Fullorder.php 238 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Fullorder 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_fullorderexcel','fullorderexcel');
  9. $this->load->_model('Model_shop','shop');
  10. $this->load->_model('Model_typeclass','typeclass');
  11. $this->load->_model('Model_express','express');
  12. $this->load->_model('Model_country','country');
  13. $this->load->_model('Model_productdescribe','productdescribe');
  14. $this->load->_model('Model_customs','customs');
  15. $this->load->_model('Model_detailed','detailed');
  16. $this->load->_model('Model_productdescription','productdescription');
  17. $this->load->_model('Model_logistics','logistics');
  18. $this->load->_model('Model_hl','hl');
  19. $this->load->_model('Model_excel','excel');
  20. $this->load->_model('Model_warehouse','warehouse');
  21. $this->load->_model('Model_customer','customer');
  22. $this->load->_model('Model_user','user');
  23. $this->load->_model('Model_dhl','dhl');
  24. $this->load->_model('Model_ali','ali');
  25. $this->load->_model('Model_notice','notice');
  26. $this->load->_model('Model_api','api');
  27. $this->load->_model('Model_usps','usps');
  28. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  29. $this->load->_model('Model_whlabel','whlabel');
  30. $this->load->_model('Model_reset','fullreset');
  31. $this->load->_model('Model_specialstock','specialstock');
  32. $this->load->_model('Model_systemwigsout','systemwigsout');
  33. $this->load->_model('Model_colourorderts','colourorderts');
  34. $this->load->_model('Model_paypal','paypal');
  35. $this->load->_model('Model_ck','ck');
  36. $this->load->_model('Model_weight','weight');
  37. $this->load->_model('Model_pay','pay');
  38. $this->load->_model('Model_setting','setting');
  39. $this->load->_model('Model_whlabel_fc','whlabel_fc');
  40. $this->load->_model('Model_transfer','transfer');
  41. $this->load->_model('Model_systemtransfer','systemtransfer');
  42. $this->load->_model('Model_power','power');
  43. $this->load->_model('Model_awlgx','awlgx');
  44. $this->load->_model('Model_fullorderhb','fullorderhb');
  45. $this->load->_model('Model_notice','notice');
  46. $this->load->_model('Model_producttitle','producttitle');
  47. $this->load->_model('Model_emaildata','emaildata');
  48. $this->load->_model('Model_afspaypal','afspaypal');
  49. $this->load->_model('Model_returngoods','returngoods');
  50. $this->load->_model('Model_message','message');
  51. $this->load->_model("Model_logic_order","logic_order");
  52. $this->load->_model("Model_logic_ding","logic_ding");
  53. $this->load->_model("Model_fullordererrors","fullordererrors");
  54. $this->load->_model("Model_logic_whlabel","logic_whlabel");
  55. $this->load->_model("Model_retreatlogs","retreatlogs");
  56. }
  57. //定义方法的调用规则 获取URI第二段值
  58. public function _remap($arg,$arg_array)
  59. {
  60. if($arg == 'add')//添加
  61. {
  62. $this->_add();
  63. }
  64. else if($arg == 'edit')//修改
  65. {
  66. $this->_edit($arg_array);
  67. }
  68. else if($arg == 'readonly')//修改
  69. {
  70. $this->_readonly($arg_array);
  71. }
  72. else if($arg == 'readlist')
  73. {
  74. $this->_readlist();
  75. }
  76. else if($arg == 'readlistdown')
  77. {
  78. $this->_readlistdown();
  79. }
  80. else if($arg == 'del')//修改
  81. {
  82. $this->_del();
  83. }
  84. else if($arg == 'price')//价格明细
  85. {
  86. $this->_price();
  87. }
  88. else if($arg == 'customs')
  89. {
  90. $this->_customs();
  91. }
  92. else if($arg == 'express')
  93. {
  94. $this->_express();
  95. }
  96. else if($arg == 'hl')
  97. {
  98. $this->_hl();
  99. }
  100. else if($arg == 'repeat')
  101. {
  102. $this->_repeat();
  103. }
  104. else if($arg == 'operation')
  105. {
  106. $this->_operation();
  107. }
  108. else if($arg == 'merge')
  109. {
  110. $this->_merge();
  111. }
  112. else if($arg == 'fmexcel')
  113. {
  114. $this->_fmexcel();
  115. }
  116. else if($arg == 'fdexcel')
  117. {
  118. $this->_fdexcel();
  119. }
  120. else if($arg == 'fdfexcel')
  121. {
  122. $this->_fdfexcel();
  123. }
  124. else if($arg == 'evaluate')
  125. {
  126. $this->_evaluate();
  127. }
  128. else if($arg == 'state')
  129. {
  130. $this->_state();
  131. }
  132. else if($arg == 'wl')
  133. {
  134. $this->_wl();
  135. }
  136. else if($arg == 'wlbz')
  137. {
  138. $this->_wlbz($arg_array);
  139. }
  140. else if($arg == 'review')
  141. {
  142. $this->_review();
  143. }
  144. else if($arg == 'black')
  145. {
  146. $this->_black();
  147. }
  148. else if($arg == 'ryf')
  149. {
  150. $this->_ryf();
  151. }
  152. else if($arg == 'expresstype')
  153. {
  154. $this->_expresstype();
  155. }
  156. else if($arg == 'fsstate')
  157. {
  158. $this->_fsstate();
  159. }
  160. else if($arg == 'power')
  161. {
  162. $this->_power();
  163. }
  164. else if($arg == 'error')
  165. {
  166. $this->_error();
  167. }
  168. else if($arg == 'yzaddress')
  169. {
  170. $this->_yzaddress();
  171. }
  172. else if($arg == 'return')
  173. {
  174. $this->_return();
  175. }
  176. else if($arg == 'clearreturn')
  177. {
  178. $this->_clearreturn();
  179. }
  180. else if($arg == 'ali')
  181. {
  182. $this->_ali();
  183. }
  184. else if($arg == 'dqpm')
  185. {
  186. $this->_dqpm();
  187. }
  188. else if($arg == 'ddpmdata')
  189. {
  190. $this->_ddpmdata($arg_array);
  191. }
  192. else if($arg == 'dqpmprovince')
  193. {
  194. $this->_dqpmprovince($arg_array);
  195. }
  196. else if($arg == 'ddpmexcel')
  197. {
  198. $this->_ddpmexcel($arg_array);
  199. }
  200. else if($arg == 'statedc')
  201. {
  202. $this->_statedc();
  203. }
  204. else if($arg == 'statedcwl')
  205. {
  206. $this->_statedcwl();
  207. }
  208. else if($arg == 'waybillemail')
  209. {
  210. $this->_waybillemail();
  211. }
  212. else if($arg == 'khdd')
  213. {
  214. $this->_khdd();
  215. }
  216. else if($arg == 'klarnadata')
  217. {
  218. $this->_klarnadata();
  219. }
  220. else if($arg == 'epod')
  221. {
  222. $this->_epod();
  223. }
  224. else if($arg == 'zw')
  225. {
  226. $this->_zw($arg_array);
  227. }
  228. else if($arg == 'thxz')
  229. {
  230. $this->_thxz($arg_array);
  231. }
  232. else if($arg == 'dcdxyz')
  233. {
  234. $this->_dcdxyz();
  235. }
  236. else if($arg == 'ddcf')
  237. {
  238. $this->_ddcf();
  239. }
  240. else if($arg == 'cf')
  241. {
  242. $this->_cf();
  243. }
  244. else
  245. {
  246. $this->_index();
  247. }
  248. }
  249. //管理
  250. public function _index()
  251. {
  252. $dt = 0;$fgshop = "shop = 0";$sid = 'id = 0';
  253. if(isset($_SESSION['api']))
  254. {
  255. $user = $this->user->get_api($_SESSION['api']);
  256. $usp = $user;
  257. $fgshop = "";$sid = "";
  258. $usersp = explode('|',trim($user['shop'],'|'));
  259. foreach ($usersp as $value)
  260. {
  261. $fgshop .= " shop = ".$value." or";
  262. $sid .= " id = ".$value." or";
  263. }
  264. if($user['vip'] == 1)
  265. {
  266. $vip = 1;
  267. }
  268. else
  269. {
  270. $vip = 0;
  271. }
  272. if(in_array($user['id'],[53241,10])){
  273. $this->data['yjtj'] = 1;
  274. }else{
  275. $this->data['yjtj'] = 0;
  276. }
  277. }
  278. else
  279. {
  280. $vip = 0;
  281. header('Location: /');exit;
  282. }
  283. $post = $this->input->post(NULL, TRUE);
  284. if(isset($post['page']))
  285. {
  286. $page = $this->input->post('page',true);
  287. $perpage = $this->input->post('perpage',true);
  288. $warehouse = $this->input->post('warehouse',true);
  289. $timetk = $this->input->post('timetk',true);
  290. $timetj = $this->input->post('timetj',true);
  291. $shop = $this->input->post('shop',true);
  292. $source = $this->input->post('source',true);
  293. $state = $this->input->post('state',true);
  294. $review = $this->input->post('review',true);
  295. $type = $this->input->post('type',true);
  296. $express = $this->input->post('express',true);
  297. $orderinfo = $this->input->post('orderinfo',true);
  298. $user = $this->input->post('user',true);
  299. $client = $this->input->post('name',true);
  300. $waybill = $this->input->post('waybill',true);
  301. $waybillid = $this->input->post('waybillid',true);
  302. $number = $this->input->post('number',true);
  303. $email = $this->input->post('email',true);
  304. $phone = $this->input->post('phone',true);
  305. $dlz = $this->input->post('dlz',true);
  306. $print = $this->input->post('print',true);
  307. $library = $this->input->post('library',true);
  308. $js = $this->input->post('js',true);
  309. $exstate = $this->input->post('exstate',true);
  310. $xztime = $this->input->post('xztime',true);
  311. $libraryconfirm = $this->input->post('libraryconfirm',true);
  312. $timetk = strtotime($timetk);
  313. $timetj = strtotime($timetj);
  314. $plorder = $this->input->post('pl',true);
  315. $paypal = $this->input->post('paypal',true);
  316. $pay = $this->input->post('pay',true);
  317. $klarna = $this->input->post('klarna',true);
  318. $orderremarks = $this->input->post('orderremarks',true);
  319. $zf = $this->input->post('zf',true);
  320. $where = "1=1 and (".rtrim($fgshop,'or').")";
  321. if($warehouse)
  322. {
  323. $where .= " and type = '$warehouse'";
  324. }
  325. if($timetk && $timetj)
  326. {
  327. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  328. }
  329. if($shop)
  330. {
  331. $where .= " and shop = '$shop'";
  332. }
  333. if($source)
  334. {
  335. if($source == '2d')
  336. {
  337. $where .= " and source >= '2'";
  338. }
  339. else
  340. {
  341. $where .= " and source = '$source'";
  342. }
  343. }
  344. if($state)
  345. {
  346. $where .= " and state = '$state'";
  347. }
  348. if($review)
  349. {
  350. $where .= " and review = '$review'";
  351. }
  352. if($type)
  353. {
  354. $where .= " and type = '$type'";
  355. }
  356. if($express)
  357. {
  358. $where .= " and express = '$express'";
  359. }
  360. if($orderinfo)
  361. {
  362. $where .= " and orderinfo = '$orderinfo' and orderinfo != '0'";
  363. }
  364. if($user)
  365. {
  366. $where .= " and user = '$user'";
  367. }
  368. if($client)
  369. {
  370. $where .= " and client like '%$client%'";
  371. }
  372. if($waybill)
  373. {
  374. $where .= " and waybill like '%$waybill%'";
  375. }
  376. if($waybillid){
  377. $where .= " and waybillid like '%".$waybillid."%'";
  378. }
  379. if($number)
  380. {
  381. $where .= " and number like '$number%'";
  382. }
  383. if($email)
  384. {
  385. $where .= " and ((email = '$email') or (send_email = '$email')) ";
  386. }
  387. if($phone)
  388. {
  389. $where .= " and phone like '%$phone%'";
  390. }
  391. if($library)
  392. {
  393. $where .= " and library = '$library'";
  394. }
  395. if($print)
  396. {
  397. $where .= " and print = '$print'";
  398. }
  399. if($dlz != '')
  400. {
  401. $where .= " and dlz = '$dlz'";
  402. }
  403. if($js)
  404. {
  405. $where .= " and js = '$js'";
  406. }
  407. if($exstate)
  408. {
  409. $where .= " and exstate = '$exstate'";
  410. }
  411. if($libraryconfirm)
  412. {
  413. $where .= " and libraryconfirm = '$libraryconfirm'";
  414. }
  415. if($klarna != '')
  416. {
  417. if($klarna == 2)
  418. {
  419. $where .= " and klarna >= '$klarna'";
  420. }
  421. else
  422. {
  423. $where .= " and klarna = '$klarna'";
  424. }
  425. }
  426. if($paypal)
  427. {
  428. $where .= " and paypal = '$paypal'";
  429. }
  430. if($pay)
  431. {
  432. $where .= " and pay = '$pay'";
  433. }
  434. if($zf)
  435. {
  436. if($zf == 1)
  437. {
  438. $where .= " and paypal not like '%-%-%-%'";
  439. }
  440. else
  441. {
  442. $where .= " and paypal like '%-%-%-%'";
  443. }
  444. }
  445. if($orderremarks){
  446. $where .= " and orderremarks like '%$orderremarks%'";
  447. }
  448. if($plorder)
  449. {
  450. $plorderinfo = '';$plnumber = '';$pln = 0;
  451. $plorder = explode(',',trim($plorder,','));
  452. foreach ($plorder as $value)
  453. {
  454. if(is_numeric($value))
  455. {
  456. $plorderinfo .= " orderinfo = ".$value." or";
  457. }
  458. else if($value != '')
  459. {
  460. $plorderinfo .= " number = '".$value."' or";
  461. }
  462. }
  463. if($pln > 0)
  464. {
  465. $where .= " and (".rtrim($plorderinfo,'or').") and (".rtrim($plnumber,'or').")";
  466. }
  467. else
  468. {
  469. $where .= " and (".rtrim($plorderinfo,'or').")";
  470. }
  471. }
  472. //数据排序
  473. $order_str = "dtime desc";
  474. if(empty($page))
  475. {
  476. $start = 0;
  477. $perpage = 1;
  478. }
  479. else
  480. {
  481. $start = ($page - 1)*$perpage;
  482. }
  483. //取得信息列表id,shop,type,source,user,orderinfo,number,name,state,buytime,clientremarks,review,print,library,libraryconfirm,express,waybill,orderremarks,black
  484. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,sname,email,state,buytime,review,libraryconfirm,express,waybill,orderremarks,library,black,clientremarks,waybillid',$order_str,$start,$perpage);
  485. //格式化数据
  486. foreach ($info_list as $key=>$value)
  487. {
  488. $rginfo = $this->returngoods->get_orderinfo($value['orderinfo']);
  489. if(!empty($rginfo)){
  490. $info_list[$key]['number'] = $value['number']."<br/>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="'.$rginfo['remark'].'"></i><p>';
  491. }
  492. $ud = $this->fullorder->read($value['id']);
  493. $ud['address'] = str_replace("'","’",$ud['address']);
  494. $ud['name'] = str_replace("'","’",$ud['name']);
  495. $customer = $this->customer->get_email($ud['email'],$value['shop']);
  496. if(empty($customer)){
  497. $customer = $this->customer->get_email($ud['send_email'],$value['shop']);
  498. }
  499. $customernum = $this->fullorder->find_count("email = '".$ud['email']."' and shop = '".$value['shop']."' and extra_status = 0");
  500. preg_match_all('/[0-9]/u',$ud['phone'],$result);
  501. $numphone = join('',$result[0]);
  502. $hmdaddress1 = str_replace(array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),strtolower($ud['address']));
  503. $hmdaddress2 = str_replace(array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),strtolower($ud['address']));
  504. $hmdaddress3 = str_replace(array(' avenue',' ave',' av'),array(' ave',' avenue',' ave'),strtolower($ud['address']));
  505. if($numphone == '0')
  506. {
  507. $customerb = $this->customer->find_all("type = 2 and (email = '".$ud['email']."' or address = '".$ud['address']."' or address = '".$hmdaddress1."' or address = '".$hmdaddress2."' or address = '".$hmdaddress3."' or phone = '".$numphone."')",'*','id desc');
  508. }
  509. else
  510. {
  511. $customerb = $this->customer->find_all("type = 2 and (email = '".$ud['email']."' or address = '".$ud['address']."' or address = '".$hmdaddress1."' or address = '".$hmdaddress2."' or address = '".$hmdaddress3."' or numphone = '".$numphone."')",'*','id desc');
  512. }
  513. $customerc = $this->customer->find_all("type = 1 and shop = '".$ud['shop']."' and address = '".$ud['address']."' and numphone = '".$numphone."'",'*','id desc');
  514. $customerd = $this->customer->find_all("type = 2 and shop = '".$ud['shop']."' and email = '".$ud['email']."'",'*','id desc');
  515. //$a = array_column($customer, 'email'); //三维找其中健的数组
  516. //$a = array_flip($a); //键和值调换
  517. $djcount = '';
  518. $lkh = $value['sname'];
  519. $djlkh = 0;$djhmd = 0;
  520. if($customer)
  521. {
  522. if($customer['count'] != '' && $customernum < 2)
  523. {
  524. $count = '<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>';
  525. $djcount = $count;
  526. }
  527. if(($customer['type'] == 1 && $customernum > 1))// || $customerc['type'] == 1 && $customerc['num'] > 1
  528. {
  529. $count = $customer['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>':'';
  530. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户(".$customer['num'].")</p>";
  531. $djlkh = 1;
  532. $djcount = $count;
  533. }
  534. else if(isset($customerc[0]['num']))
  535. {
  536. if($customerc[0]['num'] > 1)
  537. {
  538. $count = $customer['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>':'';
  539. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户(".$customer['num'].")</p>";
  540. $djlkh = 1;
  541. $djcount = $count;
  542. }
  543. }
  544. }
  545. if($customerb)
  546. {
  547. $hmsp = $this->shop->read($customerb[0]['shop']);
  548. $count = $customerb[0]['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customerb[0]['count'].'"></i>':'';
  549. $lkh = "<p>".$value['sname']."</p><p style='color:#9900CC'>".$count."黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  550. $djhmd = 1;
  551. if($customerd)
  552. {
  553. if($customerd[0]['num'] > 1)
  554. {
  555. $count = $customerd[0]['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customerd[0]['count'].'"></i>':'';
  556. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户</p>";
  557. $djlkh = 1;
  558. $djcount = $count;
  559. $djlkh = 1;
  560. }
  561. }
  562. }
  563. if($djlkh == '1' && $djhmd == '1')
  564. {
  565. $lkh = "<p>".$value['sname']."</p><p style='color:#9900CC'><em style='color:#FF3333'>".$djcount."老客户</em> - ".$count."黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  566. }
  567. if($djlkh != '1' && $djhmd != '1' && $djcount)
  568. {
  569. $info_list[$key]['sname'] = $lkh."<p style='color:#FF3333'>".$djcount."</p>";
  570. }
  571. else
  572. {
  573. $info_list[$key]['sname'] = $lkh;
  574. }
  575. // $rginfo_list = $this->returngoods->find_all("email = '".$value['email']."'");
  576. // if(!empty($rginfo_list))
  577. // {
  578. // $tmp_str = '';
  579. // foreach ($rginfo_list as $k => $v) {
  580. // $tmp_str .= $v['remark'].'<br/>';
  581. // }
  582. // $info_list[$key]['sname'] = $info_list[$key]['sname']."<br/>售后单(".count($rginfo_list).")".'<p style="color:blue"><i class="method fa fa-list-ul" data-t="'.$tmp_str.'"></i><p>';
  583. // }
  584. $shop = $this->shop->read($value['shop']);
  585. $info_list[$key]['shop'] = $shop['shopname'];
  586. //$info_list[$key]['user'] = $shop['shopuser'];
  587. $warehouse = $this->warehouse->read($value['type']);
  588. $warehousetitle = $warehouse['title'];
  589. if($value['type'] != 13){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  590. $info_list[$key]['type'] = $warehousetitle;
  591. if(empty($ud['send_email'])){
  592. $info_list[$key]['email'] = '<em style="font-size: 13px;">'.$value['email'].'</em><br />'.$ud['phone'];
  593. }else{
  594. $info_list[$key]['email'] = '<em style="font-size: 13px;">'.$value['email'].'</em><br />'.'<em style="font-size: 13px;">'.$ud['send_email'].'</em><br />'.$ud['phone'];
  595. }
  596. $typeclass = $this->typeclass->read($value['state']);
  597. $info_list[$key]['state'] = "<font style='font-size: 13px;'>".$typeclass['spare']."</font>";
  598. /**
  599. $wl = '';
  600. if($value['exstate'] == '99')
  601. {
  602. $wl = '<font style="color:#ccc">未获取到物流信息</font>';
  603. }
  604. else if($value['exstate'] == '1')
  605. {
  606. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">已揽收<font style="display: none">'.$ud['excontent'].'</font></font>';
  607. }
  608. else if($value['exstate'] == '2')
  609. {
  610. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">在途中<font style="display: none">'.$ud['excontent'].'</font></font>';
  611. }
  612. else if($value['exstate'] == '3')
  613. {
  614. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">派送中<font style="display: none">'.$ud['excontent'].'</font></font>';
  615. }
  616. else if($value['exstate'] == '4')
  617. {
  618. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">已签收<font style="display: none">'.$ud['excontent'].'</font></font>';
  619. }
  620. else if($value['exstate'] == '5')
  621. {
  622. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">派送异常<font style="display: none">'.$ud['excontent'].'</font></font>';
  623. }
  624. $info_list[$key]['exstate'] = $wl.'<br />';
  625. **/
  626. if($ud['source'] == 1) //线下单用订单时间,其他用付款时间
  627. {
  628. $info_list[$key]['buytime'] = '<p style="font-size: 13px;">'.date('Y-m-d',$ud['dtime']).'</p><p style="font-size: 13px;">'.date('H:i:s',$ud['dtime']).'</p>';
  629. }
  630. else
  631. {
  632. $info_list[$key]['buytime'] = '<p style="font-size: 13px;">'.date('Y-m-d',$value['buytime']+$dt).'</p><p style="font-size: 13px;">'.date('H:i:s',$value['buytime']+$dt).'</p>';
  633. }
  634. if($value['review'] == 1)
  635. {
  636. $info_list[$key]['review'] = "<font style='font-size: 13px;'>未送审</font>";
  637. }
  638. else if($value['review'] == 2)
  639. {
  640. $info_list[$key]['review'] = "<font style='color:#555;font-size: 13px;'>待审核</font>";
  641. }
  642. else if($value['review'] == 3)
  643. {
  644. $info_list[$key]['review'] = "<font style='color:#f90f4b;font-size: 13px;'>不通过</font>";
  645. }
  646. else if($value['review'] == 4)
  647. {
  648. $info_list[$key]['review'] = "<font style='font-size: 13px;'>取消重审</font>";
  649. }
  650. else if($value['review'] == 5)
  651. {
  652. $info_list[$key]['review'] = "<font style='color:#2f80f9;font-size: 13px;'>审核通过</font>";
  653. }
  654. else if($value['review'] == 6)
  655. {
  656. $info_list[$key]['review'] = "<font style='color:#2f80f9;font-size: 13px;'>自动通过</font>";
  657. }
  658. if($ud['dlz'] == 1)
  659. {
  660. $dlz = "<p>独立站已更新</p>";
  661. }
  662. else if($ud['dlz'] == 3)
  663. {
  664. $dlz = "<p>不需要更新</p>";
  665. }
  666. else if($ud['dlz'] == 2)
  667. {
  668. $dlz = "<p style='color:#C3C'>独立站更新失败</p>";
  669. }
  670. else
  671. {
  672. $dlz = "";
  673. }
  674. if($value['waybill'] != "")
  675. {
  676. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz;
  677. //如果是云尚快线那么需要展示一个可以查全程的运单号
  678. if( !empty($value['waybillid'])){
  679. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz."<p>".$value['waybillid']."</p>";
  680. }
  681. }
  682. if($value['express'] != 0)
  683. {
  684. $express = $this->express->read($value['express']);
  685. $expressservicename = $express['servicename'];
  686. if($value['express'] != 1 && $value['express'] != 63)
  687. {
  688. $expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";
  689. }
  690. else if($value['express'] == 63)
  691. {
  692. $expressservicename = "<font style='color:#a910f8'>".$express['servicename']."</font>";
  693. }
  694. $info_list[$key]['express'] = $expressservicename;
  695. }
  696. else
  697. {
  698. $info_list[$key]['express'] = "无";
  699. }
  700. $x = "";
  701. if($value['libraryconfirm'] == 2 && $value['review'] > 4 && $ud['library'] == 1)
  702. {
  703. $x = "<p class='ckn'><b class='fojz' data-type='1'>禁止发货</b></p>";
  704. }
  705. else if(($value['review'] > 4) && $ud['print'] != 1 && $value['libraryconfirm'] == 1)
  706. {
  707. $x = "<p class='ckn'><b class='fojzof' data-type='6' data-id='".$value['id']."'>允许发货</b></p>";
  708. }
  709. if(($value['review'] > 4) && $ud['print'] == 2)
  710. {
  711. $x = "<p class='ckn'><b class='fojzof' data-type='7' data-id='".$value['id']."'>禁止打印</b></p>";
  712. }
  713. else if($value['review'] >4 && $ud['print'] == 1)
  714. {
  715. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  716. }
  717. if($value['waybill'] == "" && $value['review'] > 4)
  718. {
  719. $x .= "<p><b class='kn' data-type='2'>填写运单号</b></p>";
  720. }
  721. else if($value['waybill'] != "" && $value['review'] > 4)
  722. {
  723. $x .= "<p><b class='kn' data-type='2'>修改运单号</b></p>";
  724. }
  725. if(($value['review'] == 1 || $value['review'] == 3) && $ud['express'] > 0 && $ud['dtsbjz'] != 0 && $ud['ts'] != 0 && $ud['zsbjz'] != 0 && $ud['zjs'] != 0 && $ud['ts'] != 0 && ($ud['merge'] == 0 || $ud['merge'] != 0 && $ud['merge'] == $ud['id']))
  726. {
  727. $x .= "<p><b class='focz' data-type='2' data-id='".$value['id']."'>提交审核</b></p>";
  728. }
  729. $x .= "<p><b class='window' data-h='/customer/edit/".$customer['id']."' data-t='客户信息 - 修改'>客户信息</b></p>";
  730. $info_list[$key]['black'] = $x;
  731. $tly = "";
  732. if($value['clientremarks'] != "")
  733. {
  734. $tly = "<p style='color:#FF3333'>有客户留言</p>";
  735. }
  736. if($value['review'] > 4 && $usp['vip'] != 1 && ($ud['merge'] == 0 || $ud['merge'] == $ud['id']))
  737. {
  738. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullorder/readonly/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  739. }
  740. else if($ud['merge'] == 0 || $ud['merge'] == $ud['id'])
  741. {
  742. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullorder/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  743. }
  744. else if($ud['merge'] != 0 && $ud['merge'] != $ud['id'])
  745. {
  746. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullorder/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."' style='color:#000'><p>".$value['orderinfo']."</p>".$tly."</h9>"."<p>合并订单</p>";
  747. }
  748. else
  749. {
  750. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullorder/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  751. }
  752. if($value['library'] == 1 && $ud['printtype'] == 3)
  753. {
  754. $info_list[$key]['library'] = "不需要";
  755. }
  756. else if($value['library'] == 1 && $ud['printtype'] != 3)
  757. {
  758. $info_list[$key]['library'] = "未出库";
  759. }
  760. else if($value['library'] == 2)
  761. {
  762. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  763. }
  764. else if($value['library'] == 3)
  765. {
  766. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  767. }
  768. unset($info_list[$key]['waybillid']);
  769. }
  770. $total = $this->fullorder->find_count($where);
  771. $pagenum = ceil($total/$perpage);
  772. $over = $total-($start+$perpage);
  773. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  774. echo json_encode($rows);exit;
  775. }
  776. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  777. $this->data['wlshop'] = $wlshop;
  778. $this->data['express'] = $this->express->find_all();
  779. $user = $this->user->get_api($_SESSION['api']);
  780. $powerid = $this->power->read($user['power']);
  781. $powertext = explode('|',trim($powerid['excelid'],'|'));
  782. $pid = '';
  783. foreach ($powertext as $v)
  784. {
  785. $pid .= " id = ".$v." or";
  786. }
  787. $fullorderexcel = $this->fullorderexcel->find_all("type = '100001' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  788. $this->data['fullorderexcel'] = $fullorderexcel;
  789. $error = $this->fullorder->find_count("failed !='' and mergeid = 0 and print != 3 and (".rtrim($fgshop,'or').") and dtime > '".(time()-90*24*3600)."'");
  790. $this->data['error'] = $error;
  791. $cs_num = $this->fullordererrors->find_count( " plat = 'fullorder' and error_type = 1 and (".rtrim($fgshop,'or'). " ) and error_time > '".(time()-90*24*3600)."'");
  792. $this->data['cs_num'] = $cs_num;
  793. $this->data['power'] = $vip;
  794. $this->_Template('fullorder',$this->data);
  795. }
  796. //筛选重复订单
  797. public function _repeat()
  798. {
  799. $user = $this->user->get_api($_SESSION['api']);
  800. if($user)
  801. {
  802. $fgshop = "";$sid = "";
  803. $user = explode('|',trim($user['shop'],'|'));
  804. foreach ($user as $value)
  805. {
  806. $fgshop .= " shop = ".$value." or";
  807. $sid .= " id = ".$value." or";
  808. }
  809. }
  810. $post = $this->input->post(NULL, TRUE);
  811. if(isset($post['page']))
  812. {
  813. $page = $this->input->post('page',true);
  814. $perpage = $this->input->post('perpage',true);
  815. $shop = $this->input->post('shop',true);
  816. $email = $this->input->post('email',true);
  817. $timetk = $this->input->post('timetk',true);
  818. $timetj = $this->input->post('timetj',true);
  819. $timetk = strtotime($timetk);
  820. $timetj = strtotime($timetj);
  821. $where = "print != 999 and state = 207 and review = 1 and number NOT like '%-%-%-%' and (".rtrim($fgshop,'or').")";
  822. if($shop)
  823. {
  824. $where .= " and shop = '$shop'";
  825. }
  826. if($email)
  827. {
  828. $where .= " and email = '$email'";
  829. }
  830. if($timetk && $timetj)
  831. {
  832. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  833. }
  834. //数据排序
  835. $order_str = "id desc";
  836. if(empty($page))
  837. {
  838. $start = 0;
  839. $perpage = 1;
  840. }
  841. else
  842. {
  843. $start = ($page - 1)*$perpage;
  844. }
  845. //取得信息列表
  846. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,name,email,address,state,dtime,shipremarks,type,merge');
  847. $info = array();
  848. $len = count($info_list);
  849. //格式化数据
  850. foreach ($info_list as $key=>$value)
  851. {
  852. $ud = $this->fullorder->read($value['id']);
  853. $shop = $this->shop->read($value['shop']);
  854. $warehouse = $this->warehouse->read($value['type']);
  855. $info_list[$key]['shop'] = '<p>'.$shop['shopname'].'</p>'.'<p>'.$warehouse['title'].'</p>';
  856. $info_list[$key]['email'] = '<p>'.$value['email'].'</p>'.'<p>'.$ud['phone'].'</p>';
  857. $typeclass = $this->typeclass->read($value['state']);
  858. $info_list[$key]['state'] = $typeclass['spare'];
  859. $info_list[$key]['type'] = $ud['orderremarks'];
  860. $info_list[$key]['dtime'] = '<p>'.date('Y-m-d',$value['dtime']).'</p><p>'.date('H:i:s',$value['dtime']).'</p>';
  861. if($value['merge'] == 0)
  862. {
  863. $info_list[$key]['merge'] = "<p>可合并</p>";
  864. }
  865. else
  866. {
  867. if($value['merge'] == $value['id'])
  868. {
  869. if($ud['print'] < '3' && $ud['library'] == '1')
  870. {
  871. $info_list[$key]['merge'] = "<p><b class='cforder' data-id='".$value['id']."'>拆分订单</b></p>";
  872. }
  873. else
  874. {
  875. $info_list[$key]['merge'] = "已合并";
  876. }
  877. }
  878. else
  879. {
  880. $info_list[$key]['merge'] = "被合并";
  881. }
  882. }
  883. }
  884. /** 操作合并
  885. if($value['merge'] == 0)
  886. {
  887. $info_list[$key]['merge'] = "<p><b class='jd' data-type='5'>合并订单</b></p>";
  888. }
  889. else
  890. {
  891. if($value['merge'] == $value['id'])
  892. {
  893. $info_list[$key]['merge'] = "已合并";
  894. }
  895. else
  896. {
  897. $info_list[$key]['merge'] = "被合并";
  898. }
  899. }
  900. **/
  901. $asd = array();
  902. for($i=0;$i<$len;$i++)
  903. {
  904. for($j=$i+1;$j<$len;$j++)
  905. {
  906. if (strtolower($info_list[$i]['address']) == strtolower($info_list[$j]['address']) && stripos($info_list[$i]['number'],$info_list[$j]['number']) === false && stripos($info_list[$j]['number'],$info_list[$i]['number']) === false) //$info_list[$i]['email'] == $info_list[$j]['email']
  907. {
  908. if(!array_key_exists($j,$info))
  909. {
  910. $info[$j] = $info_list[$j];
  911. }
  912. if(!array_key_exists($i,$info))
  913. {
  914. $info[$i] = $info_list[$i];
  915. }
  916. }
  917. }
  918. }
  919. rsort($info);
  920. $total = count($info);
  921. $pagenum = ceil($total/$perpage);
  922. $over = $total-($start+$perpage);
  923. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_slice($info,$start,$perpage)));
  924. echo json_encode($rows);exit;
  925. }
  926. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  927. $this->data['wlshop'] = $wlshop;
  928. $this->_Template('fullorder_repeat',$this->data);
  929. }
  930. //修改
  931. public function _edit($arg_array)
  932. {
  933. if(isset($_SESSION['api']))
  934. {
  935. $user = $this->user->get_api($_SESSION['api']);
  936. if($user['vip'] == 1)
  937. {
  938. $vip = 1;
  939. }
  940. else
  941. {
  942. $vip = 0;
  943. }
  944. $this->data['userid'] = $user['id'];
  945. }
  946. else
  947. {
  948. $this->data['userid'] = 0;
  949. $vip = 0;
  950. }
  951. $post = $this->input->post(NULL, TRUE);
  952. if(isset($post['id']))
  953. {
  954. // $dtsbjz = $this->input->post('dtsbjz',true);
  955. // $ts = $this->input->post('ts',true);
  956. // $dtsbjz = sprintf("%.2f",$dtsbjz);
  957. // $total_sbjz = $dtsbjz*$ts;
  958. // $tmp_zsbjz = $this->input->post('zsbjz',true);
  959. // $tmp_zsbjz = sprintf("%.2f",$tmp_zsbjz);
  960. // if($tmp_zsbjz*1 != $total_sbjz){
  961. // echo json_encode(array('msg'=>'单条申报价为2为小数!','success'=>false));exit;
  962. // }
  963. $id = $this->input->post('id',true);
  964. $data = $this->fullorder->read($id);
  965. $post['type'] = $this->input->post('warehouse',true);
  966. $post['country'] = $this->input->post('country',true);
  967. $currency = $this->country->read($post['country']);
  968. $post['al'] = $currency['lb'];
  969. $post['freight'] = $this->input->post('freight',true);
  970. $post['expressmoney'] = $this->input->post('expressmoney',true);
  971. $post['shouldmoney'] = $this->input->post('shouldmoney',true);
  972. $orderremarks = $this->input->post('orderremarks');
  973. $orderremarks = str_replace(array('%26','%2B'),array('&','+'),$orderremarks);
  974. $post['orderremarks'] = $orderremarks;
  975. $shipremarks = $this->input->post('shipremarks');
  976. $shipremarks = str_replace(array('%26','%2B'),array('&','+'),$shipremarks);
  977. $post['shipremarks'] = preg_replace('/( | | |\s)/',' ',$shipremarks);
  978. $email = $this->input->post('email',true);
  979. $post['email'] = preg_replace('/( | | |\s)/','',$email);
  980. //$post['paypal'] = $this->input->post('paypal',true);
  981. $name = $this->input->post('name',true);
  982. $post['name'] = str_replace("'","’",$name);
  983. $post['phone'] = $this->input->post('phone',true);
  984. $post['phone'] = preg_replace('/\D/s','',$post['phone']);
  985. $post['phone'] = preg_replace('/( | | |\s)/','',$post['phone']);
  986. $post['country'] = $this->input->post('country',true);
  987. $post['province'] = $this->input->post('province',true);//省、州
  988. $post['province'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['province']); //替换开头空字符
  989. $post['province'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['province']); //替换结尾空字符
  990. $post['city'] = $this->input->post('city',true);//城市
  991. $post['city'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['city']); //替换开头空字符
  992. $post['city'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['city']); //替换结尾空字符
  993. $post['zipcode'] = $this->input->post('zipcode',true);//邮编
  994. $post['zipcode'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['zipcode']); //替换开头空字符
  995. $post['zipcode'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['zipcode']); //替换结尾空字符
  996. $post['street'] = $this->input->post('street',true);
  997. $address = $this->input->post('address',true);
  998. $address = preg_replace('/( | | |\s)/',' ',$address);
  999. $post['address'] = str_replace("'","’",$address);
  1000. $address2 = $this->input->post('address2',true);
  1001. $address2 = preg_replace('/( | | |\s)/',' ',$address2);
  1002. if($address2 == ' ')
  1003. {
  1004. $address2 = '';
  1005. }
  1006. $post['address2'] = str_replace("'","’",$address2);
  1007. $post['express'] = $this->input->post('express',true);
  1008. $post['printtype'] = $this->input->post('printtype',true);
  1009. $fpdata = $this->input->post('fpdata');
  1010. $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
  1011. $post['fpdata'] = $fpdata;
  1012. $post['waybill'] = $this->input->post('waybill',true);
  1013. $post['msg'] = $this->input->post('msg',true);
  1014. $post['zsbjz'] = $this->input->post('zsbjz',true);
  1015. $post['refundy'] = $this->input->post('refundy',true);
  1016. $post['refundj'] = $this->input->post('refundj',true);
  1017. $rtime = $this->input->post('rtime',true);
  1018. $post['rtime'] = strtotime($rtime);
  1019. $post['rpaypal'] = $this->input->post('rpaypal',true);
  1020. $post['rtext'] = $this->input->post('rtext',true);
  1021. $post['sbpm'] = $this->input->post('sbpm',true);
  1022. $post['edittime'] = time();
  1023. $editstate = $this->input->post('state',true);
  1024. if(!$editstate)
  1025. {
  1026. $editstate = $data['state'];
  1027. }
  1028. $whlabel = $this->input->post('whlabel',true);
  1029. $fpcount = $this->input->post('fpcount',true);
  1030. $post['ioss'] = $this->input->post('ioss',true);
  1031. $post['waybill'] = preg_replace('/( | | | |\s)/','',$post['waybill']);
  1032. $pay = $this->pay->get_typeclass($data['pay']);
  1033. $yga = $post['shouldmoney'];
  1034. $ygc = $data['estimaterate'];
  1035. $post['budget'] = 0;
  1036. if($post['email'] == $post['send_email']){
  1037. $post['send_email'] = '';
  1038. }
  1039. $ifbudget = eval("return $yga*1.$ygc;");
  1040. if($ifbudget > 0)
  1041. {
  1042. $post['budget'] = eval("return $yga*1.$ygc;");
  1043. }
  1044. if($data['estimaterate'] == 1){
  1045. $post['budget'] = $post['shouldmoney'];
  1046. }
  1047. $whlabeldata = explode('|',trim($whlabel,'|'));$way = 0;
  1048. foreach ($whlabeldata as $va)
  1049. {
  1050. if(stripos($va,'z') !== false)
  1051. {
  1052. $way += 1;
  1053. }
  1054. }
  1055. //如果备注中出现网红的两个字 ,那么在fpdata种的品名中必须有 WH这两个字 且美仓不用
  1056. if($post['type'] !=5 ){
  1057. if(stripos($post['shipremarks'],'网红') !== false){
  1058. if(stripos($post['fpdata'],'-2090-') === false){
  1059. echo json_encode(array('msg'=>'网红单请在商品名称中勾选WH!','success'=>false));exit;
  1060. }
  1061. }
  1062. }
  1063. if((($post['express'] == 2 || $post['express'] == 63 || $post['express'] == 64 || $post['express'] == 81 || $post['express'] == 85 || $post['express'] == 87 ) && $post['type'] != 5) )
  1064. {
  1065. echo json_encode(array('msg'=>'此快递方式必须从美仓发货!','success'=>false));exit;
  1066. }
  1067. if( ($post['express'] != 2 && $post['express'] != 63 && $post['express'] != 64 && $post['express'] != 81 && $post['express'] != 85 && $post['express'] != 87 && $post['type'] == 5)){
  1068. echo json_encode(array('msg'=>'此快递方式不能美仓发货!','success'=>false));exit;
  1069. }
  1070. //仅独立站 地址美国对电话 10或者11位进行判断
  1071. if($post['country'] == 192){
  1072. if((strlen($post['phone'])!= 10) && (strlen($post['phone'])!= 11)){
  1073. echo json_encode(array('msg'=>'美国电话号码应为10/11位!','success'=>false));exit;
  1074. }
  1075. }
  1076. //减少代码复用吧
  1077. $lo_ret = $this->logic_order->checkEditExpress($post);
  1078. if($lo_ret['code'] != 1){
  1079. echo json_encode(array('msg'=>$lo_ret['msg'],'success'=>false));exit;
  1080. }
  1081. //检测PayPal有但是为空的情况
  1082. if(isset($post['paypal'])){
  1083. if(empty($post['paypal'])){
  1084. echo json_encode(array('msg'=>'交易号不可为空!','success'=>false));exit;
  1085. }
  1086. }else{
  1087. $tmp_info = $this->fullorder->read($post['id']);
  1088. if(empty($tmp_info)){
  1089. echo json_encode(array('msg'=>'订单信息异常','success'=>false));exit;
  1090. }
  1091. if(empty($tmp_info['paypal'])){
  1092. echo json_encode(array('msg'=>'交易号不可为空!','success'=>false));exit;
  1093. }
  1094. }
  1095. // if($post['express'] == 42 && $post['sbpm'] != 'Human Hair Wigs' && $post['sbpm'] != 'Human Hair Goods')//$post['express'] == 3 ||
  1096. // {
  1097. // echo json_encode(array('msg'=>'此快递方式必须选择Human Hair Wigs/Human Hair Goods!','success'=>false));exit;
  1098. // }
  1099. if($post['express'] == 24 && $post['sbpm'] != 'Hair Sample' && $post['sbpm'] != 'Human Hair Wigs' && $post['sbpm'] != 'Human Hair Goods')//$post['express'] == 3 ||
  1100. {
  1101. echo json_encode(array('msg'=>'此快递方式必须选择Hair Sample/Human Hair Wigs/Human Hair Goods!','success'=>false));exit;
  1102. }
  1103. // if($post['country'] != 192 && $post['express'] == 1 && $post['sbpm'] != 'Synthetic Hair Wigs' && $post['sbpm'] != 'Synthetic Hair Goods')//$post['express'] == 3 ||
  1104. // {
  1105. // echo json_encode(array('msg'=>'非美国选择官方DHL必须选择Synthetic Hair Wigs/Synthetic Hair Goods','success'=>false));exit;
  1106. // }
  1107. if($way == count($whlabeldata) && $post['type'] != 12)
  1108. {
  1109. echo json_encode(array('msg'=>'必须选择特殊仓!','success'=>false));exit;
  1110. }
  1111. if($way == '0' && $post['type'] == 12)
  1112. {
  1113. echo json_encode(array('msg'=>'特殊仓必须包含特殊仓货物!','success'=>false));exit;
  1114. }
  1115. $post['review'] = 1;
  1116. if($post['zsbjz'] < '0.01')
  1117. {
  1118. echo json_encode(array('msg'=>'总申报价错误!','success'=>false));exit;
  1119. }
  1120. if($data['library'] == 1)
  1121. {
  1122. if($data['print'] != 3)
  1123. {
  1124. $post['print'] = 1;
  1125. $post['libraryconfirm'] = 1;
  1126. $post['librarynot'] = "订单未打印,未审核或未通过";
  1127. }
  1128. else
  1129. {
  1130. $post['libraryconfirm'] = 1;
  1131. $post['librarynot'] = "订单被修改或重新提交";
  1132. }
  1133. }
  1134. if($data['yhs'] == 1)
  1135. {
  1136. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  1137. }
  1138. if($post['express'] == 2 && (stripos($post['name'],'&') !== false || stripos($post['name'],"'") !== false))
  1139. {
  1140. echo json_encode(array('msg'=>'USPS收件人或公司名不可用特殊符号!','success'=>false));exit;
  1141. }
  1142. if(strlen($post['client']) > 34 || strlen($post['name']) > 34)//收件人姓名或公司名不允许超过35位
  1143. {
  1144. echo json_encode(array('msg'=>'收件人姓名或公司名不可超过34个字符!','success'=>false));exit;
  1145. }
  1146. if($post['express'] == '3' && $post['address2'] != '')//UPS不允许提交地址2
  1147. {
  1148. echo json_encode(array('msg'=>'UPS不允许提交地址2','success'=>false));exit;
  1149. }
  1150. if(($post['express'] == '5' || $post['express'] == '24' || $post['express'] == '42' || $post['express'] == '31') && $post['country'] != 192)
  1151. {
  1152. echo json_encode(array('msg'=>'非美国无法选择Fedex、DHL官方-美国!','success'=>false));exit;
  1153. }
  1154. if($post['express'] == '3' && $post['country'] != 192 && $post['country'] != 35)
  1155. {
  1156. echo json_encode(array('msg'=>'非美国和加拿大无法选择UPS!','success'=>false));exit;
  1157. }
  1158. if($post['country'] == 35 && $post['zsbjz'] > 20)
  1159. {
  1160. echo json_encode(array('msg'=>'加拿大最高申报不可超过20','success'=>false));exit;
  1161. }
  1162. if(($post['express'] == '28' || $post['express'] == '7') && $post['country'] != 191)
  1163. {
  1164. echo json_encode(array('msg'=>'非英国无法选择CNE和GES!','success'=>false));exit;
  1165. }
  1166. $express = $this->express->read($post['express']);
  1167. if($express['ioss'] == 1 && $post['ioss'] == '')
  1168. {
  1169. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  1170. }
  1171. if(strlen($post['address']) > $express['addresssize'] || strlen($post['address2']) > $express['addresssize'])
  1172. {
  1173. echo json_encode(array('msg'=>'此快递地址不可超出'.$express['addresssize'].'个字符','success'=>false));exit;
  1174. }
  1175. if(strlen($post['address']) < 5)
  1176. {
  1177. echo json_encode(array('msg'=>'地址不可留空!','success'=>false));exit;
  1178. }
  1179. if(($express['sbjz'] > 0) && ($post['zsbjz'] > $express['sbjz']))
  1180. {
  1181. echo json_encode(array('msg'=>'总申报价值不可超出'.$express['sbjz'],'success'=>false));exit;
  1182. }
  1183. if($post['shouldmoney'] > $express['shouldmoney'] && $express['shouldmoney'] != 0)
  1184. {
  1185. echo json_encode(array('msg'=>'订单金额不可超出'.$express['shouldmoney'],'success'=>false));exit;
  1186. }
  1187. if($post['express'] == '2' && $post['zzl'] > '16' && isset($post['js']) && $post['js'] == '0')
  1188. {
  1189. echo json_encode(array('msg'=>'重量大于16不可按Ground Advantage提交!','success'=>false));exit;
  1190. }
  1191. // if($post['express'] == '2' && isset($post['js']) && $post['js'] == '0'&& $post['qm'] == '1')
  1192. // {
  1193. // echo json_encode(array('msg'=>'Ground Advantage不可使用签名服务!','success'=>false));exit;
  1194. // }
  1195. if(isset($post['bx']))
  1196. {
  1197. if($post['express'] == '99' && $post['bx'] > 0)
  1198. {
  1199. echo json_encode(array('msg'=>'此物流不允许购买保险','success'=>false));exit;
  1200. }
  1201. }
  1202. if(($post['express'] == '3' || $post['express'] == '42' || $post['express'] == '24') && $post['shouldmoney'] < 1)
  1203. {
  1204. //echo json_encode(array('msg'=>'零金额订单不可发 UPS/DHL官方-美国/Fedex(杭州)','success'=>false));exit;
  1205. }
  1206. if($post['express'] == '42' && $post['zsbjz'] < 1)
  1207. {
  1208. echo json_encode(array('msg'=>'零申报金额不可发 DHL官方-美国','success'=>false));exit;
  1209. }
  1210. if($post['express'] == '6' && $post['province'] == '')
  1211. {
  1212. echo json_encode(array('msg'=>'选择DPEX必须填写州信息','success'=>false));exit;
  1213. }
  1214. if(($post['express'] == '24' || $post['express'] == '3') && $post['shouldmoney'] == 0)
  1215. {
  1216. echo json_encode(array('msg'=>'0金额订单不可发UPS/Fedex(杭州)!!!','success'=>false));exit;
  1217. }
  1218. if($post['country'] == '35' && $post['zsbjz'] > 20)
  1219. {
  1220. echo json_encode(array('msg'=>'加拿大不可申报超过20美金!!!','success'=>false));exit;
  1221. }
  1222. if($post['printtype'] == 1)//如果是运单
  1223. {
  1224. $post['productdescription'] = $this->input->post('productdescription',true);
  1225. $post['customs'] = $this->input->post('customs',true);
  1226. }
  1227. if($post['express'] == 2 && strlen($post['zipcode']) != 5)//如果usps 邮编不是5位
  1228. {
  1229. echo json_encode(array('msg'=>'USPS-USA的邮编需按5位数格式提交!','success'=>false));exit;
  1230. }
  1231. if(strlen($post['phone']) > 11 && $post['express'] == 63)
  1232. {
  1233. echo json_encode(array('msg'=>'美国联邦,电话号码不允许超过11位!','success'=>false));exit;
  1234. }
  1235. /**
  1236. if($post['paypal'] != '')
  1237. {
  1238. $pp = $this->fullorder->get_paypal($post['paypal']);
  1239. if(isset($pp['number']) && $pp['number'] != $data['number'])
  1240. {
  1241. echo json_encode(array('msg'=>'此交易号的订单已存在!-'.$pp['number'],'success'=>false));exit;
  1242. }
  1243. }
  1244. **/
  1245. /**
  1246. if($editstate == 216 && $data['state'] != 216)
  1247. {
  1248. echo json_encode(array('msg'=>'不可修改为完成状态','success'=>false));exit;
  1249. }
  1250. **/
  1251. $post['review'] = $data['review'];
  1252. $post['state'] = $editstate;
  1253. if($editstate == 216)
  1254. {
  1255. foreach ($post as $k=>$v)
  1256. {
  1257. if($k == 'shipremarks' || $k == 'whlabel' || $k == 'fpdata' || $k == 'fpcount' || $k == 'refundy' || $k == 'refundj' || $k == 'rtime' || $k == 'rpaypal' || $k == 'rtext' || $k == 'freight' || $k == 'expressmoney' || $k == 'edittime' || $k == 'librarynot' || $k == 'state' || $k == 'jweight' || $k == 'productdescription')
  1258. {
  1259. continue;
  1260. }
  1261. else
  1262. {
  1263. //当时不知道为会把 当前不可修改订单信息 给注释掉 但是 如果注释掉 这个判断就没意义了 还引起了报错 我这里就注释掉了
  1264. // if($v != $data[$k])
  1265. // {
  1266. // //echo json_encode(array('msg'=>'当前不可修改订单信息','cs'=>$k,'success'=>false));exit;
  1267. // }
  1268. }
  1269. }
  1270. }
  1271. /**
  1272. if($editstate == 216 && $post['waybill'] != '' && $data['waybill'] != '')//if($editstate == 216 && preg_match('/\d/is',$post['waybill']) != true)
  1273. {
  1274. echo json_encode(array('msg'=>'当前信息不可修改订单状态','success'=>false));exit;
  1275. }
  1276. else
  1277. {
  1278. $post['review'] = $data['review'];
  1279. $post['state'] = $editstate;
  1280. }
  1281. **/
  1282. $thisdata = $this->fullorder->read($id);
  1283. $warehouse = $this->warehouse->read($thisdata['type']);
  1284. $warehousenew = $this->warehouse->read($post['type']);
  1285. if($warehousenew['bdcountry'] != 0 && $post['country'] != $warehousenew['bdcountry'])
  1286. {
  1287. echo json_encode(array('msg'=>'当前国家无法选择'.$warehousenew['title'].'!','success'=>false));exit;
  1288. }
  1289. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  1290. {
  1291. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  1292. }
  1293. $expt = $this->express->read($post['express']);
  1294. if($expt['pt'] != '' && stripos($post['fpdata'],$expt['pt']) !== false)
  1295. {
  1296. echo json_encode(array('msg'=>$expt['ptts'],'success'=>false));exit;
  1297. }
  1298. if($expt['province'] != '' && stripos($expt['province'],$post['province'].'、') !== false)
  1299. {
  1300. echo json_encode(array('msg'=>'此省/州不可使用 '.$expt['servicename'],'success'=>false));exit;
  1301. }
  1302. /**
  1303. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  1304. {
  1305. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  1306. }
  1307. **/
  1308. //开始注释 xyxg
  1309. /**
  1310. $ft = array();
  1311. $ftdata = explode('|',rtrim($fpcount,'|'));
  1312. foreach ($ftdata as $va)
  1313. {
  1314. $ftitle = '';
  1315. $va = explode('-',trim($va,'-'));
  1316. foreach ($va as $v)
  1317. {
  1318. $v = $this->typeclass->read($v);
  1319. $ftitle .= $v['title'].' ';
  1320. }
  1321. $ft[] = rtrim($ftitle,' ');
  1322. }
  1323. if($data['library'] == 1)
  1324. {
  1325. $tqkcyz = $this->_kcyz($post['type'],$whlabel,$id,$data['shop'],$data['number']);
  1326. if(isset($tqkcyz[0]))
  1327. {
  1328. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$tqkcyz,'success'=>false));exit;
  1329. }
  1330. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  1331. {
  1332. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  1333. if($tskcyz['t'] > '0')
  1334. {
  1335. echo $tskcyz['m'];exit;
  1336. }
  1337. }
  1338. $kcyz = $this->whlabel->get_kc($thisdata['state'],$post['state'],$warehousenew['zd'],$warehousenew['ys'],$post['type'],$whlabel,$fpcount,$ft,$thisdata['number'],$thisdata['shop'],$thisdata['type'],$thisdata['whlabel']);//旧状态、新状态、仓库占单设置、仓库预设设置、新仓库、新产品简化数字、旧产品数字、旧产品名称、订单号、订单店铺、旧订单仓库、旧产品简化数字
  1339. if($kcyz['t'] > '0')
  1340. {
  1341. echo $kcyz['m'];exit;
  1342. }
  1343. }
  1344. //结束注释
  1345. **/
  1346. /** 重新写产品名称
  1347. $dtctitle = array();
  1348. $dictionaries = $this->typeclass->find_all();
  1349. foreach ($dictionaries as $v)
  1350. {
  1351. $dtctitle[$v['id']] = array($v['title'],$v['bqsku']);
  1352. }
  1353. if(stripos($fpdata,'-128-') !== false || stripos($fpdata,'-127-') !== false)
  1354. {
  1355. $dfp = explode(';',trim($fpdata,';'));
  1356. $fdata = '';
  1357. foreach ($dfp as $k=>$v)
  1358. {
  1359. $ptitleb = '';
  1360. $fp = explode('|',trim($v,'|'));
  1361. $fp0 = explode(',',$fp[0]);
  1362. $fp1 = explode('-',trim($fp0[1],'-'));
  1363. foreach ($fp1 as $vv)
  1364. {
  1365. $ptitleb .= isset($dtctitle[$vv])?$dtctitle[$vv][0].' ':'';
  1366. }
  1367. $ptitleb .= $dtctitle[$fp0[0]][1].'inch ';
  1368. $fp[1] = $ptitleb;
  1369. $fdata .= implode("|",$fp).";";
  1370. }
  1371. $fpdata = $fdata;
  1372. }
  1373. **/
  1374. $warehouse = $this->warehouse->read($post['type']);
  1375. //未出库或者(已退库并且订单的状态不是等待买家收货和代发货状态)
  1376. if($data['library'] == 1 || ($data['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  1377. {
  1378. // echo "<pre>";
  1379. // var_dump($post['state']);
  1380. // var_dump($warehouse);
  1381. // var_dump($thisdata['shop']);
  1382. // var_dump($thisdata['number']);
  1383. // var_dump($whlabel);
  1384. // var_dump($fpdata);
  1385. // die;
  1386. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  1387. if($kcyz['t'] > '0')
  1388. {
  1389. echo $kcyz['m'];exit;
  1390. }
  1391. else if($kcyz['fpdata'] != '')
  1392. {
  1393. $post['whlabel'] = $kcyz['whlabel'];
  1394. $post['fpdata'] = $kcyz['fpdata'];
  1395. }
  1396. }
  1397. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  1398. $post['sfxh'] = $fl['sfxh'];
  1399. $post['ckfl'] = $fl['ckfl'];
  1400. //查询净重开始
  1401. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  1402. unset($post[0]);
  1403. //查询净重结束
  1404. if($this->fullorder->save($post,$id))
  1405. {
  1406. if($data['printtime'] == '0')
  1407. {
  1408. $xghz = ',将自动禁止打印';
  1409. }
  1410. else if($data['printtime'] > '0' && $data['librarytime'] == '0')
  1411. {
  1412. $q = '';
  1413. if($data['libraryconfirm'] == 1)
  1414. {
  1415. $q = ',<em style="color: #F00;">改前状态为:禁止出库</em>';
  1416. }
  1417. $xghz = ',将自动禁止发货'.$q;
  1418. }
  1419. else
  1420. {
  1421. $xghz = '';
  1422. }
  1423. echo json_encode(array('msg'=>'修改成功'.$xghz,'id'=>$id,'success'=>true));exit;
  1424. }
  1425. else
  1426. {
  1427. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  1428. }
  1429. }
  1430. $this->data['vip'] = $vip;
  1431. $arg_array = $arg_array[0];$fpdata = array();
  1432. $fullorder = $this->fullorder->read($arg_array);
  1433. $returngoods = $this->returngoods->get_orderinfo($fullorder['orderinfo']);
  1434. $this->data['returngoods'] = 0;
  1435. if(!empty($returngoods)){
  1436. if($returngoods['status'] != 120){
  1437. $this->data['returngoods'] = 1;
  1438. }
  1439. }
  1440. $fullorder['parameter'] = str_replace(",","---",$fullorder['parameter']);
  1441. $country = $this->country->find_all('1=1','id,name','name asc');//所有国家信息
  1442. $express = $this->express->find_all('1=1');//所有快递配置信息
  1443. $this->data['fullorder'] = $fullorder;
  1444. if($fullorder['express'] == 2)
  1445. {
  1446. $zzhl = 'oz';
  1447. }
  1448. else
  1449. {
  1450. $zzhl = 'kg';
  1451. }
  1452. $this->data['zzhl'] = $zzhl;
  1453. $this->data['country'] = $country;
  1454. $this->data['express'] = $express;
  1455. $this->data['dtime'] = date('Y-m-d H:i:s',$fullorder['dtime']);
  1456. $warehouse = $this->warehouse->read($fullorder['type']);
  1457. if(stripos($fullorder['fpdata'],';') !== false)
  1458. {
  1459. $fpdata = explode(';',rtrim($fullorder['fpdata'],';'));
  1460. foreach ($fpdata as $k=>$v)
  1461. {
  1462. $xxv = explode('|',$v);
  1463. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  1464. {
  1465. $xxv['zd'] = "<p>已占单</p>";
  1466. $bdck = $warehouse['bdck'];
  1467. if(stripos($xxv[9],'~') !== false)
  1468. {
  1469. $dxxv = explode('~',trim($xxv[9],'~'));
  1470. foreach ($dxxv as $val)
  1471. {
  1472. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  1473. if($wzid['details'] != '')
  1474. {
  1475. if($fullorder['type'] == 5){
  1476. $xxv['zd'] .= '<p>位置:'.$wzid['details'].'</p>';
  1477. }else{
  1478. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1479. }
  1480. }
  1481. }
  1482. }
  1483. else
  1484. {
  1485. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  1486. if($wzid['details'] != '')
  1487. {
  1488. if($fullorder['type'] == 5){
  1489. $xxv['zd'] .= '<p>位置:'.$wzid['details'].'</p>';
  1490. }else{
  1491. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1492. }
  1493. }
  1494. }
  1495. }
  1496. $fpdata[$k] = $xxv;
  1497. }
  1498. }
  1499. $fpdata = $this->logic_order->checkOrderProduct($fpdata);
  1500. // $tmp_features = array_column($fpdata,0);
  1501. // $do_trans_pms = [];
  1502. // foreach ($tmp_features as $k=>$v) {
  1503. // if(strpos($v,",") === false){
  1504. // $do_trans_pms[] = [
  1505. // 'features'=>$v
  1506. // ];
  1507. // }else{
  1508. // $tmp_arr = explode(",",$v);
  1509. // $do_trans_pms[] = [
  1510. // 'features'=>$tmp_arr[1].$tmp_arr[0]."-"
  1511. // ];
  1512. // }
  1513. // }
  1514. // $r = $this->logic_whlabel->dataTran($do_trans_pms,['pm']);
  1515. // foreach ($fpdata as $k=>$v) {
  1516. // $fpdata[$k]['pm'] = $r[$k]['pm'];
  1517. // }
  1518. $this->data['fpdata'] = $fpdata;
  1519. $thfpdataxs = array();
  1520. if($fullorder['thfpdata'] != '')
  1521. {
  1522. $thfpdata = explode(';',trim($fullorder['thfpdata'],';'));
  1523. foreach ($thfpdata as $k=>$v)
  1524. {
  1525. $thxs = explode('~',trim($v,'~'));
  1526. $thxs[0] = explode('|',trim($thxs[0],'|'));
  1527. $thxs[1] = explode('|',trim($thxs[1],'|'));
  1528. $thfpdataxs[] = array("<p>".$thxs[0][1]."<i class='fa fa-level-down'></i></p><p>".$thxs[1][1]."</p>","<p>".$thxs[0][2]."</p><p>".$thxs[1][2]."</p>","<p>旧</p><p>新</p>",$thxs[1][0]);
  1529. }
  1530. }
  1531. $this->data['thfpdata'] = $thfpdataxs;
  1532. $shop = $this->shop->read($fullorder['shop']);
  1533. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  1534. $is = 0;
  1535. if($shop['type'] == 269 || $shop['type'] == 2768)//判断是否独立站,269是独立站
  1536. {
  1537. $is = 1;
  1538. }
  1539. $this->data['is'] = $is;
  1540. if(isset($_SESSION['api']))
  1541. {
  1542. $user = $this->user->get_api($_SESSION['api']);
  1543. if($user['vip'] == 1)
  1544. {
  1545. $vip = 1;
  1546. }
  1547. else
  1548. {
  1549. $vip = 0;
  1550. }
  1551. }
  1552. else
  1553. {
  1554. $vip = 0;
  1555. }
  1556. $this->data['power'] = $vip;
  1557. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  1558. $downwaybill = '';$dwls = array();
  1559. $oldwaybill = explode('-',ltrim($fullorder['oldwaybill'],'-'));
  1560. if(isset($oldwaybill[0][1]))
  1561. {
  1562. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  1563. foreach ($oldwaybill as $v)
  1564. {
  1565. $dw = explode('/',$v);
  1566. if(isset($dw[1]))
  1567. {
  1568. if(stripos($downwaybill,$dw[1]) === false)
  1569. {
  1570. $dwls[$dw[1]] = 1;
  1571. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  1572. }
  1573. }
  1574. }
  1575. }
  1576. if($fullorder['printtype'] == 1)
  1577. {
  1578. if($fullorder['waybill'] != '' && !isset($dwls[$fullorder['waybill']]))
  1579. {
  1580. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullorder['printtime']).'/y-'.$fullorder['waybill'].'.pdf" target="_blank">'.$fullorder['waybill'].'</a>、'.$downwaybill;
  1581. }
  1582. }
  1583. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  1584. /** 历史打印时间 **/
  1585. $printtime = '';
  1586. if($fullorder['oldprinttime'])
  1587. {
  1588. $pte = explode('-',rtrim($fullorder['oldprinttime'],'-'));
  1589. foreach ($pte as $v)
  1590. {
  1591. if(!empty($v)){
  1592. $printtime .= date('Y-m-d H:i:s',$v).'、';
  1593. }
  1594. }
  1595. }
  1596. $this->data['printtime'] = rtrim($printtime,'、');
  1597. $product = '';
  1598. $fullorder['product'] = str_replace("'","",$fullorder['product']);
  1599. if($fullorder['link'] != '' && $fullorder['source'] != '1')
  1600. {
  1601. $pt = explode(',',$fullorder['product']);
  1602. $lk = explode(',',$fullorder['link']);
  1603. for($i=0;$i<count($pt);$i++)
  1604. {
  1605. if(isset($lk[$i]))
  1606. {
  1607. $octs = $this->colourorderts->get_texturl($pt[$i],$lk[$i]);
  1608. }
  1609. else
  1610. {
  1611. $octs = '';
  1612. }
  1613. $a = $octs?'<font style="color:#'.$octs['colour'].'">'.$pt[$i].'</font>':$pt[$i];
  1614. //$a = (stripos($pt[$i],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($pt[$i],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($pt[$i],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($pt[$i],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($pt[$i],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($pt[$i],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($pt[$i],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($pt[$i],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($pt[$i],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$pt[$i].'</font>':$pt[$i];
  1615. if(isset($lk[$i]))
  1616. {
  1617. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  1618. }
  1619. else
  1620. {
  1621. $product .= ($product != '')?' , '.$a:$a;
  1622. }
  1623. }
  1624. }
  1625. else
  1626. {
  1627. $octs = $this->colourorderts->get_text($fullorder['product']);
  1628. $a = $octs?'<font style="color:#F39">'.$fullorder['product'].'</font>':$fullorder['product'];
  1629. //$a = (stripos($fullorder['product'],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($fullorder['product'],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($fullorder['product'],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($fullorder['product'],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($fullorder['product'],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($fullorder['product'],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($fullorder['product'],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($fullorder['product'],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($fullorder['product'],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$fullorder['product'].'</font>':$fullorder['product'];
  1630. $product = $a;
  1631. }
  1632. $this->data['product'] = $product;
  1633. $out = $this->systemtransfer->find_all("number = '".$fullorder['number']."'");
  1634. $outread = '';
  1635. if($out)
  1636. {
  1637. foreach ($out as $val)
  1638. {
  1639. $list = '';
  1640. $rk = explode('|',trim($val['rk'],'|'));
  1641. $rktime = explode('|',trim($val['rktime'],'|'));
  1642. $zw = array();
  1643. $t = $this->transfer->find_all("1=1");
  1644. foreach ($t as $v)
  1645. {
  1646. $zw[$v['id']] = $v['title'];
  1647. }
  1648. if($val['rk'] != '' && count($rk) > 0)
  1649. {
  1650. for($i=0;$i<count($rk);$i++)
  1651. {
  1652. if(!isset($rktime[$i]))
  1653. {
  1654. if(isset($cz[$i]))
  1655. {
  1656. $list .= $zw[$cz[$i]];
  1657. }
  1658. }
  1659. else
  1660. {
  1661. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  1662. }
  1663. }
  1664. }
  1665. $outread .= '<span style="color:#f00">'.$val['shipremarks'].'</span>:'.$list.'<br>';
  1666. //$outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  1667. }
  1668. }
  1669. else
  1670. {
  1671. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullorder['number']."'");
  1672. $outread = array();
  1673. if($systemwigsout)
  1674. {
  1675. foreach ($systemwigsout as $v)
  1676. {
  1677. if($v['czwarehouse'] == 37)
  1678. {
  1679. $outread[] = '华荣厂';
  1680. }
  1681. else if($v['czwarehouse'] == 0)
  1682. {
  1683. $outread[] = '龙盈厂';
  1684. }
  1685. $cz = explode('|',trim($v['cz'],'|'));
  1686. $cztime = explode('|',trim($v['cztime'],'|'));
  1687. $zw = $this->transfer->get_list();
  1688. if($v['cz'] != '' && count($cz) > 0)
  1689. {
  1690. for($i=0;$i<count($cz);$i++)
  1691. {
  1692. if(!isset($cztime[$i]))
  1693. {
  1694. $outread[] = $zw[$cz[$i]].' -&gt; ';
  1695. }
  1696. else
  1697. {
  1698. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  1699. }
  1700. }
  1701. $outread[] = '<br>';
  1702. }
  1703. }
  1704. }
  1705. }
  1706. $klarnacolor = '';
  1707. if($fullorder['klarnadata'] !='')
  1708. {
  1709. $klarnadata = explode('|',$fullorder['klarnadata']);
  1710. if($klarnadata[0] == 'paypal' || $klarnadata[0] == 'stripe')
  1711. {
  1712. $klarnadata[1] = json_decode($klarnadata[1],true);
  1713. if($klarnadata[0] == 'stripe' && $klarnadata[1]['shouldmoney'] != $fullorder['shouldmoney'] && $fullorder['pay'] == 1211)
  1714. {
  1715. $klarnacolor = 'style="color:#F00"';
  1716. }
  1717. }
  1718. else if($klarnadata[0]!=1 && $fullorder['pay']!=26 && $fullorder['pay']!=27 && $fullorder['pay']!=1211)
  1719. {
  1720. $klarnacolor = 'style="color:#F00"';
  1721. }
  1722. if($fullorder['pay'] == 23)//klarna
  1723. {
  1724. $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','guam'=>'GU','puerto rico'=>'PR');
  1725. $ToState = array_flip($ToState);
  1726. $klarnadata3 = str_replace(' ','',$klarnadata[3]);
  1727. $city = str_replace(' ','',$fullorder['city']);
  1728. $klarnadataaddress = explode($city,$klarnadata3);
  1729. if(isset($klarnadataaddress[1]))
  1730. {
  1731. $klarnadata3 = $city.$klarnadataaddress[1];
  1732. $klarnadatacolor = explode(',',$klarnadata3);
  1733. unset($klarnadatacolor[4]);
  1734. unset($klarnadatacolor[6]);
  1735. if(isset($ToState[$klarnadatacolor[1]]))
  1736. {
  1737. $klarnadatacolor[1] = ucwords($ToState[$klarnadatacolor[1]]);
  1738. }
  1739. $klarnadata['color'] = $klarnadataaddress[0].implode(",",$klarnadatacolor);
  1740. }
  1741. else
  1742. {
  1743. $klarnadata['color'] = $klarnadata3;
  1744. }
  1745. }
  1746. }
  1747. else
  1748. {
  1749. $klarnadata = '';
  1750. }
  1751. $p = explode('-',$fullorder['paypal']);
  1752. $this->data['klarnacolor'] = $klarnacolor;
  1753. $this->data['klarnadata'] = $klarnadata;
  1754. $this->data['systemwigsout'] = $outread;
  1755. $quantity = explode(';',trim($fullorder['quantity'],';'));
  1756. $qc = 0;
  1757. foreach ($quantity as $v)
  1758. {
  1759. if($v > 1)
  1760. {
  1761. $qc += 1;
  1762. }
  1763. }
  1764. $this->data['qc'] = $qc;
  1765. //新增row_total和sub_total
  1766. $product_ids = $row_total = $sub_total = "";
  1767. if(!empty($fullorder['extra_price'])){
  1768. $extra_price = json_decode($fullorder['extra_price'],true);
  1769. foreach($extra_price as $k=>$v){
  1770. $row_total .= sprintf("%.2f",($v['qty']* $v['price'])).";";
  1771. $sub_total .= sprintf("%.2f",$v['sub_total']).";";
  1772. if(!empty($v['product_id'])){
  1773. $product_ids .= $v['product_id'].";";
  1774. }
  1775. }
  1776. }
  1777. $this->data['row_total'] = trim($row_total,";");
  1778. $this->data['sub_total'] = trim($sub_total,";");
  1779. $this->data['product_ids'] = trim($product_ids,";");
  1780. $this->_Template('fullorder_edit',$this->data);
  1781. }
  1782. //不可修改
  1783. public function _readonly($arg_array)
  1784. {
  1785. $post = $this->input->post(NULL, TRUE);
  1786. if(isset($post['id']))
  1787. {
  1788. $id = $this->input->post('id',true);
  1789. $ud = $this->fullorder->read($id);
  1790. $post['type'] = $this->input->post('warehouse',true);
  1791. $post['orderremarks'] = $this->input->post('orderremarks',true);
  1792. $post['state'] = $this->input->post('state',true);
  1793. $post['msg'] = $this->input->post('msg',true);
  1794. $post['refundy'] = $this->input->post('refundy',true);
  1795. $post['refundj'] = $this->input->post('refundj',true);
  1796. $fpdata = $this->input->post('fpdata');
  1797. $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
  1798. $post['fpdata'] = $fpdata;
  1799. $rtime = $this->input->post('rtime',true);
  1800. $post['rtime'] = strtotime($rtime);
  1801. $post['rpaypal'] = $this->input->post('rpaypal',true);
  1802. $post['rtext'] = $this->input->post('rtext',true);
  1803. $post['express'] = $this->input->post('express',true);
  1804. $whlabel = $this->input->post('whlabel',true);
  1805. //$post['ioss'] = $this->input->post('ioss',true);
  1806. $post['edittime'] = time();
  1807. $editstate = $post['state'];
  1808. if(!$editstate)
  1809. {
  1810. $editstate = $ud['state'];
  1811. $post['state'] = $editstate;
  1812. }
  1813. /**
  1814. if($post['state'] == 216 && $ud['state'] != 216)
  1815. {
  1816. echo json_encode(array('msg'=>'不可修改为完成状态','success'=>false));exit;
  1817. }
  1818. **/
  1819. $whlabeldata = explode('|',trim($whlabel,'|'));$way = 0;
  1820. foreach ($whlabeldata as $va)
  1821. {
  1822. if(stripos($va,'z') !== false)
  1823. {
  1824. $way += 1;
  1825. }
  1826. }
  1827. if((($post['express'] == 2 || $post['express'] == 63 || $post['express'] == 64 || $post['express'] == 81) && $post['type'] != 5) || ($post['express'] != 2 && $post['express'] != 63 && $post['express'] != 64 && $post['express'] != 81 && $post['type'] == 5))
  1828. {
  1829. echo json_encode(array('msg'=>'此快递方式必须选择美仓!','success'=>false));exit;
  1830. }
  1831. if($way == count($whlabeldata) && $post['type'] != 12)
  1832. {
  1833. echo json_encode(array('msg'=>'必须选择特殊仓!','success'=>false));exit;
  1834. }
  1835. if($way == '0' && $post['type'] == 12)
  1836. {
  1837. echo json_encode(array('msg'=>'特殊仓必须包含特殊仓货物!','success'=>false));exit;
  1838. }
  1839. $fpcount = $this->input->post('fpcount',true);
  1840. if(!$fpcount)
  1841. {
  1842. echo json_encode(array('msg'=>'需要先清理浏览器缓存,刷新当前页面后再试!','success'=>false));exit;
  1843. }
  1844. if($ud['library'] == 1)
  1845. {
  1846. if($ud['print'] != 3)
  1847. {
  1848. $post['print'] = 1;
  1849. $post['libraryconfirm'] = 1;
  1850. $post['librarynot'] = "订单未打印,未审核或未通过";
  1851. }
  1852. else
  1853. {
  1854. $post['libraryconfirm'] = 1;
  1855. $post['librarynot'] = "订单被重新提交";
  1856. }
  1857. }
  1858. if(($post['express'] == '5' || $post['express'] == '24' || $post['express'] == '42' || $post['express'] == '31') && $ud['country'] != 192)
  1859. {
  1860. echo json_encode(array('msg'=>'非美国无法选择Fedex、DHL官方-美国!','success'=>false));exit;
  1861. }
  1862. if($post['express'] == '3' && $ud['country'] != 192 && $ud['country'] != 35)
  1863. {
  1864. echo json_encode(array('msg'=>'非美国和加拿大无法选择UPS!','success'=>false));exit;
  1865. }
  1866. if(($post['express'] == '28' || $post['express'] == '7') && $ud['country'] != 191)
  1867. {
  1868. echo json_encode(array('msg'=>'非英国无法选择CNE和GES!','success'=>false));exit;
  1869. }
  1870. $express = $this->express->read($post['express']);
  1871. /**
  1872. if($express['ioss'] == 1 && $post['ioss'] == '')
  1873. {
  1874. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  1875. }
  1876. **/
  1877. $thisdata = $this->fullorder->read($id);
  1878. $warehouse = $this->warehouse->read($thisdata['type']);
  1879. $warehousenew = $this->warehouse->read($post['type']);
  1880. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  1881. {
  1882. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  1883. }
  1884. if($ud['yhs'] == 1)
  1885. {
  1886. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  1887. }
  1888. $expt = $this->express->read($post['express']);
  1889. if($expt['pt'] != '' && stripos($post['fpdata'],$expt['pt']) !== false)
  1890. {
  1891. echo json_encode(array('msg'=>$expt['ptts'],'success'=>false));exit;
  1892. }
  1893. if($expt['province'] != '' && stripos($expt['province'],$ud['province'].'、') !== false)
  1894. {
  1895. echo json_encode(array('msg'=>'此省/州不可使用 '.$expt['servicename'],'success'=>false));exit;
  1896. }
  1897. if($post['type'] != 5 && in_array($post['express'],[2,63,64,81]))
  1898. {
  1899. echo json_encode(array('msg'=>"此快递方式必须从美仓发货!",'success'=>false));exit;
  1900. }
  1901. if($post['type'] == 5 && !in_array($post['express'],[2,63,64,81]))
  1902. {
  1903. echo json_encode(array('msg'=>"此快递方式不能美仓发货!",'success'=>false));exit;
  1904. }
  1905. /**
  1906. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  1907. {
  1908. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  1909. }
  1910. **/
  1911. /**
  1912. if($warehousenew['zd'] == '1' && $editstate != $thisdata['state'] && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  1913. {
  1914. echo json_encode(array('msg'=>'如需更改订单状态,请先把仓库选择为非开启库存模式仓库或等待订单出库!','success'=>false));exit;
  1915. }
  1916. if($warehousenew['zd'] == '1' && $editstate != '207' && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  1917. {
  1918. echo json_encode(array('msg'=>'非待发货状态,不允许修改为开启库存模式仓库','success'=>false));exit;
  1919. }
  1920. **/
  1921. //开始注释 xyxg
  1922. /**
  1923. $ft = array();
  1924. $ftdata = explode('|',rtrim($fpcount,'|'));
  1925. foreach ($ftdata as $va)
  1926. {
  1927. $ftitle = '';
  1928. $va = explode('-',trim($va,'-'));
  1929. foreach ($va as $v)
  1930. {
  1931. $v = $this->typeclass->read($v);
  1932. $ftitle .= $v['title'].' ';
  1933. }
  1934. $ft[] = rtrim($ftitle,' ');
  1935. }
  1936. $user = $this->user->get_api($_SESSION['api']);
  1937. if($ud['library'] == 1)
  1938. {
  1939. $tqkcyz = $this->_kcyz($post['type'],$whlabel,$id,$ud['shop'],$ud['number']);
  1940. if(isset($tqkcyz[0]))
  1941. {
  1942. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$tqkcyz,'success'=>false));exit;
  1943. }
  1944. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  1945. {
  1946. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  1947. if($tskcyz['t'] > '0')
  1948. {
  1949. echo $tskcyz['m'];exit;
  1950. }
  1951. }
  1952. $kcyz = $this->whlabel->get_kc($thisdata['state'],$post['state'],$warehousenew['zd'],$warehousenew['ys'],$post['type'],$whlabel,$fpcount,$ft,$thisdata['number'],$thisdata['shop'],$thisdata['type'],$thisdata['whlabel']);//旧状态、新状态、仓库占单设置、仓库预设设置、新仓库、新产品简化数字、旧产品数字、旧产品名称、订单号、订单店铺、旧订单仓库、旧产品简化数字
  1953. if($kcyz['t'] > '0')
  1954. {
  1955. echo $kcyz['m'];exit;
  1956. }
  1957. }
  1958. //结束注释
  1959. **/
  1960. // $post['fpdata'] = preg_replace('/\s+/', '', $post['fpdata']);str_replace(" ", "", ); // 去除所有空格
  1961. // $post['fpdata'] = str_replace(array("\r", "\n"), "", $post['fpdata']);
  1962. // $ud['fpdata'] = str_replace(" ", "", $ud['fpdata']); // 去除所有空格
  1963. // $ud['fpdata'] = str_replace(array("\r", "\n"), "", $ud['fpdata']);
  1964. if($ud['estimaterate'] == 1){
  1965. $post['budget'] = $ud['shouldmoney'];
  1966. }
  1967. if($ud['state'] == 216 && $post['whlabel'] != $ud['whlabel'])
  1968. {
  1969. echo json_encode(array('msg'=>'商品信息需要找梦体修改','success'=>false));exit;
  1970. }
  1971. $warehouse = $this->warehouse->read($post['type']);
  1972. if($ud['library'] == 1 || ($ud['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  1973. {
  1974. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  1975. if($kcyz['t'] > '0')
  1976. {
  1977. echo $kcyz['m'];exit;
  1978. }
  1979. else if($kcyz['fpdata'] != '')
  1980. {
  1981. $post['whlabel'] = $kcyz['whlabel'];
  1982. $post['fpdata'] = $kcyz['fpdata'];
  1983. }
  1984. }
  1985. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  1986. $post['sfxh'] = $fl['sfxh'];
  1987. $post['ckfl'] = $fl['ckfl'];
  1988. //查询净重开始
  1989. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  1990. //查询净重结束
  1991. if($this->fullorder->save($post,$id))
  1992. {
  1993. if($ud['printtime'] == '0')
  1994. {
  1995. $xghz = ',将自动禁止打印';
  1996. }
  1997. else if($ud['printtime'] > '0' && $ud['librarytime'] == '0')
  1998. {
  1999. $q = '';
  2000. if($ud['libraryconfirm'] == 1)
  2001. {
  2002. $q = ',<em style="color: #F00;">改前状态为:禁止出库</em>';
  2003. }
  2004. $xghz = ',将自动禁止发货'.$q;
  2005. }
  2006. else
  2007. {
  2008. $xghz = '';
  2009. }
  2010. echo json_encode(array('msg'=>'修改成功'.$xghz,'id'=>$id,'cs'=>$ud['state'].' - '.$post['fpdata'].' - '.$ud['fpdata'],'success'=>true));exit;
  2011. }
  2012. else
  2013. {
  2014. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  2015. }
  2016. }
  2017. $arg_array = $arg_array[0];$fpdata = array();
  2018. $fullorder = $this->fullorder->read($arg_array);
  2019. $returngoods = $this->returngoods->get_orderinfo($fullorder['orderinfo']);
  2020. $this->data['returngoods'] = $returngoods?1:0;
  2021. $fullorder['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$fullorder['shipremarks']);
  2022. $fullorder['parameter'] = str_replace(",","---",$fullorder['parameter']);
  2023. $this->data['fullorder'] = $fullorder;
  2024. if($fullorder['express'] == 2)
  2025. {
  2026. $zzhl = 'oz';
  2027. }
  2028. else
  2029. {
  2030. $zzhl = 'kg';
  2031. }
  2032. $this->data['zzhl'] = $zzhl;
  2033. $this->data['countrys'] = $this->country->find_all();
  2034. $this->data['express'] = $this->express->find_all();
  2035. $warehouse = $this->warehouse->read($fullorder['type']);
  2036. if(stripos($fullorder['fpdata'],';') !== false)
  2037. {
  2038. $fpdata = explode(';',rtrim($fullorder['fpdata'],';'));
  2039. foreach ($fpdata as $k=>$v)
  2040. {
  2041. $xxv = explode('|',$v);
  2042. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  2043. {
  2044. $xxv['zd'] = "<p>已占单</p>";
  2045. $bdck = $warehouse['bdck'];
  2046. if(stripos($xxv[9],'~') !== false)
  2047. {
  2048. $dxxv = explode('~',trim($xxv[9],'~'));
  2049. foreach ($dxxv as $val)
  2050. {
  2051. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  2052. if($wzid['details'] != '')
  2053. {
  2054. if($fullorder['type'] == 5){
  2055. $xxv['zd'] .= '<p>位置:'.$wzid['details'].'</p>';
  2056. }else{
  2057. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  2058. }
  2059. }
  2060. }
  2061. }
  2062. else
  2063. {
  2064. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  2065. if($wzid['details'] != '')
  2066. {
  2067. if($fullorder['type'] == 5){
  2068. $xxv['zd'] .= '<p>位置:'.$wzid['details'].'</p>';
  2069. }else{
  2070. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  2071. }
  2072. }
  2073. }
  2074. }
  2075. $fpdata[$k] = $xxv;
  2076. }
  2077. }
  2078. $this->data['fpdata'] = $fpdata;
  2079. // $tmp_features = array_column($fpdata,0);
  2080. // $do_trans_pms = [];
  2081. // foreach ($tmp_features as $k=>$v) {
  2082. // if(strpos($v,",") === false){
  2083. // $do_trans_pms[] = [
  2084. // 'features'=>$v
  2085. // ];
  2086. // }else{
  2087. // $tmp_arr = explode(",",$v);
  2088. // $do_trans_pms[] = [
  2089. // 'features'=>$tmp_arr[1].$tmp_arr[0]."-"
  2090. // ];
  2091. // }
  2092. // }
  2093. // $r = $this->logic_whlabel->dataTran($do_trans_pms,['pm']);
  2094. // foreach ($fpdata as $k=>$v) {
  2095. // $fpdata[$k]['pm'] = $r[$k]['pm'];
  2096. // }
  2097. $this->data['fpdata'] = $fpdata;
  2098. $thfpdataxs = array();
  2099. if($fullorder['thfpdata'] != '')
  2100. {
  2101. $thfpdata = explode(';',trim($fullorder['thfpdata'],';'));
  2102. foreach ($thfpdata as $k=>$v)
  2103. {
  2104. $thxs = explode('~',trim($v,'~'));
  2105. $thxs[0] = explode('|',trim($thxs[0],'|'));
  2106. $thxs[1] = explode('|',trim($thxs[1],'|'));
  2107. $thfpdataxs[] = array("<p>".$thxs[0][1]."<i class='fa fa-level-down'></i></p><p>".$thxs[1][1]."</p>","<p>".$thxs[0][2]."</p><p>".$thxs[1][2]."</p>","<p>旧</p><p>新</p>",$thxs[1][0]);
  2108. }
  2109. }
  2110. $this->data['thfpdata'] = $thfpdataxs;
  2111. $shop = $this->shop->read($fullorder['shop']);
  2112. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  2113. $is = 0;
  2114. if($shop['type'] == 269 || $shop['type']==2768 )//判断是否独立站,269是独立站
  2115. {
  2116. $is = 1;
  2117. }
  2118. $this->data['is'] = $is;
  2119. //单项开始
  2120. $warehouse = $this->warehouse->read($fullorder['warehouse']);//发货仓库
  2121. $state = $this->typeclass->read($fullorder['state']);//订单状态
  2122. $country = $this->country->read($fullorder['country']);//国家
  2123. if($fullorder['capital'] == 1)
  2124. {
  2125. $capital = '暂未支付';
  2126. }
  2127. else if($fullorder['capital'] == 2)
  2128. {
  2129. $capital = '部分支付';
  2130. }
  2131. else if($fullorder['capital'] == 3)
  2132. {
  2133. $capital = '全部支付';
  2134. }
  2135. if($fullorder['printtype'] == 1)
  2136. {
  2137. $printtype = '运单';
  2138. }
  2139. else if($fullorder['printtype'] == 2)
  2140. {
  2141. $printtype = '发货单';
  2142. }
  2143. else if($fullorder['printtype'] == 3)
  2144. {
  2145. $printtype = '不打印单据';
  2146. }
  2147. else
  2148. {
  2149. $printtype = '未选择';
  2150. }
  2151. $this->data['warehouse'] = $warehouse['title'];
  2152. $this->data['state'] = $state['title'];
  2153. $this->data['capital'] = $capital;
  2154. $this->data['country'] = $country['name'];
  2155. $this->data['printtype'] = $printtype;
  2156. //单项结束
  2157. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  2158. $downwaybill = '';$dwls = array();
  2159. $oldwaybill = explode('-',ltrim($fullorder['oldwaybill'],'-'));
  2160. if(isset($oldwaybill[0][1]))
  2161. {
  2162. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  2163. foreach ($oldwaybill as $v)
  2164. {
  2165. $dw = explode('/',$v);
  2166. if(isset($dw[1]))
  2167. {
  2168. if(stripos($downwaybill,$dw[1]) === false)
  2169. {
  2170. $dwls[$dw[1]] = 1;
  2171. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  2172. }
  2173. }
  2174. }
  2175. }
  2176. if($fullorder['printtype'] == 1)
  2177. {
  2178. if($fullorder['waybill'] != '' && !isset($dwls[$fullorder['waybill']]))
  2179. {
  2180. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullorder['printtime']).'/y-'.$fullorder['waybill'].'.pdf" target="_blank">'.$fullorder['waybill'].'</a>、'.$downwaybill;
  2181. }
  2182. }
  2183. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  2184. /** 历史打印时间 **/
  2185. $printtime = '';
  2186. if($fullorder['oldprinttime'])
  2187. {
  2188. $pte = explode('-',rtrim($fullorder['oldprinttime'],'-'));
  2189. foreach ($pte as $v)
  2190. {
  2191. $printtime .= date('Y-m-d H:i:s',$v).'、';
  2192. }
  2193. }
  2194. $this->data['printtime'] = rtrim($printtime,'、');
  2195. $product = '';
  2196. $fullorder['product'] = str_replace("'","",$fullorder['product']);
  2197. if($fullorder['link'] != '' && $fullorder['source'] != '1')
  2198. {
  2199. $pt = explode(',',$fullorder['product']);
  2200. $lk = explode(',',$fullorder['link']);
  2201. for($i=0;$i<count($pt);$i++)
  2202. {
  2203. if(isset($lk[$i]))
  2204. {
  2205. $octs = $this->colourorderts->get_texturl($pt[$i],$lk[$i]);
  2206. }
  2207. else
  2208. {
  2209. $octs = '';
  2210. }
  2211. $a = $octs?'<font style="color:#'.$octs['colour'].'">'.$pt[$i].'</font>':$pt[$i];
  2212. //$a = (stripos($pt[$i],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($pt[$i],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($pt[$i],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($pt[$i],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($pt[$i],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($pt[$i],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($pt[$i],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($pt[$i],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($pt[$i],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$pt[$i].'</font>':$pt[$i];
  2213. if(isset($lk[$i]))
  2214. {
  2215. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  2216. }
  2217. else
  2218. {
  2219. $product .= ($product != '')?' , '.$a:$a;
  2220. }
  2221. }
  2222. }
  2223. else
  2224. {
  2225. $octs = $this->colourorderts->get_text($fullorder['product']);
  2226. $a = $octs?'<font style="color:#F39">'.$fullorder['product'].'</font>':$fullorder['product'];
  2227. //$a = (stripos($fullorder['product'],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($fullorder['product'],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($fullorder['product'],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($fullorder['product'],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($fullorder['product'],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($fullorder['product'],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($fullorder['product'],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($fullorder['product'],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($fullorder['product'],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$fullorder['product'].'</font>':$fullorder['product'];
  2228. $product = $a;
  2229. }
  2230. $this->data['product'] = $product;
  2231. $out = $this->systemtransfer->find_all("number = '".$fullorder['number']."'");
  2232. $outread = '';
  2233. if($out)
  2234. {
  2235. foreach ($out as $val)
  2236. {
  2237. $list = '';
  2238. $rk = explode('|',trim($val['rk'],'|'));
  2239. $rktime = explode('|',trim($val['rktime'],'|'));
  2240. $zw = array();
  2241. $t = $this->transfer->find_all("1=1");
  2242. foreach ($t as $v)
  2243. {
  2244. $zw[$v['id']] = $v['title'];
  2245. }
  2246. if($val['rk'] != '' && count($rk) > 0)
  2247. {
  2248. for($i=0;$i<count($rk);$i++)
  2249. {
  2250. if(!isset($rktime[$i]))
  2251. {
  2252. $list .= $zw[$cz[$i]];
  2253. }
  2254. else
  2255. {
  2256. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  2257. }
  2258. }
  2259. }
  2260. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  2261. }
  2262. }
  2263. else
  2264. {
  2265. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullorder['number']."'");
  2266. $outread = array();
  2267. if($systemwigsout)
  2268. {
  2269. foreach ($systemwigsout as $v)
  2270. {
  2271. if($v['czwarehouse'] == 37)
  2272. {
  2273. $outread[] = '华荣厂';
  2274. }
  2275. else if($v['czwarehouse'] == 0)
  2276. {
  2277. $outread[] = '龙盈厂';
  2278. }
  2279. $cz = explode('|',trim($v['cz'],'|'));
  2280. $cztime = explode('|',trim($v['cztime'],'|'));
  2281. $zw = $this->transfer->get_list();
  2282. if($v['cz'] != '' && count($cz) > 0)
  2283. {
  2284. for($i=0;$i<count($cz);$i++)
  2285. {
  2286. if(!isset($cztime[$i]))
  2287. {
  2288. $outread[] = $zw[$cz[$i]].' -&gt; ';
  2289. }
  2290. else
  2291. {
  2292. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  2293. }
  2294. }
  2295. $outread[] = '<br>';
  2296. }
  2297. }
  2298. }
  2299. }
  2300. $klarnacolor = '';
  2301. if($fullorder['klarnadata'] !='')
  2302. {
  2303. $klarnadata = explode('|',$fullorder['klarnadata']);
  2304. if($klarnadata[0] == 'paypal' || $klarnadata[0] == 'stripe')
  2305. {
  2306. $klarnadata[1] = json_decode($klarnadata[1],true);
  2307. if($klarnadata[0] == 'stripe' && $klarnadata[1]['shouldmoney'] != $fullorder['shouldmoney'] && $fullorder['pay'] == 1211)
  2308. {
  2309. $klarnacolor = 'style="color:#F00"';
  2310. }
  2311. }
  2312. else if($klarnadata[0]!=1 && $fullorder['pay']!=26 && $fullorder['pay']!=27 && $fullorder['pay']!=1211)
  2313. {
  2314. $klarnacolor = 'style="color:#F00"';
  2315. }
  2316. if($fullorder['pay'] == 23)//klarna
  2317. {
  2318. $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','guam'=>'GU','puerto rico'=>'PR');
  2319. $ToState = array_flip($ToState);
  2320. $klarnadata3 = str_replace(' ','',$klarnadata[3]);
  2321. $city = str_replace(' ','',$fullorder['city']);
  2322. $klarnadataaddress = explode($city,$klarnadata3);
  2323. if(isset($klarnadataaddress[1]))
  2324. {
  2325. $klarnadata3 = $city.$klarnadataaddress[1];
  2326. $klarnadatacolor = explode(',',$klarnadata3);
  2327. unset($klarnadatacolor[4]);
  2328. unset($klarnadatacolor[6]);
  2329. if(isset($ToState[$klarnadatacolor[1]]))
  2330. {
  2331. $klarnadatacolor[1] = ucwords($ToState[$klarnadatacolor[1]]);
  2332. }
  2333. $klarnadata['color'] = $klarnadataaddress[0].implode(",",$klarnadatacolor);
  2334. }
  2335. else
  2336. {
  2337. $klarnadata['color'] = $klarnadata3;
  2338. }
  2339. }
  2340. }
  2341. else
  2342. {
  2343. $klarnadata = '';
  2344. }
  2345. $p = explode('-',$fullorder['paypal']);
  2346. $this->data['klarnacolor'] = $klarnacolor;
  2347. $this->data['klarnadata'] = $klarnadata;
  2348. $this->data['systemwigsout'] = $outread;
  2349. $quantity = explode(';',trim($fullorder['quantity'],';'));
  2350. $qc = 0;
  2351. foreach ($quantity as $v)
  2352. {
  2353. if($v > 1)
  2354. {
  2355. $qc += 1;
  2356. }
  2357. }
  2358. $this->data['qc'] = $qc;
  2359. //新增row_total和sub_total
  2360. $product_ids = $row_total = $sub_total = "";
  2361. if(!empty($fullorder['extra_price'])){
  2362. $extra_price = json_decode($fullorder['extra_price'],true);
  2363. foreach($extra_price as $k=>$v){
  2364. $row_total .= sprintf("%.2f",($v['qty']* $v['price'])).";";
  2365. $sub_total .= sprintf("%.2f",$v['sub_total']).";";
  2366. if(!empty($v['product_id'])){
  2367. $product_ids .= $v['product_id'].";";
  2368. }
  2369. }
  2370. }
  2371. $this->data['row_total'] = trim($row_total,";");
  2372. $this->data['sub_total'] = trim($sub_total,";");
  2373. $this->data['product_ids'] = trim($product_ids,";");
  2374. $this->_Template('fullorder_readonly',$this->data);
  2375. }
  2376. //浏览列表
  2377. public function _readlist()
  2378. {
  2379. if(isset($_SESSION['api']))
  2380. {
  2381. $user = $this->user->get_api($_SESSION['api']);
  2382. $usp = $user;
  2383. $fgshop = "";$sid = "";
  2384. $usersp = explode('|',trim($user['shop'],'|'));
  2385. foreach ($usersp as $value)
  2386. {
  2387. $fgshop .= " shop = ".$value." or";
  2388. $sid .= " id = ".$value." or";
  2389. }
  2390. }
  2391. $post = $this->input->post(NULL, TRUE);
  2392. if(isset($post['page']))
  2393. {
  2394. $page = $this->input->post('page',true);
  2395. $perpage = $this->input->post('perpage',true);
  2396. $shop = $this->input->post('shop',true);
  2397. $warehouse = $this->input->post('warehouse',true);
  2398. $express = $this->input->post('express',true);
  2399. $state = $this->input->post('state',true);
  2400. $print = $this->input->post('print',true);
  2401. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2402. $orderinfo = $this->input->post('orderinfo',true);
  2403. $client = $this->input->post('name',true);
  2404. $email = $this->input->post('email',true);
  2405. $number = $this->input->post('number',true);
  2406. $waybill = $this->input->post('waybill',true);
  2407. $authorid = $this->input->post('authorid',true);
  2408. $sourcecontentid = $this->input->post('sourcecontentid',true);
  2409. $timetk = $this->input->post('timetk',true);
  2410. $timetj = $this->input->post('timetj',true);
  2411. $timetk = strtotime($timetk);
  2412. $timetj = strtotime($timetj);
  2413. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  2414. if($shop)
  2415. {
  2416. $where .= " and shop = '$shop'";
  2417. }
  2418. if($warehouse)
  2419. {
  2420. $where .= " and type = '$warehouse'";
  2421. }
  2422. if($express)
  2423. {
  2424. $where .= " and express = '$express'";
  2425. }
  2426. if($state)
  2427. {
  2428. $where .= " and state = '$state'";
  2429. }
  2430. if($print)
  2431. {
  2432. $where .= " and print = '$print'";
  2433. }
  2434. if($libraryconfirm)
  2435. {
  2436. $where .= " and libraryconfirm = '$libraryconfirm'";
  2437. }
  2438. if($orderinfo)
  2439. {
  2440. $where .= " and orderinfo = '$orderinfo'";
  2441. }
  2442. if($client)
  2443. {
  2444. $where .= " and client like '%$client%'";
  2445. }
  2446. if($email)
  2447. {
  2448. $where .= " and email = '$email'";
  2449. }
  2450. if($number)
  2451. {
  2452. $where .= " and number = '$number'";
  2453. }
  2454. if($waybill)
  2455. {
  2456. $where .= " and waybill = '$waybill'";
  2457. }
  2458. if($authorid)
  2459. {
  2460. $where .= " and authorid = '$authorid'";
  2461. }
  2462. if($sourcecontentid)
  2463. {
  2464. $where .= " and sourcecontentid = '$sourcecontentid'";
  2465. }
  2466. if($timetk && $timetj)
  2467. {
  2468. $timetj = $timetj+24*3600;
  2469. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2470. }
  2471. //数据排序
  2472. $order_str = "dtime desc";
  2473. if(empty($page))
  2474. {
  2475. $start = 0;
  2476. $perpage = 1;
  2477. }
  2478. else
  2479. {
  2480. $start = ($page - 1)*$perpage;
  2481. }
  2482. //取得信息列表
  2483. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,sname,state,buytime,review,libraryconfirm,express,waybill,exstate,orderremarks,library,clientremarks,waybillid',$order_str,$start,$perpage);
  2484. //格式化数据
  2485. $dt = 0;
  2486. foreach ($info_list as $key=>$value)
  2487. {
  2488. $ud = $this->fullorder->read($value['id']);
  2489. $ud['address'] = str_replace("'","’",$ud['address']);
  2490. $ud['name'] = str_replace("'","’",$ud['name']);
  2491. $customer = $this->customer->get_email($ud['email'],$value['shop']);
  2492. $customernum = $this->fullorder->find_count("email = '".$ud['email']."' and shop = '".$value['shop']."'");
  2493. preg_match_all('/[0-9]/u',$ud['phone'],$result);
  2494. $numphone = join('',$result[0]);
  2495. $customerb = $this->customer->find_all("type = 2 and (email = '".$ud['email']."' or address = '".$ud['address']."' or numphone = '".$numphone."')",'*','id desc');
  2496. $customerc = $this->customer->find_all("type = 1 and shop = '".$ud['shop']."' and address = '".$ud['address']."' and numphone = '".$numphone."'",'*','id desc');
  2497. //$a = array_column($customer, 'email'); //三维找其中健的数组
  2498. //$a = array_flip($a); //键和值调换
  2499. $lkh = $value['sname'];
  2500. $djlkh = 0;$djhmd = 0;
  2501. if($customer)
  2502. {
  2503. if(($customer['type'] == 1 && $customernum > 1))// || $customerc['type'] == 1 && $customerc['num'] > 1
  2504. {
  2505. $count = $customer['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>':'';
  2506. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户</p>";
  2507. $djlkh = 1;
  2508. $djcount = $count;
  2509. }
  2510. else if(isset($customerc[0]['num']))
  2511. {
  2512. if($customerc[0]['num'] > 1)
  2513. {
  2514. $count = $customer['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>':'';
  2515. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户</p>";
  2516. $djlkh = 1;
  2517. $djcount = $count;
  2518. }
  2519. }
  2520. }
  2521. if($customerb)
  2522. {
  2523. $hmsp = $this->shop->read($customerb[0]['shop']);
  2524. $count = $customerb[0]['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customerb[0]['count'].'"></i>':'';
  2525. $lkh = "<p>".$value['sname']."</p><p style='color:#9900CC'>".$count."黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  2526. $djhmd = 1;
  2527. }
  2528. if($djlkh == '1' && $djhmd == '1')
  2529. {
  2530. $lkh = "<p>".$value['sname']."</p><p style='color:#9900CC'><em style='color:#FF3333'>".$djcount."老客户</em> - ".$count."黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  2531. }
  2532. $info_list[$key]['sname'] = $lkh;
  2533. $shop = $this->shop->read($value['shop']);
  2534. $info_list[$key]['shop'] = $shop['shopname'];
  2535. //$info_list[$key]['user'] = $shop['shopuser'];
  2536. $warehouse = $this->warehouse->read($value['type']);
  2537. $warehousetitle = $warehouse['title'];
  2538. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  2539. $info_list[$key]['type'] = $warehousetitle;
  2540. $typeclass = $this->typeclass->read($value['state']);
  2541. $info_list[$key]['state'] = $typeclass['spare'];
  2542. $wl = '';
  2543. if($value['exstate'] == '99')
  2544. {
  2545. $wl = '<font style="color:#ccc">未获取到物流信息</font>';
  2546. }
  2547. else if($value['exstate'] == '1')
  2548. {
  2549. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">已揽收<font style="display: none">'.$ud['excontent'].'</font></font>';
  2550. }
  2551. else if($value['exstate'] == '2')
  2552. {
  2553. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">在途中<font style="display: none">'.$ud['excontent'].'</font></font>';
  2554. }
  2555. else if($value['exstate'] == '3')
  2556. {
  2557. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">派送中<font style="display: none">'.$ud['excontent'].'</font></font>';
  2558. }
  2559. else if($value['exstate'] == '4')
  2560. {
  2561. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">已签收<font style="display: none">'.$ud['excontent'].'</font></font>';
  2562. }
  2563. else if($value['exstate'] == '5')
  2564. {
  2565. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">派送异常<font style="display: none">'.$ud['excontent'].'</font></font>';
  2566. }
  2567. $info_list[$key]['exstate'] = $wl.'<br />';
  2568. if($ud['source'] == 1) //线下单用订单时间,其他用付款时间
  2569. {
  2570. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$ud['dtime']).'</p><p>'.date('H:i:s',$ud['dtime']).'</p>';
  2571. }
  2572. else
  2573. {
  2574. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']+$dt).'</p><p>'.date('H:i:s',$value['buytime']+$dt).'</p>';
  2575. }
  2576. if($value['review'] == 1)
  2577. {
  2578. $info_list[$key]['review'] = "未送审";
  2579. }
  2580. else if($value['review'] == 2)
  2581. {
  2582. $info_list[$key]['review'] = "<font style='color:#555'>待审核</font>";
  2583. }
  2584. else if($value['review'] == 3)
  2585. {
  2586. $info_list[$key]['review'] = "<font style='color:#f90f4b'>不通过</font>";
  2587. }
  2588. else if($value['review'] == 4)
  2589. {
  2590. $info_list[$key]['review'] = "取消重审";
  2591. }
  2592. else if($value['review'] == 5)
  2593. {
  2594. $info_list[$key]['review'] = "<font style='color:#2f80f9'>审核通过</font>";
  2595. }
  2596. else if($value['review'] == 6)
  2597. {
  2598. $info_list[$key]['review'] = "<font style='color:#2f80f9'>自动通过</font>";
  2599. }
  2600. if($ud['dlz'] == 1)
  2601. {
  2602. $dlz = "<p>独立站已更新</p>";
  2603. }
  2604. else if($ud['dlz'] == 3)
  2605. {
  2606. $dlz = "<p>不需要更新</p>";
  2607. }
  2608. else if($ud['dlz'] == 2)
  2609. {
  2610. $dlz = "<p style='color:#C3C'>独立站更新失败</p>";
  2611. }
  2612. else
  2613. {
  2614. $dlz = "";
  2615. }
  2616. if($value['waybill'] != "")
  2617. {
  2618. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz;
  2619. if( !empty($value['waybillid'])){
  2620. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz."<p>".$value['waybillid']."</p>";
  2621. }
  2622. }
  2623. if($value['express'] != 0)
  2624. {
  2625. $express = $this->express->read($value['express']);
  2626. $expressservicename = $express['servicename'];
  2627. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  2628. $info_list[$key]['express'] = $expressservicename;
  2629. }
  2630. else
  2631. {
  2632. $info_list[$key]['express'] = "无";
  2633. }
  2634. $tly = "";
  2635. if($value['clientremarks'] != "")
  2636. {
  2637. $tly = "<p style='color:#FF3333'>有客户留言</p>";
  2638. }
  2639. if($value['library'] == 1 && $ud['printtype'] == 3)
  2640. {
  2641. $info_list[$key]['library'] = "不需要";
  2642. }
  2643. else if($value['library'] == 1 && $ud['printtype'] != 3)
  2644. {
  2645. $info_list[$key]['library'] = "未出库";
  2646. }
  2647. else if($value['library'] == 2)
  2648. {
  2649. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  2650. }
  2651. else if($value['library'] == 3)
  2652. {
  2653. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  2654. }
  2655. if($ud['authorid'] != '' && $ud['authorid'] != 0)
  2656. {
  2657. $info_list[$key]['orderremarks'] = '<p>'.$value['orderremarks'].'</p><p style="border-top: 1px dashed #C2C2C2;">author_id:</p><p>'.$ud['authorid'].'</p><p>source_content_id:</p><p>'.$ud['sourcecontentid'].'</p>';
  2658. }
  2659. unset($info_list[$key]['waybillid']);
  2660. }
  2661. $total = $this->fullorder->find_count($where);
  2662. $pagenum = ceil($total/$perpage);
  2663. $over = $total-($start+$perpage);
  2664. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2665. echo json_encode($rows);exit;
  2666. }
  2667. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2668. $this->data['wlshop'] = $wlshop;
  2669. $this->_Template('fullorder_readlist',$this->data);
  2670. }
  2671. public function _readlistdown()
  2672. {
  2673. if(isset($_SESSION['api']))
  2674. {
  2675. $user = $this->user->get_api($_SESSION['api']);
  2676. $usp = $user;
  2677. $fgshop = "";$sid = "";
  2678. $usersp = explode('|',trim($user['shop'],'|'));
  2679. foreach ($usersp as $value)
  2680. {
  2681. $fgshop .= " shop = ".$value." or";
  2682. $sid .= " id = ".$value." or";
  2683. }
  2684. }
  2685. $post = $this->input->get(NULL, TRUE);
  2686. if(isset($post['excel']))
  2687. {
  2688. $shop = $this->input->get('shop',true);
  2689. $warehouse = $this->input->get('warehouse',true);
  2690. $express = $this->input->get('express',true);
  2691. $state = $this->input->get('state',true);
  2692. $print = $this->input->get('print',true);
  2693. $libraryconfirm = $this->input->get('libraryconfirm',true);
  2694. $orderinfo = $this->input->get('orderinfo',true);
  2695. $client = $this->input->get('name',true);
  2696. $email = $this->input->get('email',true);
  2697. $number = $this->input->get('number',true);
  2698. $waybill = $this->input->get('waybill',true);
  2699. $authorid = $this->input->get('authorid',true);
  2700. $sourcecontentid = $this->input->get('sourcecontentid',true);
  2701. $timetk = $this->input->get('timetk',true);
  2702. $timetj = $this->input->get('timetj',true);
  2703. $timetk = strtotime($timetk);
  2704. $timetj = strtotime($timetj);
  2705. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  2706. if($shop)
  2707. {
  2708. $where .= " and shop = '$shop'";
  2709. }
  2710. if($warehouse)
  2711. {
  2712. $where .= " and type = '$warehouse'";
  2713. }
  2714. if($express)
  2715. {
  2716. $where .= " and express = '$express'";
  2717. }
  2718. if($state)
  2719. {
  2720. $where .= " and state = '$state'";
  2721. }
  2722. if($print)
  2723. {
  2724. $where .= " and print = '$print'";
  2725. }
  2726. if($libraryconfirm)
  2727. {
  2728. $where .= " and libraryconfirm = '$libraryconfirm'";
  2729. }
  2730. if($orderinfo)
  2731. {
  2732. $where .= " and orderinfo = '$orderinfo'";
  2733. }
  2734. if($client)
  2735. {
  2736. $where .= " and client like '%$client%'";
  2737. }
  2738. if($email)
  2739. {
  2740. $where .= " and email = '$email'";
  2741. }
  2742. if($number)
  2743. {
  2744. $where .= " and number = '$number'";
  2745. }
  2746. if($waybill)
  2747. {
  2748. $where .= " and waybill = '$waybill'";
  2749. }
  2750. if($authorid)
  2751. {
  2752. $where .= " and authorid = '$authorid'";
  2753. }
  2754. if($sourcecontentid)
  2755. {
  2756. $where .= " and sourcecontentid = '$sourcecontentid'";
  2757. }
  2758. if($timetk && $timetj)
  2759. {
  2760. $timetj = $timetj+24*3600;
  2761. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2762. }
  2763. //数据排序
  2764. $order_str = "dtime desc";
  2765. //取得信息列表
  2766. $info_list = $this->fullorder->find_all($where,'shop,number,orderinfo,buytime,name,express,waybill,email,shipremarks,shouldmoney,orderremarks,librarytime,authorid,sourcecontentid',$order_str);
  2767. //格式化数据
  2768. $dt = 0;
  2769. foreach ($info_list as $key=>$value)
  2770. {
  2771. $shop = $this->shop->read($value['shop']);
  2772. $info_list[$key]['shop'] = $shop['shopname'];
  2773. $info_list[$key]['buytime'] = date('Y-m-d H:i:s',$value['buytime']);
  2774. if($value['librarytime'] > 0)
  2775. {
  2776. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  2777. }
  2778. if($value['express'] != 0)
  2779. {
  2780. $express = $this->express->read($value['express']);
  2781. $info_list[$key]['express'] = $express['servicename'];
  2782. }
  2783. else
  2784. {
  2785. $info_list[$key]['express'] = "无";
  2786. }
  2787. }
  2788. $title = "订单列表 ".date("Y-m-d");
  2789. $titlename = "<table border=1>
  2790. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  2791. <tr>
  2792. <td>店铺</td>
  2793. <td>编号</td>
  2794. <td>订单号</td>
  2795. <td>订单日期</td>
  2796. <td>客户姓名</td>
  2797. <td>快递方式</td>
  2798. <td>运单号</td>
  2799. <td>邮箱</td>
  2800. <td>仓库品名</td>
  2801. <td>订单金额</td>
  2802. <td>订单备注</td>
  2803. <td>出库时间</td>
  2804. <td>author_id</td>
  2805. <td>source_content_id</td>
  2806. </tr>
  2807. </table>";
  2808. $filename = $title.".xls";
  2809. $tail = "\n";
  2810. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  2811. }
  2812. }
  2813. //删除
  2814. public function _del()
  2815. {
  2816. echo json_encode(array('msg'=>'不允许执行!','success'=>false));exit;
  2817. $post = $this->input->post(NULL, TRUE);
  2818. if(isset($post['s']))
  2819. {
  2820. $id_arr = $this->input->post('s');
  2821. $id_arr = explode(',',$id_arr);
  2822. if(!$id_arr)
  2823. {
  2824. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2825. }
  2826. //循环删除记录
  2827. foreach ($id_arr as $v)
  2828. {
  2829. $this->fullorder->remove($v);
  2830. }
  2831. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  2832. }
  2833. }
  2834. //查找商品价格
  2835. public function _price()
  2836. {
  2837. $post = $this->input->post(NULL, TRUE);
  2838. if(isset($post['data']))
  2839. {
  2840. $data = $this->input->post('data');
  2841. $data = explode('-',$data);
  2842. $number = '';$num = count($data);
  2843. //循环删除记录
  2844. for($i=0;$i<$num-1;$i++)
  2845. {
  2846. if($data[$i] != 0)
  2847. {
  2848. $number=$number.$data[$i];
  2849. if($i == 2)
  2850. {
  2851. $number=$number.$data[$num-1];
  2852. }
  2853. }
  2854. }
  2855. $list = $this->productdescribe->get_number($number);
  2856. if($list)
  2857. {
  2858. echo json_encode(array('msg'=>($list),'n'=>$data[$num-1],'number'=>$number,'success'=>true));
  2859. }
  2860. else
  2861. {
  2862. $list = array('purchase'=>0,'cost'=>0,'salesprice'=>0);
  2863. //echo json_encode(array('msg'=>'此信息没有配置价格!','n'=>$data[$num-1],'success'=>false));exit;
  2864. echo json_encode(array('msg'=>($list),'n'=>$data[$num-1],'number'=>$number,'success'=>true));exit;
  2865. }
  2866. }
  2867. }
  2868. public function _customs()
  2869. {
  2870. $post = $this->input->post(NULL, TRUE);
  2871. if(isset($post['e']))
  2872. {
  2873. $e = $this->input->post('e');//快递信息
  2874. $c = $this->input->post('c');//国家信息
  2875. $data = $this->customs->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2876. $list = $this->productdescription->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2877. $rows = array();
  2878. foreach ($data as $key=>$value)
  2879. {
  2880. $detailed = explode('|',trim($value['detailed'],'|'));
  2881. //此处未对比重量选择价值,暂直接选择第一条海关价值
  2882. $detailed = $this->detailed->read($detailed[0]);
  2883. $money = $detailed['customsval'];//找到海关价值
  2884. }
  2885. foreach ($list as $key=>$value)
  2886. {
  2887. $description = $this->typeclass->read($value['description']);
  2888. $list[$key]['title'] = $description['title'];//产品描述名称
  2889. }
  2890. if(!$data && !$list)
  2891. {
  2892. echo json_encode(array('msg'=>'无此快递配置信息!','success'=>false));exit;
  2893. }
  2894. else
  2895. {
  2896. //$list-title -description 取值
  2897. echo json_encode(array('money'=>sprintf("%.2f",$money),'msg'=>$list,'success'=>true));
  2898. }
  2899. }
  2900. }
  2901. public function _express()
  2902. {
  2903. $post = $this->input->post(NULL, TRUE);
  2904. if(isset($post['e']))
  2905. {
  2906. $e = $this->input->post('e');//快递信息
  2907. $c = $this->input->post('c');//国家信息
  2908. $data = $this->logistics->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2909. if(!$data)
  2910. {
  2911. echo json_encode(array('success'=>false));exit;
  2912. }
  2913. else
  2914. {
  2915. echo json_encode(array('money'=>sprintf("%.2f",$data[0]['firstmoney']),'success'=>true));
  2916. }
  2917. }
  2918. }
  2919. public function _hl()
  2920. {
  2921. $post = $this->input->post(NULL, TRUE);
  2922. if(isset($post['cy']))
  2923. {
  2924. $hl = 0;
  2925. $cy = $this->input->post('cy');//币种ID
  2926. $cy = $this->typeclass->read($cy);
  2927. $gethl = $this->hl->get_hl();
  2928. foreach ($gethl as $v)
  2929. {
  2930. $code = str_replace(" ","",$v['code']);
  2931. if($code == $cy['title'])
  2932. {
  2933. $hl = $v['refePrice']/100;
  2934. }
  2935. }
  2936. echo json_encode(array('msg'=>$hl,'success'=>true));
  2937. }
  2938. }
  2939. public function _operation()
  2940. {
  2941. $post = $this->input->post(NULL, TRUE);
  2942. if(isset($post['type']))
  2943. {
  2944. $type = $this->input->post('type');
  2945. $id = $this->input->post('id');
  2946. $msg = $this->input->post('msg');
  2947. $d = $this->fullorder->read($id);
  2948. $time = time();
  2949. if($type == 1)//禁止发货
  2950. {
  2951. if($d['library'] != 1)
  2952. {
  2953. echo json_encode(array('msg'=>'操作失败,订单非未出库状态!','success'=>false));exit;
  2954. }
  2955. if($msg == "")
  2956. {
  2957. echo json_encode(array('msg'=>'必须填写禁止原因!','success'=>false));exit;
  2958. }
  2959. if($d['print'] < 3)
  2960. {
  2961. $a = "订单未打印,";
  2962. }
  2963. else
  2964. {
  2965. $a = "";
  2966. }
  2967. if($this->fullorder->save(array('libraryconfirm'=>1,'librarynot'=>$a.$msg),$id))
  2968. {
  2969. echo json_encode(array('msg'=>'操作成功','l'=>1,'d'=>$id,'success'=>true));exit;
  2970. }
  2971. else
  2972. {
  2973. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2974. }
  2975. }
  2976. if($type == 6)//允许发货
  2977. {
  2978. if($d['library'] > 1)
  2979. {
  2980. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2981. }
  2982. if($d['print'] < 3)
  2983. {
  2984. $a = "订单未打印,";
  2985. }
  2986. else
  2987. {
  2988. $a = "";
  2989. }
  2990. if($this->fullorder->save(array('libraryconfirm'=>2,'librarynot'=>$a.$msg),$id))
  2991. {
  2992. echo json_encode(array('msg'=>'操作成功','l'=>1,'d'=>$id,'success'=>true));exit;
  2993. }
  2994. else
  2995. {
  2996. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2997. }
  2998. }
  2999. if($type == 7)//禁止打印
  3000. {
  3001. if($d['printtime'] != 0)
  3002. {
  3003. echo json_encode(array('msg'=>'订单已打印,操作失败','success'=>false));exit;
  3004. }
  3005. if($d['library'] > 1)
  3006. {
  3007. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  3008. }
  3009. if($d['print'] < 3)
  3010. {
  3011. $a = "订单未打印,";
  3012. }
  3013. else
  3014. {
  3015. $a = "";
  3016. }
  3017. if($this->fullorder->save(array('print'=>1),$id))
  3018. {
  3019. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  3020. }
  3021. else
  3022. {
  3023. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3024. }
  3025. }
  3026. if($type == 8)//允许打印
  3027. {
  3028. /**
  3029. if($d['printtime'] != 0)
  3030. {
  3031. echo json_encode(array('msg'=>'订单已打印,操作失败','success'=>false));exit;
  3032. }
  3033. **/
  3034. if($d['library'] > 1)
  3035. {
  3036. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  3037. }
  3038. if($d['print'] < 3)
  3039. {
  3040. $a = "订单未打印,";
  3041. }
  3042. else
  3043. {
  3044. $a = "";
  3045. }
  3046. if($d['printtime'] == '0')
  3047. {
  3048. $bcprint = 2;
  3049. }
  3050. else
  3051. {
  3052. $bcprint = 3;
  3053. }
  3054. if($this->fullorder->save(array('print'=>$bcprint,'failed'=>''),$id))
  3055. {
  3056. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  3057. }
  3058. else
  3059. {
  3060. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3061. }
  3062. }
  3063. if($type == 9)//关闭
  3064. {
  3065. if($this->fullorder->save(array('failed'=>''),$id))
  3066. {
  3067. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  3068. }
  3069. else
  3070. {
  3071. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3072. }
  3073. }
  3074. if($type == 2)//填写运单、修改运单
  3075. {
  3076. if($d['express'] == 0)
  3077. {
  3078. echo json_encode(array('msg'=>'操作失败,未选择物流方式!','success'=>false));exit;
  3079. }
  3080. if($d['library'] == 3 || ($d['print'] == 3 && $d['libraryconfirm'] == 1))
  3081. {
  3082. echo json_encode(array('msg'=>'操作失败,不允许填写运单号!','success'=>false));exit;
  3083. }
  3084. if($msg == '')
  3085. {
  3086. echo json_encode(array('msg'=>'运单号不能为空!','success'=>false));exit;
  3087. }
  3088. $ckemail = '';
  3089. $d['waybill'] = $msg;
  3090. $xg = $this->fullorder->read($id);
  3091. $shop = $this->shop->read($xg['shop']);
  3092. $ex = $this->express->read($xg['express']);
  3093. $fs = $this->notice->find_all("shop = '".$d['shop']."' and message = '1' and state = '1' and type = '4' and ktime < '$time' and jtime > '$time'");
  3094. if(isset($fs[0]))
  3095. {
  3096. $fs = $fs[0];
  3097. $fs['email'] = $this->emaildata->read($fs['email']);
  3098. if(($xg['dlzemail'] == 1 && $msg != $xg['waybill']) || $xg['dlzemail'] == 0)
  3099. {
  3100. $warehouse = $this->warehouse->read($xg['type']);
  3101. $ck = $this->notice->get_god($d,$shop,$ex,$fs);
  3102. if($ck == 1)
  3103. {
  3104. $ckemail = '邮件发送成功,';
  3105. $this->fullorder->save(array('dlzemail'=>1,'dlzemailtime'=>time()),$id);
  3106. }
  3107. }
  3108. }
  3109. if( $msg )
  3110. {
  3111. if($xg['source'] != 1)
  3112. {
  3113. $ms = $this->message->find_all("express like '%,".$xg['express'].",%'");
  3114. if(!isset($ms[0]))
  3115. {
  3116. $ms = $this->message->read(2);
  3117. }
  3118. else
  3119. {
  3120. $ms = $ms[0];
  3121. }
  3122. if($xg['shop'] == 5){
  3123. $ddh = $xg['orderinfo'];
  3124. }else{
  3125. $ddh = substr($xg['orderinfo'],1);
  3126. }
  3127. $shopifyid = $xg['shopify'];
  3128. //独立站地址更新订单状态、物流信息
  3129. $shopname = $shop['brandname']; //店铺名
  3130. $buyername = $xg['bname']; //Bill Name
  3131. $email_call = $shop['shopid']; //发货人邮箱;
  3132. $phone = $shop['shopphone']; //发货人电话
  3133. $track_type = $ex['title']; //快递名称
  3134. $service = $ex['title']; //快递追踪名称
  3135. $track_link = $ex['url']; //快递查询网址
  3136. $logistics_number = $msg; //运单号
  3137. $t= array('%buyername%','%email_call%','%track_type%','%service%','%track_link%','%logistics_number%','%shop%','%phone%','%jtime%');
  3138. $h= array($buyername,$email_call,$track_type,$service,$track_link,$logistics_number,$shopname,$phone,$ex['yjtime']);
  3139. $remark = str_replace($t,$h,$ms['content']);
  3140. $gx = $this->api->get_gx($ddh,$msg,$xg,$shop,$ex,$remark,$shopifyid);
  3141. }
  3142. else if($xg['source'] == 1)
  3143. {
  3144. $gx['res'] = 3;
  3145. $gx['state'] = 216;
  3146. $gx['cw'] = 'a';
  3147. }
  3148. }
  3149. else
  3150. {
  3151. $gx['res'] = $xg['dlz'];
  3152. $gx['state'] = $xg['state'];
  3153. $gx['cw'] = 'b';
  3154. }
  3155. $xg['iscode'] = $ex['title'];
  3156. $xg['url'] = $shop['shopname'];
  3157. $xg['waybill'] = $msg;
  3158. @$chuanshu = $this->api->get_paypal($xg);
  3159. $this->afspaypal->insert(array('number'=>$xg['number'],'cs'=>$chuanshu));
  3160. $msg = preg_replace('/( | | | |\s)/','',$msg);
  3161. if($this->fullorder->save(array('waybill'=>$msg,'state'=>$gx['state'],'dlz'=>$gx['res']),$id))
  3162. {
  3163. if($gx['res'] == 2)
  3164. {
  3165. echo json_encode(array('msg'=>$ckemail.'传输独立站失败!','cs'=>$gx['state'].' - '.$gx['res'].' - '.$gx['cw'],'success'=>false));exit;
  3166. }
  3167. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  3168. }
  3169. else
  3170. {
  3171. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3172. }
  3173. }
  3174. }
  3175. }
  3176. public function _merge()
  3177. {
  3178. $post = $this->input->post(NULL, TRUE);
  3179. if(isset($post['s']))
  3180. {
  3181. $id_arr = $this->input->post('s');
  3182. $id_arr = explode(',',trim( $id_arr,','));
  3183. $id_arr = array_reverse($id_arr);
  3184. if(!$id_arr)
  3185. {
  3186. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  3187. }
  3188. if(count($id_arr) < 2)
  3189. {
  3190. echo json_encode(array('msg'=>'缺少可合并单!','success'=>false));exit;
  3191. }
  3192. $tmp_list = $this->db->from('fullorder')->where_in('id',$id_arr)->select('id,orderinfo,number,type,express')->get()->result_array();
  3193. $count_warehouse_list = [];
  3194. $count_express_list = [];
  3195. $flag = 0;
  3196. $flag_str = '';
  3197. foreach ($tmp_list as $k => $v) {
  3198. $count_warehouse_list[$v['type']] = $v['type'];
  3199. if(empty($v['express'])){
  3200. $flag = 1;
  3201. $flag_str.= $v['number'].'仓库未选,请先选快递;';
  3202. }
  3203. $count_express_list[$v['express']] = $v['express'];
  3204. }
  3205. if($flag == 1){
  3206. echo json_encode(array('msg'=>$flag_str,'success'=>false));exit;
  3207. }
  3208. if(count($count_warehouse_list) > 1){
  3209. echo json_encode(array('msg'=>'合并单的仓库不一致,无法合并!','success'=>false));exit;
  3210. }
  3211. if(count($count_express_list) > 1){
  3212. echo json_encode(array('msg'=>'合并单的快递不一致,无法合并!','success'=>false));exit;
  3213. }
  3214. $post = array();
  3215. $u = $this->fullorder->read($id_arr[0]);
  3216. unset($id_arr[0]);
  3217. $this->db->trans_begin();
  3218. $hd = $this->fullorderhb->get_orderinfo($u['orderinfo']);
  3219. if(!$hd)
  3220. {
  3221. $this->fullorderhb->insert($u);
  3222. }
  3223. //相加
  3224. $post['shouldmoney'] = $u['shouldmoney'];//购买应收金额
  3225. $post['budget'] = $u['budget'];//预估到帐金额
  3226. $post['expressmoney']= $u['expressmoney'];//物流金额
  3227. //$post['refundy'] = $u['refundy'];//补/退原额
  3228. //$post['refundj'] = $u['refundj'];//补/退净额
  3229. $post['cost'] = $u['cost'];//成本金额
  3230. //$post['zzl'] = $u['zzl'];//总重量
  3231. //$post['zsbjz'] = $u['zsbjz'];//总申报价值
  3232. $post['ts'] = $u['ts'];//条数
  3233. $post['cost'] = $u['cost'];//成本金额
  3234. //追加
  3235. $post['rpaypal'] = $u['rpaypal'];//补/退交易号
  3236. $post['rtext'] = $u['rtext'];//补/退原因
  3237. $post['pay'] = $u['pay'];//付款方式
  3238. $post['paypal'] = $u['paypal'];//交易号
  3239. $post['clientremarks'] = $u['clientremarks'];//客户留言
  3240. $post['product'] = $u['product'];//商品名称
  3241. //$post['issku'] = $u['issku'];//sku
  3242. //$post['orderremarks'] = $u['orderremarks'];//订单备注
  3243. $post['shipremarks'] = $u['shipremarks'];//仓库品名
  3244. //产品追加
  3245. $post['fpdata'] = $u['fpdata'];//产品内容
  3246. $post['whlabel'] = $u['whlabel'];//产品对应库存码
  3247. $merge = $u['id'];
  3248. $d = array($u['id']);$order = '';
  3249. $zsl = 0;$zccsl = 0;
  3250. foreach ($id_arr as $v)
  3251. {
  3252. $v = $this->fullorder->read($v);
  3253. if($u['type'] != $v['type'])
  3254. {
  3255. echo json_encode(array('msg'=>'仓库不一致,无法合并!','success'=>false));exit;
  3256. }
  3257. if($v['shop'] = $u['shop'])
  3258. {
  3259. $hd = $this->fullorderhb->get_orderinfo($v['orderinfo']);
  3260. if(!$hd)
  3261. {
  3262. $this->fullorderhb->insert($v);
  3263. }
  3264. //$post['shouldmoney'] += $v['shouldmoney'];//购买应收金额
  3265. // $post['budget'] += $v['budget'];//预估到帐金额
  3266. // $post['expressmoney'] += $v['expressmoney'];//物流金额
  3267. //$post['refundy'] += $v['refundy'];//补/退原额
  3268. //$post['refundj'] += $v['refundj'];//补/退净额
  3269. $post['cost'] += $v['cost'];//成本金额
  3270. //$post['zzl'] += $v['zzl'];//总重量
  3271. //$post['zsbjz'] += $v['zsbjz'];//总申报价值
  3272. $post['ts'] += $v['ts'];//条数
  3273. //$post['rpaypal'] .= $v['rpaypal'];//补/退交易号
  3274. //$post['rtext'] .= $v['rtext'];//补/退原因
  3275. //$post['pay'] .= (stripos($post['pay'],$v['pay']) !== false)?'':';'.$v['pay'];//付款方式
  3276. //$post['paypal'] .= $v['paypal'];//交易号
  3277. $post['clientremarks'] .= $v['clientremarks'];//客户留言
  3278. $post['product'] .= $v['product'];//商品名称
  3279. //$post['issku'] .= $v['issku'];//sku
  3280. //$post['orderremarks'] .= $v['orderremarks'];//订单备注
  3281. $post['shipremarks'] .= $v['shipremarks'];//仓库品名
  3282. $post['fpdata'] .= $v['fpdata'];//产品内容
  3283. $post['whlabel'] .= ltrim($v['whlabel'],'|');//产品对应库存码
  3284. $d[] = $v['id'];
  3285. $order .= $v['orderinfo'].'('.$v['number'].')、';
  3286. $wl = $this->whlabel->find_all("zd = '".$v['number']."'");//查找是否有占用库存情况
  3287. $i = 0;
  3288. if($wl)//如果有那么清除所有占用
  3289. {
  3290. foreach ($wl as $val)
  3291. {
  3292. if($val['sku'] == 'Preset' && $val['state'] == '9')
  3293. {
  3294. $this->whlabel->remove($val['id']);//删除预设
  3295. $i++;
  3296. }
  3297. else
  3298. {
  3299. $this->whlabel->save(array('zd'=>''),$val['id']);//专属
  3300. $i++;
  3301. }
  3302. }
  3303. }
  3304. $zsl += count($wl);
  3305. $zccsl += $i;
  3306. $this->fullorder->save(array('merge'=>$u['id'],'mergeid'=>1,'orderremarks'=>' 《合并信息》:'.'已合并到'.$u['orderinfo'].'('.$u['number'].')中; '.$v['orderremarks'],'print'=>1,'libraryconfirm'=>1,'whlabel'=>'','fpdata'=>'','shipremarks'=>''),$v['id']);
  3307. }
  3308. }
  3309. //计算出单条价值
  3310. /**
  3311. if($post['zsbjz'] < 1 || $post['ts'] < 1)
  3312. {
  3313. //$post['dtsbjz'] = 0;
  3314. }
  3315. else
  3316. {
  3317. //$post['dtsbjz'] = $post['zsbjz']/$post['ts'];//单条申报价
  3318. }
  3319. **/
  3320. $post['orderremarks'] = ' 《合并信息》:由'.rtrim($order,'、').'合并而来; '.$u['orderremarks'];;
  3321. $post['merge'] = $u['id'];
  3322. //$post['mergeid'] = 1;
  3323. //合并重复项
  3324. $hbcfw = explode('|',trim($post['whlabel'],'|'));
  3325. $hbcff = explode(';',trim($post['fpdata'],';'));
  3326. $c = 0;
  3327. $hbw = array();
  3328. $hbf = array();
  3329. for($i=0;$i<count($hbcfw);$i++)
  3330. {
  3331. $w = explode('-',$hbcfw[$i]);
  3332. $f = explode('|',$hbcff[$i]);
  3333. if(isset($w[2]))
  3334. {
  3335. $w2 = ($w[2]==0)?0:'';
  3336. }
  3337. else
  3338. {
  3339. $w2 = '';
  3340. }
  3341. if(!isset($hbw[$w[0].$w2]))
  3342. {
  3343. $hbw[$w[0].$w2] = $hbcfw[$i];
  3344. $hbf[$w[0].$w2] = $hbcff[$i];
  3345. }
  3346. else
  3347. {
  3348. $c++;
  3349. $cw = explode('-',$hbw[$w[0].$w2]);
  3350. $cf = explode('|',$hbf[$w[0].$w2]);
  3351. if($cw[2] != 0 && $w[2] != 0)
  3352. {
  3353. $cf[2] += $f[2];
  3354. $cf[9] .= '~'.$f[9];
  3355. $hbf[$w[0].$w2] = implode("|",$cf);
  3356. $cw[1] += $f[2];
  3357. $cw[2] .= '~'.$f[9];
  3358. $hbw[$w[0].$w2] = implode("-",$cw);
  3359. }
  3360. else if($cw[2] == 0 && $w[2] == 0)
  3361. {
  3362. $cf[2] += $f[2];
  3363. $hbf[$w[0].$w2] = implode("|",$cf);
  3364. $cw[1] += $f[2];
  3365. $hbw[$w[0].$w2] = implode("-",$cw);
  3366. }
  3367. else
  3368. {
  3369. $hbw[] = $hbcfw[$i];
  3370. $hbf[] = $hbcff[$i];
  3371. }
  3372. }
  3373. }
  3374. if($c > 0)
  3375. {
  3376. $post['fpdata'] = implode(";",$hbf).';';
  3377. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  3378. }
  3379. //合并重复项结束
  3380. $this->fullorder->save($post,$u['id']);
  3381. if ($this->db->trans_status() === FALSE)
  3382. {
  3383. $this->db->trans_commit();
  3384. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3385. }
  3386. else
  3387. {
  3388. $this->db->trans_commit();
  3389. echo json_encode(array('msg'=>'操作成功','d'=>($d),'b'=>$u['id'],'success'=>true));
  3390. }
  3391. }
  3392. /**
  3393. $post = $this->input->post(NULL, TRUE);
  3394. if(isset($post['type']))
  3395. {
  3396. $type = $this->input->post('type');
  3397. $id = $this->input->post('id');
  3398. $u = $this->fullorder->read($id);
  3399. $rows = $this->fullorder->find_all('name = "'.$u['name'].'" or email = "'.$u['email'].'" or address = "'.$u['address'].'"','*','id desc');
  3400. if(count($rows)>1)
  3401. {
  3402. $this->db->trans_begin();
  3403. $fpdata=$rows[0]['fpdata'];//购买产品
  3404. $shouldmoney=$rows[0]['shouldmoney'];//购买应收金额
  3405. $budget=$rows[0]['budget'];//预估到帐金额
  3406. $cost=$rows[0]['cost'];//成本金额
  3407. $merge=$rows[0]['id'];
  3408. $d = array($rows[0]['id']);
  3409. for($i=1;$i<count($rows);$i++)
  3410. {
  3411. $fpdata=$fpdata.$rows[$i]['fpdata'];
  3412. $shouldmoney=$shouldmoney+$rows[$i]['shouldmoney'];
  3413. $budget=$budget+$rows[$i]['budget'];
  3414. $cost=$cost+$rows[$i]['cost'];
  3415. $d[] = $rows[$i]['id'];
  3416. $this->fullorder->save(array('merge'=>$rows[0]['id'],'mergeid'=>1),$rows[$i]['id']);
  3417. }
  3418. $this->fullorder->save(array('fpdata'=>$fpdata,'shouldmoney'=>$shouldmoney,'budget'=>$budget,'cost'=>$cost,'merge'=>$merge),$rows[0]['id']);
  3419. if ($this->db->trans_status() === FALSE)
  3420. {
  3421. $this->db->trans_commit();
  3422. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3423. }
  3424. else
  3425. {
  3426. $this->db->trans_commit();
  3427. echo json_encode(array('msg'=>'操作成功','d'=>($d),'b'=>$rows[0]['id'],'success'=>true));
  3428. }
  3429. }
  3430. }
  3431. **/
  3432. }
  3433. //评价管理
  3434. public function _evaluate()
  3435. {
  3436. $user = $this->user->get_api($_SESSION['api']);
  3437. if($user)
  3438. {
  3439. $fgshop = "";$sid = "";
  3440. $user = explode('|',trim($user['shop'],'|'));
  3441. foreach ($user as $value)
  3442. {
  3443. $fgshop .= " shop = ".$value." or";
  3444. $sid .= " id = ".$value." or";
  3445. }
  3446. }
  3447. $post = $this->input->post(NULL, TRUE);
  3448. if(isset($post['page']))
  3449. {
  3450. $page = $this->input->post('page',true);
  3451. $perpage = $this->input->post('perpage',true);
  3452. $shop = $this->input->post('shop',true);
  3453. $where = "1=1 and evaluate = 0 and (".rtrim($fgshop,'or').")";
  3454. if($shop)
  3455. {
  3456. $where .= " and shop = '$shop'";
  3457. }
  3458. //数据排序
  3459. $order_str = "id desc";
  3460. if(empty($page))
  3461. {
  3462. $start = 0;
  3463. $perpage = 1;
  3464. }
  3465. else
  3466. {
  3467. $start = ($page - 1)*$perpage;
  3468. }
  3469. //取得信息列表
  3470. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,operation',$order_str,$start,$perpage);
  3471. //格式化数据
  3472. foreach ($info_list as $key=>$value)
  3473. {
  3474. $shop = $this->shop->read($value['shop']);
  3475. $info_list[$key]['shop'] = $shop['shopname'];
  3476. $info_list[$key]['operation'] = "评价";
  3477. }
  3478. $total = $this->fullorder->find_count($where);
  3479. $pagenum = ceil($total/$perpage);
  3480. $over = $total-($start+$perpage);
  3481. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3482. echo json_encode($rows);exit;
  3483. }
  3484. $this->_Template('fullorder_evaluate',$this->data);
  3485. }
  3486. //订单消息
  3487. public function _state()
  3488. {
  3489. $user = $this->user->get_api($_SESSION['api']);
  3490. if($user)
  3491. {
  3492. $fgshop = "";$sid = "";
  3493. $user = explode('|',trim($user['shop'],'|'));
  3494. foreach ($user as $value)
  3495. {
  3496. $fgshop .= " shop = ".$value." or";
  3497. $sid .= " id = ".$value." or";
  3498. }
  3499. }
  3500. $post = $this->input->post(NULL, TRUE);
  3501. if(isset($post['page']))
  3502. {
  3503. $page = $this->input->post('page',true);
  3504. $perpage = $this->input->post('perpage',true);
  3505. $timetk = $this->input->post('timetk',true);
  3506. $timetj = $this->input->post('timetj',true);
  3507. $shop = $this->input->post('shop',true);
  3508. $expressstate = $this->input->post('expressstate',true);
  3509. $fs = $this->input->post('fs',true);
  3510. $state = $this->input->post('state',true);
  3511. $express = $this->input->post('express',true);
  3512. $review = $this->input->post('review',true);
  3513. $orderinfo = $this->input->post('orderinfo',true);
  3514. $number = $this->input->post('number',true);
  3515. $waybill = $this->input->post('waybill',true);
  3516. $xztime = $this->input->post('xztime',true);
  3517. $timetk = strtotime($timetk);
  3518. $timetj = strtotime($timetj);
  3519. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3520. if($timetk && $timetj)
  3521. {
  3522. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3523. }
  3524. if($xztime == 'librarytime')
  3525. {
  3526. $order_str = "librarytime desc";
  3527. }
  3528. else if($xztime == 'dtime')
  3529. {
  3530. $order_str = "dtime desc";
  3531. }
  3532. if($shop)
  3533. {
  3534. $where .= " and shop = '$shop'";
  3535. }
  3536. if($expressstate)
  3537. {
  3538. $where .= " and expressstate = '$expressstate'";
  3539. }
  3540. if($review)
  3541. {
  3542. $where .= " and review = '$review'";
  3543. }
  3544. if($fs)
  3545. {
  3546. if($fs == '2')
  3547. {
  3548. $where .= " and exstateerror != ''";
  3549. }
  3550. else
  3551. {
  3552. $where .= " and exstateerror = ''";
  3553. }
  3554. }
  3555. if($state)
  3556. {
  3557. $where .= " and state = '$state'";
  3558. }
  3559. if($express)
  3560. {
  3561. $where .= " and express = '$express'";
  3562. }
  3563. if($orderinfo)
  3564. {
  3565. $where .= " and orderinfo = '$orderinfo'";
  3566. }
  3567. if($number)
  3568. {
  3569. $where .= " and number = '$number'";
  3570. }
  3571. if($waybill)
  3572. {
  3573. $where .= " and waybill = '$waybill'";
  3574. }
  3575. if(empty($page))
  3576. {
  3577. $start = 0;
  3578. $perpage = 1;
  3579. }
  3580. else
  3581. {
  3582. $start = ($page - 1)*$perpage;
  3583. }
  3584. //取得信息列表
  3585. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,country,library,librarytime,express,waybill,content,orderremarks,exstateerror',$order_str,$start,$perpage);
  3586. //格式化数据
  3587. foreach ($info_list as $key=>$value)
  3588. {
  3589. $shop = $this->shop->read($value['shop']);
  3590. $info_list[$key]['shop'] = $shop['shopname'];
  3591. $country = $this->country->read($value['country']);
  3592. $info_list[$key]['country'] = $country['name'];
  3593. //$state = $this->typeclass->read($value['state']);
  3594. //$info_list[$key]['state'] = $state['title'];
  3595. if($value['library'] == 1)
  3596. {
  3597. $info_list[$key]['library'] = "未出库";
  3598. }
  3599. else if($value['library'] == 2)
  3600. {
  3601. $info_list[$key]['library'] = "已出库";
  3602. }
  3603. else if($value['library'] == 3)
  3604. {
  3605. $info_list[$key]['library'] = "已退库";
  3606. }
  3607. if($value['librarytime'] == '0')
  3608. {
  3609. $info_list[$key]['librarytime'] = '无';
  3610. }
  3611. else
  3612. {
  3613. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']);
  3614. }
  3615. $express = $this->express->read($value['express']);
  3616. $info_list[$key]['express'] = $express['servicename'];
  3617. }
  3618. $total = $this->fullorder->find_count($where);
  3619. $pagenum = ceil($total/$perpage);
  3620. $over = $total-($start+$perpage);
  3621. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3622. echo json_encode($rows);exit;
  3623. }
  3624. $notice = $this->notice->find_all("type = '1' and (".rtrim($fgshop,'or').")");
  3625. $this->data['notice'] = $notice;
  3626. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3627. $this->data['wlshop'] = $wlshop;
  3628. $this->data['express'] = $this->express->find_all();
  3629. $this->_Template('fullorder_state',$this->data);
  3630. }
  3631. //物流信息
  3632. public function _wl()
  3633. {
  3634. $user = $this->user->get_api($_SESSION['api']);
  3635. if($user)
  3636. {
  3637. $fgshop = "";$sid = "";
  3638. $user = explode('|',trim($user['shop'],'|'));
  3639. foreach ($user as $value)
  3640. {
  3641. $fgshop .= " shop = ".$value." or";
  3642. $sid .= " id = ".$value." or";
  3643. }
  3644. }
  3645. $post = $this->input->post(NULL, TRUE);
  3646. if(isset($post['page']))
  3647. {
  3648. $page = $this->input->post('page',true);
  3649. $perpage = $this->input->post('perpage',true);
  3650. $timetk = $this->input->post('timetk',true);
  3651. $timetj = $this->input->post('timetj',true);
  3652. $shop = $this->input->post('shop',true);
  3653. $expressstate = $this->input->post('expressstate',true);
  3654. $fs = $this->input->post('fs',true);
  3655. $state = $this->input->post('state',true);
  3656. $express = $this->input->post('express',true);
  3657. $orderinfo = $this->input->post('orderinfo',true);
  3658. $number = $this->input->post('number',true);
  3659. $waybill = $this->input->post('waybill',true);
  3660. $wlyc = $this->input->post('wlyc',true);
  3661. $wltype = $this->input->post('wltype',true);
  3662. $source = $this->input->post('source',true);
  3663. $xztime = $this->input->post('xztime',true);
  3664. $wlbz = $this->input->post('wlbz',true);
  3665. $timetk = strtotime($timetk);
  3666. $timetj = strtotime($timetj);
  3667. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3668. if($timetk && $timetj)
  3669. {
  3670. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3671. }
  3672. if($xztime == 'librarytime')
  3673. {
  3674. $order_str = "librarytime desc";
  3675. }
  3676. else if($xztime == 'dtime')
  3677. {
  3678. $order_str = "dtime desc";
  3679. }
  3680. else if ($xztime == 'wlfstime')
  3681. {
  3682. $order_str = "wlfstime desc";
  3683. }
  3684. if($shop)
  3685. {
  3686. $where .= " and shop = '$shop'";
  3687. }
  3688. if($fs)
  3689. {
  3690. if($fs == '1')
  3691. {
  3692. $where .= " and wlcontent != ''";
  3693. }
  3694. if($fs == '2')
  3695. {
  3696. $where .= " and wlerror != ''";
  3697. }
  3698. if($fs == '3')
  3699. {
  3700. $where .= " and wlcontent = '' and shouldmoney > 100";
  3701. }
  3702. else if($fs == '4')
  3703. {
  3704. $where .= " and wltype = '1'";
  3705. }
  3706. }
  3707. if($state)
  3708. {
  3709. $where .= " and state = '$state'";
  3710. }
  3711. if($express)
  3712. {
  3713. $where .= " and express = '$express'";
  3714. }
  3715. if($orderinfo)
  3716. {
  3717. $where .= " and orderinfo = '$orderinfo'";
  3718. }
  3719. if($number)
  3720. {
  3721. $where .= " and number = '$number'";
  3722. }
  3723. if($waybill)
  3724. {
  3725. $where .= " and waybill = '$waybill'";
  3726. }
  3727. if($wlbz)
  3728. {
  3729. $where .= " and wlbz like '%$wlbz%'";
  3730. }
  3731. if($wlyc!='')
  3732. {
  3733. $where .= " and wlyc = '$wlyc'";
  3734. }
  3735. if($wltype!='')
  3736. {
  3737. $where .= " and wltype = '$wltype'";
  3738. }
  3739. if($source)
  3740. {
  3741. if($source == 1)
  3742. {
  3743. $where .= " and source = '$source'";
  3744. }
  3745. else
  3746. {
  3747. $where .= " and source != '1'";
  3748. }
  3749. }
  3750. if($expressstate != '')
  3751. {
  3752. if($expressstate == 99)
  3753. {
  3754. $cxid = '';
  3755. $sjcc = $this->awlgx->find_all("time < '".(time()-3*24*3600)."' and exstate != 6",'number');
  3756. foreach ($sjcc as $v)
  3757. {
  3758. $cxid .= "number = '".$v['number']."' or ";
  3759. }
  3760. $where .= ' and ('.rtrim($cxid,'or ').')';
  3761. }
  3762. else
  3763. {
  3764. $where .= " and expressstate = '$expressstate'";
  3765. }
  3766. }
  3767. if(empty($page))
  3768. {
  3769. $start = 0;
  3770. $perpage = 1;
  3771. }
  3772. else
  3773. {
  3774. $start = ($page - 1)*$perpage;
  3775. }
  3776. //取得信息列表
  3777. $info_list = $this->fullorder->find_all($where,'id,orderinfo,number,country,library,librarytime,expressstate,express,waybill,wlbz,orderremarks,wlcontent,wlerror,excontent,wltype',$order_str,$start,$perpage);
  3778. //格式化数据
  3779. foreach ($info_list as $key=>$value)
  3780. {
  3781. $f = $this->fullorder->read($value['id']);
  3782. $info_list[$key]['number'] = "<p>".$value['number']."</p>"."<p>".$f['email']."</p>";
  3783. $country = $this->country->read($value['country']);
  3784. $info_list[$key]['country'] = "<p>".$country['name']."</p><p>".$f['phone']."</p>";
  3785. //$state = $this->typeclass->read($value['state']);
  3786. //$info_list[$key]['state'] = $state['title'];
  3787. if($value['library'] == 1)
  3788. {
  3789. $info_list[$key]['library'] = "未出库";
  3790. }
  3791. else if($value['library'] == 2)
  3792. {
  3793. $info_list[$key]['library'] = "已出库";
  3794. }
  3795. else if($value['library'] == 3)
  3796. {
  3797. $info_list[$key]['library'] = "已退库";
  3798. }
  3799. if($value['librarytime'] == '0')
  3800. {
  3801. $info_list[$key]['librarytime'] = '无';
  3802. }
  3803. else
  3804. {
  3805. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']).'<br>'.$f['shouldmoney'];
  3806. }
  3807. if($value['expressstate'] == 0)
  3808. {
  3809. $info_list[$key]['expressstate'] = "无信息";
  3810. }
  3811. else if($value['expressstate'] == 2)
  3812. {
  3813. $info_list[$key]['expressstate'] = "已取件";
  3814. }
  3815. else if($value['expressstate'] == 3)
  3816. {
  3817. $info_list[$key]['expressstate'] = "在途中";
  3818. }
  3819. /**
  3820. else if($value['expressstate'] == 4)
  3821. {
  3822. $info_list[$key]['expressstate'] = "到达目的地国".$value['expressstate'];
  3823. }
  3824. **/
  3825. else if($value['expressstate'] == 4 || $value['expressstate'] == 5)
  3826. {
  3827. $info_list[$key]['expressstate'] = "即将派送";
  3828. }
  3829. else if($value['expressstate'] == 6)
  3830. {
  3831. $info_list[$key]['expressstate'] = "已签收";
  3832. }
  3833. else if($value['expressstate'] == 1)
  3834. {
  3835. $info_list[$key]['expressstate'] = "派送异常";
  3836. }
  3837. $express = $this->express->read($value['express']);
  3838. $info_list[$key]['express'] = $express['servicename'];
  3839. if($value['wltype'] == '0')
  3840. {
  3841. $info_list[$key]['wltype'] = "<p class='ckn'><b class='wlfsxx' data-id='".$value['id']."' data-q='1'>禁止发送</b></p>";
  3842. }
  3843. else
  3844. {
  3845. $info_list[$key]['wltype'] = "<p class='ckn'><b class='wlfsxx' data-id='".$value['id']."' data-q='1'>允许发送</b></p>";
  3846. }
  3847. if($f['wlyc'] == '0')
  3848. {
  3849. $info_list[$key]['wltype'] .= "<p class='yc'><b class='wlyc' data-id='".$value['id']."' data-t='1'>加入异常处理中</b></p>";
  3850. }
  3851. else if($f['wlyc'] == '1')
  3852. {
  3853. $info_list[$key]['wltype'] .= "<p class='yc'><b class='wlyc' data-id='".$value['id']."' data-t='2'>移入异常已处理</b></p>";
  3854. $info_list[$key]['wltype'] .= "<p class='yc'><b class='ycyc' data-id='".$value['id']."' data-c='2'>移出异常处理中</b></p>";
  3855. }
  3856. else if($f['wlyc'] == '2')
  3857. {
  3858. $info_list[$key]['wltype'] .= "<p><b>异常已处理</b></p>";
  3859. }
  3860. if(stripos($value['excontent'],'<br />') !== false)
  3861. {
  3862. $excontent = explode('<br />',$value['excontent']);
  3863. $info_list[$key]['excontent'] = '<i class="method fa fa-list-ul" data-t="'.$value['excontent'].'"></i> '.$excontent[0];
  3864. }
  3865. }
  3866. $total = $this->fullorder->find_count($where);
  3867. $pagenum = ceil($total/$perpage);
  3868. $over = $total-($start+$perpage);
  3869. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$where);
  3870. echo json_encode($rows);exit;
  3871. }
  3872. if(isset($post['q']))
  3873. {
  3874. $id = $this->input->post('id',true);
  3875. $f = $this->fullorder->read($id);
  3876. $wl = ($f['wltype']=='0')?1:0;
  3877. $wltitle = ($f['wltype']=='0')?'已禁发送':'已允发送';
  3878. if($this->fullorder->save(array('wltype'=>$wl),$id))
  3879. {
  3880. echo json_encode(array('msg'=>'ckn','id'=>$id,'wltitle'=>$wltitle,'success'=>true));exit;
  3881. }
  3882. else
  3883. {
  3884. echo json_encode(array('msg'=>'失败,请重试','id'=>$id,'wltitle'=>$wltitle,'success'=>false));exit;
  3885. }
  3886. }
  3887. if(isset($post['t']))
  3888. {
  3889. $id = $this->input->post('id',true);
  3890. $f = $this->fullorder->read($id);
  3891. $t = $this->input->post('t',true);
  3892. $yc = ($f['wlyc']=='0')?1:2;
  3893. $yctitle = ($f['wlyc']=='0')?'移入成功':'异常已处理';
  3894. if($this->fullorder->save(array('wlyc'=>$yc),$id))
  3895. {
  3896. echo json_encode(array('msg'=>'yc','id'=>$id,'wltitle'=>$yctitle,'success'=>true));exit;
  3897. }
  3898. else
  3899. {
  3900. echo json_encode(array('msg'=>'失败,请重试','id'=>$id,'wltitle'=>$yctitle,'success'=>false));exit;
  3901. }
  3902. }
  3903. if(isset($post['c']))
  3904. {
  3905. $id = $this->input->post('id',true);
  3906. $f = $this->fullorder->read($id);
  3907. $t = $this->input->post('t',true);
  3908. $yc = 0;
  3909. $yctitle = '移出成功';
  3910. if($this->fullorder->save(array('wlyc'=>$yc),$id))
  3911. {
  3912. echo json_encode(array('msg'=>'yc','id'=>$id,'wltitle'=>$yctitle,'success'=>true));exit;
  3913. }
  3914. else
  3915. {
  3916. echo json_encode(array('msg'=>'失败,请重试','id'=>$id,'wltitle'=>$yctitle,'success'=>false));exit;
  3917. }
  3918. }
  3919. $notice = $this->notice->find_all("type = '2' and (".rtrim($fgshop,'or').")");
  3920. $this->data['notice'] = $notice;
  3921. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3922. $this->data['wlshop'] = $wlshop;
  3923. $this->data['express'] = $this->express->find_all();
  3924. $this->_Template('fullorder_wl',$this->data);
  3925. }
  3926. //审核订单
  3927. public function _review()
  3928. {
  3929. $user = $this->user->get_api($_SESSION['api']);
  3930. if($user)
  3931. {
  3932. $fgshop = "";$sid = "";
  3933. $user = explode('|',trim($user['shop'],'|'));
  3934. foreach ($user as $value)
  3935. {
  3936. $sid .= " id = ".$value." or";
  3937. $fgshop .= " shop = ".$value." or";
  3938. }
  3939. $fgshop = " and (".rtrim($fgshop,'or').")";
  3940. }
  3941. $post = $this->input->post(NULL, TRUE);
  3942. if(isset($post['page']))
  3943. {
  3944. $page = $this->input->post('page',true);
  3945. $perpage = $this->input->post('perpage',true);
  3946. $source = $this->input->post('source',true);
  3947. $warehouse = $this->input->post('warehouse',true);
  3948. $express = $this->input->post('express',true);
  3949. $orderremarks = $this->input->post('orderremarks',true);
  3950. $shop = $this->input->post('shop',true);
  3951. $review = $this->input->post('review',true);
  3952. $orderinfo = $this->input->post('orderinfo',true);
  3953. $shipremarks = $this->input->post('shipremarks',true);
  3954. $number = $this->input->post('number',true);
  3955. $timetk = $this->input->post('timetk',true);
  3956. $timetj = $this->input->post('timetj',true);
  3957. $timetk = strtotime($timetk);
  3958. $timetj = strtotime($timetj);
  3959. $where = "mergeid = 0 and state = '207'".$fgshop;
  3960. if($timetk && $timetj)
  3961. {
  3962. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3963. }
  3964. if($source)
  3965. {
  3966. if($source == '2d')
  3967. {
  3968. $where .= " and source >= '2'";
  3969. }
  3970. else
  3971. {
  3972. $where .= " and source = '$source'";
  3973. }
  3974. }
  3975. if($review)
  3976. {
  3977. $where .= " and review = '$review'";
  3978. }
  3979. else
  3980. {
  3981. $where .= "and review <= '2'";
  3982. // $where .= " and ((review = '2' and source = '1') or (review = '1' and source >= '2'))";
  3983. }
  3984. if($shop)
  3985. {
  3986. $where .= " and shop = '$shop'";
  3987. }
  3988. if($warehouse)
  3989. {
  3990. $where .= " and type = '$warehouse'";
  3991. }
  3992. if($express)
  3993. {
  3994. $where .= " and express = '$express'";
  3995. }
  3996. if($orderremarks)
  3997. {
  3998. $where .= " and orderremarks like '%$orderremarks%'";
  3999. }
  4000. if($orderinfo)
  4001. {
  4002. $where .= " and orderinfo = '$orderinfo'";
  4003. }
  4004. if($number)
  4005. {
  4006. $where .= " and number = '$number'";
  4007. }
  4008. if($shipremarks)
  4009. {
  4010. $where .= " and shipremarks like '%$shipremarks%'";
  4011. }
  4012. //数据排序
  4013. $order_str = "id desc";
  4014. if(empty($page))
  4015. {
  4016. $start = 0;
  4017. $perpage = 1;
  4018. }
  4019. else
  4020. {
  4021. $start = ($page - 1)*$perpage;
  4022. }
  4023. //取得信息列表
  4024. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,client,express,buytime,shouldmoney,review,orderremarks');
  4025. //格式化数据
  4026. foreach ($info_list as $key=>$value)
  4027. {
  4028. $lr = $this->fullorder->read($value['id']);
  4029. $shop = $this->shop->read($value['shop']);
  4030. $info_list[$key]['shop'] = $shop['shopname'];
  4031. $warehouse = $this->warehouse->read($value['type']);
  4032. $info_list[$key]['type'] = $warehouse['title'];
  4033. $express = $this->express->read($value['express']);
  4034. $info_list[$key]['express'] = $express['servicename'];
  4035. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  4036. if($value['review'] == 1)
  4037. {
  4038. $info_list[$key]['review'] = "未送审";
  4039. }
  4040. else if($value['review'] == 2)
  4041. {
  4042. $info_list[$key]['review'] = "待审核";
  4043. }
  4044. else if($value['review'] == 3)
  4045. {
  4046. $info_list[$key]['review'] = "不通过";
  4047. }
  4048. else if($value['review'] == 4)
  4049. {
  4050. $info_list[$key]['review'] = "取消重审";
  4051. }
  4052. else if($value['review'] == 5)
  4053. {
  4054. $info_list[$key]['review'] = "审核通过";
  4055. }
  4056. else if($value['review'] == 6)
  4057. {
  4058. $info_list[$key]['review'] = "自动通过";
  4059. }
  4060. /**
  4061. $info_list[$key]['library'] = "";
  4062. if($value['review'] == 1)
  4063. {
  4064. $info_list[$key]['library'] = "<p><b class='focz' data-type='6' data-id='".$value['id']."'>审核通过</b></p>";
  4065. }
  4066. if($value['review'] == 2)
  4067. {
  4068. $info_list[$key]['library'] = "<p><b class='focz' data-type='5' data-id='".$value['id']."'>审核通过</b></p><p><b class='focz' data-type='3' data-id='".$value['id']."'>不通过</b></p>";
  4069. }
  4070. else if($value['review'] == 3)
  4071. {
  4072. $info_list[$key]['library'] = "<p><b class='fullorderreview' data-type='5' data-id='".$value['id']."'>审核通过</b></p>";
  4073. }
  4074. else if($value['review'] == 5)
  4075. {
  4076. $info_list[$key]['library'] = "<p><b class='fullorderreview' data-type='3' data-id='".$value['id']."'>不通过</b></p>";
  4077. }
  4078. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$lr['currencytitle'];
  4079. $lr['hl'] = $lr['hl']==0?6.71:$lr['hl'];
  4080. $cost = $lr['cost']/$lr['hl'];
  4081. $currencytitle = $lr['budget']-$lr['refundj']-$cost-$lr['expressmoney'];
  4082. $info_list[$key]['currencytitle'] = sprintf("%.2f",$currencytitle).' '.$lr['currencytitle'];
  4083. **/
  4084. }
  4085. $total = $this->fullorder->find_count($where);
  4086. $pagenum = ceil($total/$perpage);
  4087. $over = $total-($start+$perpage);
  4088. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4089. echo json_encode($rows);exit;
  4090. }
  4091. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4092. $this->data['shop'] = $wlshop;
  4093. $this->_Template('fullorder_review',$this->data);
  4094. }
  4095. public function _wlbz($arg_array)
  4096. {
  4097. $post = $this->input->post(NULL, TRUE);
  4098. if(isset($post['id']))
  4099. {
  4100. $id = $this->input->post('id',true);
  4101. $post['wlbz'] = $this->input->post('wlbz',true);
  4102. if($post['wlbz'] == '')
  4103. {
  4104. echo json_encode(array('msg'=>'备注不能为空','success'=>false));exit;
  4105. }
  4106. if($this->fullorder->save($post,$id))
  4107. {
  4108. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  4109. }
  4110. else
  4111. {
  4112. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  4113. }
  4114. }
  4115. $arg_array = $arg_array[0];
  4116. $fullorder = $this->fullorder->read($arg_array);
  4117. $this->data['fullorder'] = $fullorder;
  4118. $this->_Template('fullorder_wlbz',$this->data);
  4119. }
  4120. //导出资金统计excel
  4121. public function _fmexcel()
  4122. {
  4123. $user = $this->user->get_api($_SESSION['api']);
  4124. if($user)
  4125. {
  4126. $fgshop = "";$sid = "";
  4127. $user = explode('|',trim($user['shop'],'|'));
  4128. foreach ($user as $value)
  4129. {
  4130. $fgshop .= " shop = ".$value." or";
  4131. $sid .= " id = ".$value." or";
  4132. }
  4133. }
  4134. if(isset($_GET['excel']))
  4135. {
  4136. $timetk = $this->input->get('timetk',true);
  4137. $timetj = $this->input->get('timetj',true);
  4138. $shop = $this->input->get('shop',true);
  4139. $source = $this->input->get('source',true);
  4140. $state = $this->input->get('state',true);
  4141. $type = $this->input->get('type',true);
  4142. $orderinfo = $this->input->get('orderinfo',true);
  4143. $user = $this->input->get('user',true);
  4144. $name = $this->input->get('name',true);
  4145. $timetk = strtotime($timetk);
  4146. $timetj = strtotime($timetj);
  4147. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  4148. if($timetk && $timetj)
  4149. {
  4150. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  4151. }
  4152. if($shop)
  4153. {
  4154. $where .= " and shop = '$shop'";
  4155. }
  4156. if($source)
  4157. {
  4158. $where .= " and source = '$source'";
  4159. }
  4160. if($state)
  4161. {
  4162. if($state == 1)
  4163. {
  4164. $where .= " and state = '$state'";
  4165. }
  4166. }
  4167. if($type)
  4168. {
  4169. $where .= " and type = '$type'";
  4170. }
  4171. if($orderinfo)
  4172. {
  4173. $where .= " and orderinfo = '$orderinfo'";
  4174. }
  4175. if($user)
  4176. {
  4177. $where .= " and user = '$user'";
  4178. }
  4179. if($name)
  4180. {
  4181. $where .= " and name = '$name'";
  4182. }
  4183. //取得信息列表
  4184. $info_list = $this->fullorder->find_all($where,'id,shop,user,number,orderinfo,client,country,dtime,ftime,express,waybill,shouldmoney,refund,currency,budget,fpdata,hl,currencytitle');
  4185. //格式化数据
  4186. $i = 1;$shouldmoney = 0;$refund = 0;$budget = 0;$currency = 0;$hl=1;
  4187. foreach ($info_list as $key=>$value)
  4188. {
  4189. $info_list[$key]['id'] = $i;
  4190. if($value['currencytitle'] != "CNY")
  4191. {
  4192. $hl=$value['hl'];
  4193. }
  4194. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  4195. $budget=$budget+($value['budget']*$hl);
  4196. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  4197. $refund=$refund+($value['refund']*$hl);
  4198. $shop = $this->shop->read($value['shop']);
  4199. $info_list[$key]['shop'] = $shop['shopname'];
  4200. $info_list[$key]['user'] = $shop['shopuser'];
  4201. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  4202. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  4203. $country = $this->country->read($value['country']);
  4204. $info_list[$key]['country'] = $country['name'];
  4205. $express = $this->express->read($value['express']);
  4206. $info_list[$key]['express'] = $express['servicename'];
  4207. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  4208. $info_list[$key]['refund'] = $value['refund'].' '.$value['currencytitle'];
  4209. $info_list[$key]['budget'] = $value['budget'].' '.$value['currencytitle'];
  4210. $info_list[$key]['currency'] = sprintf("%.2f",$value['shouldmoney']-$value['budget']).' '.$value['currencytitle'];
  4211. $fpdata = array();
  4212. if(stripos($value['fpdata'],';') !== false)
  4213. {
  4214. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  4215. foreach ($fpdata as $ke=>$va)
  4216. {
  4217. $v = explode('|',rtrim($va,'|'));
  4218. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  4219. }
  4220. }
  4221. $info_list[$key]['fpdata'] = $fpdata;
  4222. $i++;
  4223. }
  4224. $data = array($shouldmoney.' CNY',$refund.' CNY',$currency.' CNY',$budget.' CNY');
  4225. $title = "订单资金信息";
  4226. $titlename = "<table border=1>
  4227. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  4228. <tr>
  4229. <td>NO.</td>
  4230. <td>店铺</td>
  4231. <td>负责人</td>
  4232. <td>编号</td>
  4233. <td>订单号</td>
  4234. <td>客户姓名</td>
  4235. <td>国家</td>
  4236. <td>订单日期</td>
  4237. <td>发货日期</td>
  4238. <td>快递公司</td>
  4239. <td>运单号</td>
  4240. <td>订单金额</td>
  4241. <td>退款金额</td>
  4242. <td>手续费</td>
  4243. <td>预估金额</td>
  4244. <td>
  4245. <table border=1>
  4246. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  4247. <tr>
  4248. <td>产品</td>
  4249. <td>条数</td>
  4250. <td>数量</td>
  4251. </tr>
  4252. </table>
  4253. </td>
  4254. <td>总条数</td>
  4255. </tr>
  4256. </table>";
  4257. $filename = $title.".xls";
  4258. $tail = "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>合计:</td><td>".$data[0]."</td><td>".$data[1]."</td><td>".$data[2]."</td><td>".$data[3]."</td></tr>\n";
  4259. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  4260. }
  4261. }
  4262. //导出订单excel
  4263. public function _fdexcel()
  4264. {
  4265. if(isset($_GET['excel']))
  4266. {
  4267. $page = $this->input->post('page',true);
  4268. $perpage = $this->input->post('perpage',true);
  4269. $timetk = $this->input->post('timetk',true);
  4270. $timetj = $this->input->post('timetj',true);
  4271. $shop = $this->input->post('shop',true);
  4272. $source = $this->input->post('source',true);
  4273. $state = $this->input->post('state',true);
  4274. $review = $this->input->post('review',true);
  4275. $express = $this->input->post('express',true);
  4276. $orderinfo = $this->input->post('orderinfo',true);
  4277. $user = $this->input->post('user',true);
  4278. $name = $this->input->post('name',true);
  4279. $waybill = $this->input->post('waybill',true);
  4280. $timetk = strtotime($timetk);
  4281. $timetj = strtotime($timetj);
  4282. $where = "1=1 and mergeid = 0";
  4283. if($timetk && $timetj)
  4284. {
  4285. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  4286. }
  4287. if($shop)
  4288. {
  4289. $where .= " and shop = '$shop'";
  4290. }
  4291. if($source)
  4292. {
  4293. $where .= " and source = '$source'";
  4294. }
  4295. if($state)
  4296. {
  4297. $where .= " and state = '$state'";
  4298. }
  4299. if($review)
  4300. {
  4301. $where .= " and review = '$review'";
  4302. }
  4303. if($express)
  4304. {
  4305. $where .= " and express = '$express'";
  4306. }
  4307. if($orderinfo)
  4308. {
  4309. $where .= " and orderinfo = '$orderinfo'";
  4310. }
  4311. if($user)
  4312. {
  4313. $where .= " and user = '$user'";
  4314. }
  4315. if($name)
  4316. {
  4317. $where .= " and name = '$name'";
  4318. }
  4319. if($waybill)
  4320. {
  4321. $where .= " and waybill = '$waybill'";
  4322. }
  4323. //取得信息列表
  4324. $info_list = $this->fullorder->find_all($where,'id,shop,number,orderinfo,source,client,name,address,city,zipcode,province,country,phone,dtime,ftime,state,shouldmoney,express,waybill,orderremarks,clientremarks,fpdata,hl,currencytitle');
  4325. //格式化数据
  4326. $i = 1;$shouldmoney = 0;$hl=1;
  4327. foreach ($info_list as $key=>$value)
  4328. {
  4329. $info_list[$key]['id'] = $i;
  4330. if($value['source'] == 1)
  4331. {
  4332. $info_list[$key]['source'] = "线下订单";
  4333. }
  4334. else if($value['source'] == 2)
  4335. {
  4336. $info_list[$key]['source'] = "PC订单";
  4337. }
  4338. else if($value['source'] == 3)
  4339. {
  4340. $info_list[$key]['source'] = "手机订单";
  4341. }
  4342. if($value['currencytitle'] != "CNY")
  4343. {
  4344. $hl=$value['hl'];
  4345. }
  4346. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  4347. $shop = $this->shop->read($value['shop']);
  4348. $info_list[$key]['shop'] = $shop['shopname'];
  4349. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  4350. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  4351. $state = $this->typeclass->read($value['state']);
  4352. $info_list[$key]['state'] = $state['title'];
  4353. $country = $this->country->read($value['country']);
  4354. $info_list[$key]['country'] = $country['name'];
  4355. $express = $this->express->read($value['express']);
  4356. $info_list[$key]['express'] = $express['servicename'];
  4357. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  4358. $fpdata = array();
  4359. if(stripos($value['fpdata'],';') !== false)
  4360. {
  4361. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  4362. foreach ($fpdata as $ke=>$va)
  4363. {
  4364. $v = explode('|',rtrim($va,'|'));
  4365. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  4366. }
  4367. }
  4368. $info_list[$key]['fpdata'] = $fpdata;
  4369. $i++;
  4370. }
  4371. $data = array($shouldmoney.' CNY');
  4372. $title = "订单信息表";
  4373. $titlename = "<table border=1>
  4374. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  4375. <tr>
  4376. <td>NO.</td>
  4377. <td>店铺</td>
  4378. <td>编号</td>
  4379. <td>订单号</td>
  4380. <td>订单类型</td>
  4381. <td>客户姓名</td>
  4382. <td>收件人名称</td>
  4383. <td>收货人地址</td>
  4384. <td>城市</td>
  4385. <td>邮编</td>
  4386. <td>州</td>
  4387. <td>国家</td>
  4388. <td>收件电话</td>
  4389. <td>订单日期</td>
  4390. <td>发货日期</td>
  4391. <td>订单状态</td>
  4392. <td>订单金额</td>
  4393. <td>快递公司</td>
  4394. <td>运单号</td>
  4395. <td>订单备注</td>
  4396. <td>客户备注</td>
  4397. <td>
  4398. <table border=1>
  4399. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  4400. <tr>
  4401. <td>产品</td>
  4402. <td>条数</td>
  4403. <td>数量</td>
  4404. </tr>
  4405. </table>
  4406. </td>
  4407. <td>总条数</td>
  4408. </tr>
  4409. </table>";
  4410. $filename = $title.".xls";
  4411. $tail = "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>合计:</td><td>".$data[0]."</td></tr>\n";
  4412. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  4413. }
  4414. }
  4415. public function _black()
  4416. {
  4417. $post = $this->input->post(NULL, TRUE);
  4418. if(isset($post['bd']))
  4419. {
  4420. $bd = $this->input->post('bd',true);
  4421. $rows = $this->fullorder->read($bd);
  4422. $post['shop'] = $rows['shop'];
  4423. $post['source'] = 1;
  4424. $post['name'] = $rows['client'];
  4425. $post['email'] = $rows['email'];
  4426. $post['phone'] = $rows['phone'];
  4427. $post['country'] = $rows['country'];
  4428. $post['money'] = $rows['shouldmoney'];
  4429. $post['num'] = 1;
  4430. $post['time'] = $rows['dtime'];
  4431. $post['province'] = $rows['province'];
  4432. $post['city'] = $rows['city'];
  4433. $post['street'] = $rows['street'];
  4434. $post['address'] = $rows['address'];
  4435. $post['address2'] = $rows['address2'];
  4436. $post['zipcode'] = $rows['zipcode'];
  4437. $post['type'] = 2;
  4438. if($this->customer->insert($post))
  4439. {
  4440. $this->fullorder->save(array('black'=>1),$bd);
  4441. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  4442. }
  4443. else
  4444. {
  4445. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4446. }
  4447. }
  4448. }
  4449. public function _ryf()
  4450. {
  4451. $post = $this->input->post(NULL, TRUE);
  4452. if(isset($post['bd']))
  4453. {
  4454. $bd = $this->input->post('bd',true);
  4455. $d = $this->fullorder->read($bd);
  4456. if($d['state'] == 207 || $d['state'] == 207)//订单状态为等待发货或等待部分发货才可更改为允许发货
  4457. {
  4458. if($d['print'] < 3)//打印状态为未打印
  4459. {
  4460. $print = 1;//未打印
  4461. $libraryconfirm = 1;//不允许出库
  4462. $a = "订单未打印,";
  4463. }
  4464. else//已打印订单
  4465. {
  4466. $libraryconfirm = 2;//允许出库
  4467. $a = "";
  4468. }
  4469. if($this->fullorder->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  4470. {
  4471. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  4472. }
  4473. else
  4474. {
  4475. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4476. }
  4477. }
  4478. if($this->fullorder->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  4479. {
  4480. echo json_encode(array('msg'=>'操作失败!订单未非发货状态','success'=>false));exit;
  4481. }
  4482. else
  4483. {
  4484. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4485. }
  4486. }
  4487. }
  4488. public function _fsstate()
  4489. {
  4490. $post = $this->input->post(NULL, TRUE);
  4491. if(isset($post['s']))
  4492. {
  4493. $id_arr = $this->input->post('s');
  4494. $id_arr = explode(',',$id_arr);
  4495. if(!$id_arr)
  4496. {
  4497. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  4498. }
  4499. foreach ($id_arr as $v)
  4500. {
  4501. $data = $this->fullorder->read($v);
  4502. $warehouse = $this->warehouse->read($data['type']);
  4503. $fs = $this->notice->get_ordertatus($data['state']);
  4504. if($fs)
  4505. {
  4506. $ck = $this->_email($fs['content'],$data,$warehouse['company']);
  4507. if($ck == 1)
  4508. {
  4509. $this->fullorder->save(array('fscontent'=>date('Y-m-d H:i:s',time()).'已发送:'.$fs['title'].' - '),$v);
  4510. }
  4511. }
  4512. }
  4513. echo json_encode(array('msg'=>'发送完成!','success'=>true));exit;
  4514. }
  4515. }
  4516. public function _power()
  4517. {
  4518. $user = $this->user->get_api($_SESSION['api']);
  4519. $post = $this->input->post(NULL, TRUE);
  4520. if(isset($post['id']))
  4521. {
  4522. $id = $this->input->post('id',true);
  4523. $fullorder = $this->fullorder->read($id);
  4524. $express = $this->express->read($fullorder['express']);
  4525. $warehouse = $this->warehouse->read($fullorder['type']);
  4526. if(($warehouse['zd'] == '1' || stripos($fullorder['whlabel'],'z|') !== false) && $fullorder['library'] == '2')
  4527. {
  4528. echo json_encode(array('msg'=>'需要先退库释放库存后才可重置!','success'=>false));exit;
  4529. }
  4530. /**
  4531. if($fullorder['print'] == '3' && isset($express['iscode']) && ($express['iscode'] == 'ARAMEX' || $express['iscode'] == 'TOLL' || $express['iscode'] == 'FEDEX'))
  4532. {
  4533. $lj = $this->ali->get_lj($fullorder['number'],2,'订单修改');
  4534. if($lj != '1' && $lj != '订单不存在')
  4535. {
  4536. echo json_encode(array('msg'=>$lj,'success'=>false));exit;
  4537. }
  4538. }
  4539. **/
  4540. $warehouse = $this->warehouse->read($fullorder['warehouse']);
  4541. $typeclass = $this->typeclass->read($fullorder['state']);
  4542. $express = $this->express->read($fullorder['express']);
  4543. $printtype = array(1=>'运单',2=>'发货单',3=>'不打印单据');
  4544. $teset['number']=$fullorder['number'];
  4545. $teset['orderinfo']=$fullorder['orderinfo'];
  4546. $teset['shop']=$fullorder['shop'];
  4547. $teset['user']=$user['userid'];
  4548. $teset['ip']=$this->input->ip_address();
  4549. $teset['time']=time();
  4550. $teset['warehouse']=(isset($warehouse['title']))?$warehouse['title']:'未选择';
  4551. $teset['state']=(isset($typeclass['title']))?$typeclass['spare']:'未选择';
  4552. $teset['express']=(isset($express['title']))?$express['servicename']:'未选择';
  4553. $teset['printtype']=(isset($printtype[$fullorder['printtype']]))?$printtype[$fullorder['printtype']]:'未选择';
  4554. $teset['reviewtime']=($fullorder['reviewtime'] > '0')?date('Y-m-d H:i:s',$fullorder['reviewtime']):'无';
  4555. $teset['printtime']=($fullorder['printtime'] > '0')?date('Y-m-d H:i:s',$fullorder['printtime']):'无';
  4556. $teset['librarytime']=($fullorder['librarytime'] > '0')?date('Y-m-d H:i:s',$fullorder['librarytime']):'无';
  4557. $teset['shipremarks']=$fullorder['shipremarks'];
  4558. $teset['fpdata']=$fullorder['fpdata'];
  4559. $teset['oldwaybill']=$fullorder['oldwaybill'];
  4560. $teset['oldprinttime']=$fullorder['oldprinttime'];
  4561. if($fullorder['printtype'] == 1)
  4562. {
  4563. if($fullorder['waybill'] != '' && stripos($fullorder['oldwaybill'],$fullorder['waybill']) === false)
  4564. {
  4565. $teset['oldwaybill'] .= '-'.date('Ymd',$fullorder['printtime']).'/'.$fullorder['waybill'];
  4566. $teset['oldprinttime'] .= '-'.$fullorder['printtime'];
  4567. }
  4568. }
  4569. $review = ($fullorder['source']==1)?2:1;//线下单审核状态直接为待审核
  4570. if(!$this->fullreset->insert($teset))
  4571. {
  4572. echo json_encode(array('msg'=>'重置失败,请重试','success'=>true));exit;
  4573. }
  4574. if($this->fullorder->save(array('library'=>1,'librarytime'=>0,'libraryconfirm'=>2,'print'=>1,'printtime'=>0,'printnumber'=>0,'retreattime'=>0,'librarynot'=>'订单未打印,未审核或未通过','review'=>$review,'reviewtime'=>0,'state'=>207,'waybill'=>'','waybill2'=>'','waybillid'=>'','oldwaybill'=>$teset['oldwaybill'],'oldprinttime'=>$teset['oldprinttime'],'dlzemail'=>0,'yhs'=>0,'failed'=>''),$id))
  4575. {
  4576. $th_info = $this->retreatlogs->getInfoByNumber($fullorder['number']);
  4577. if(!empty($th_info)){
  4578. $this->retreatlogs->save(array('cz_time'=>time()),$th_info['id']);
  4579. }
  4580. echo json_encode(array('msg'=>'重置成功!如需再次提交,请先保存、再提交','success'=>true));exit;
  4581. }
  4582. else
  4583. {
  4584. echo json_encode(array('msg'=>'重置失败,请重试','success'=>false));exit;
  4585. }
  4586. }
  4587. }
  4588. public function _expresstype()
  4589. {
  4590. $post = $this->input->post(NULL, TRUE);
  4591. if(isset($post['id']))
  4592. {
  4593. $id = $this->input->post('id',true);
  4594. $data = $this->express->read($id);
  4595. echo json_encode(array('msg'=>$data['type'],'success'=>true));exit;
  4596. }
  4597. }
  4598. public function _email($content,$data,$shopname)
  4599. {
  4600. $express = $this->express->read($data['express']);
  4601. $t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
  4602. $h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['servicename'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
  4603. $content = str_replace($t,$h,$content);
  4604. $this->load->library('email');
  4605. $config['protocol'] = 'smtp';
  4606. $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
  4607. $config['smtp_port'] = 465;
  4608. $config['smtp_user'] = 'service@email.supernovahair.com';
  4609. $config['smtp_pass'] = 'LONGyihair374';
  4610. $config['smtp_crypto'] = 'ssl';
  4611. $config['crlf'] = "\r\n";
  4612. $config['newline'] = "\r\n";
  4613. $this->email->initialize($config);
  4614. $this->email->from('service@email.supernovahair.com',$shopname);
  4615. $this->email->to($data['email']);//收件
  4616. $this->email->subject('The product you purchased has a new progress');//标题
  4617. $this->email->message($content);//内容
  4618. if ( ! $this->email->send())
  4619. {
  4620. return 2;
  4621. }
  4622. else
  4623. {
  4624. return 1;
  4625. }
  4626. }
  4627. public function _error()
  4628. {
  4629. if(isset($_SESSION['api']))
  4630. {
  4631. $user = $this->user->get_api($_SESSION['api']);
  4632. $usp = $user;
  4633. $fgshop = "";$sid = "";
  4634. $user = explode('|',trim($user['shop'],'|'));
  4635. foreach ($user as $value)
  4636. {
  4637. $fgshop .= " shop = ".$value." or";
  4638. $sid .= " id = ".$value." or";
  4639. }
  4640. }
  4641. $post = $this->input->post(NULL, TRUE);
  4642. if(isset($post['page']))
  4643. {
  4644. $page = $this->input->post('page',true);
  4645. $perpage = $this->input->post('perpage',true);
  4646. $orderinfo = $this->input->post('orderinfo',true);
  4647. $waybill = $this->input->post('waybill',true);
  4648. $number = $this->input->post('number',true);
  4649. $timetk = $this->input->post('timetk',true);
  4650. $timetj = $this->input->post('timetj',true);
  4651. $timetk = strtotime($timetk);
  4652. $timetj = strtotime($timetj);
  4653. $where = "failed !='' and mergeid = 0 and print != 3 and (".rtrim($fgshop,'or').")";
  4654. if($orderinfo)
  4655. {
  4656. $where .= " and orderinfo = '$orderinfo'";
  4657. }
  4658. if($waybill)
  4659. {
  4660. $where .= " and waybill = '$waybill'";
  4661. }
  4662. if($number)
  4663. {
  4664. $where .= " and number = '$number'";
  4665. }
  4666. if($timetk && $timetj)
  4667. {
  4668. $timetj = $timetj+24*3600;
  4669. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4670. }
  4671. //数据排序
  4672. $order_str = "dtime desc";
  4673. if(empty($page))
  4674. {
  4675. $start = 0;
  4676. $perpage = 1;
  4677. }
  4678. else
  4679. {
  4680. $start = ($page - 1)*$perpage;
  4681. }
  4682. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,express,failed,operation',$order_str,$start,$perpage);
  4683. //格式化数据
  4684. foreach ($info_list as $key=>$value)
  4685. {
  4686. $ud = $this->fullorder->read($value['id']);
  4687. $shop = $this->shop->read($value['shop']);
  4688. $info_list[$key]['shop'] = $shop['shopname'];
  4689. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullorder/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'>".$value['orderinfo']."<p>";
  4690. $warehouse = $this->warehouse->read($value['type']);
  4691. $warehousetitle = $warehouse['title'];
  4692. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  4693. $info_list[$key]['type'] = $warehousetitle;
  4694. if($value['express'] != 0)
  4695. {
  4696. $express = $this->express->read($value['express']);
  4697. $expressservicename = $express['servicename'];
  4698. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  4699. $info_list[$key]['express'] = $expressservicename;
  4700. }
  4701. else
  4702. {
  4703. $info_list[$key]['express'] = "无";
  4704. }
  4705. $x = "";
  4706. if($ud['review'] >4 && $ud['print'] == 1)
  4707. {
  4708. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  4709. }
  4710. else
  4711. {
  4712. $x = "<p class='ckn'><b class='fojzof' data-type='9' data-id='".$value['id']."'>关闭</b></p>";
  4713. }
  4714. $info_list[$key]['operation'] = $x;
  4715. }
  4716. $total = $this->fullorder->find_count($where);
  4717. $pagenum = ceil($total/$perpage);
  4718. $over = $total-($start+$perpage);
  4719. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4720. echo json_encode($rows);exit;
  4721. }
  4722. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4723. $this->data['wlshop'] = $wlshop;
  4724. $this->data['express'] = $this->express->find_all();
  4725. $user = $this->user->get_api($_SESSION['api']);
  4726. $powerid = $this->power->read($user['power']);
  4727. $powertext = explode('|',trim($powerid['excelid'],'|'));
  4728. $pid = '';
  4729. foreach ($powertext as $v)
  4730. {
  4731. $pid .= " id = ".$v." or";
  4732. }
  4733. $fullorderexcel = $this->fullorderexcel->find_all("type = '100001' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  4734. $this->data['fullorderexcel'] = $fullorderexcel;
  4735. $this->_Template('fullorder_error',$this->data);
  4736. }
  4737. //验证地址
  4738. public function _yzaddress()
  4739. {
  4740. $post = $this->input->post(NULL, TRUE);
  4741. if(isset($post['address']))
  4742. {
  4743. $address = $this->input->post('address',true);
  4744. $address2 = $this->input->post('address2',true);
  4745. $city = $this->input->post('city',true);
  4746. $province = $this->input->post('province',true);
  4747. $zipcode = $this->input->post('zipcode',true);
  4748. $barcode = $this->usps->get_address(array('address'=>$address,'address2'=>$address2,'city'=>$city,'province'=>$province,'zipcode'=>$zipcode));
  4749. //$this->logic_ding->sendToDing("usps地址验证返回数据".$barcode);
  4750. echo $barcode;
  4751. }
  4752. }
  4753. //清除退货信息
  4754. public function _clearreturn()
  4755. {
  4756. $post = $this->input->post(NULL, TRUE);
  4757. if(isset($post['orderinfo']))
  4758. {
  4759. $orderinfo = $this->input->post('orderinfo',true);
  4760. $data = $this->fullorder->get_orderinfo($orderinfo);
  4761. $fu = 'fullorder';
  4762. if(!$data)
  4763. {
  4764. $data = $this->fullorder_smt->get_orderinfo($orderinfo);
  4765. $fu = 'fullorder_smt';
  4766. }
  4767. $this->$fu->save(array('library'=>'2','retreattime'=>'0','returndata'=>''),$data['id']);
  4768. echo json_encode(array('msg'=>'清除成功!','success'=>true));exit;
  4769. }
  4770. }
  4771. //订单退货
  4772. public function _return()
  4773. {
  4774. $post = $this->input->post(NULL, TRUE);
  4775. if(isset($post['orderinfo']))
  4776. {
  4777. $orderinfo = $this->input->post('orderinfo',true);
  4778. $data = $this->fullorder->get_orderinfo($orderinfo);
  4779. $fu = 'fullorder';
  4780. if(!$data)
  4781. {
  4782. $data = $this->fullorder_smt->get_orderinfo($orderinfo);
  4783. $fu = 'fullorder_smt';
  4784. }
  4785. $bctime = date('Ymd',time());
  4786. if($data['library'] != 2){
  4787. echo json_encode(array('msg'=>'此单不是出库状态,不允许退货','success'=>false));exit;
  4788. }
  4789. if($data['returndata'] != "")
  4790. {
  4791. echo json_encode(array('msg'=>'请求失败,已有Return Label信息!','success'=>false));exit;
  4792. }
  4793. $barcode = $this->usps->get_return($data);
  4794. // if(isset($barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription']))
  4795. // {
  4796. // echo json_encode(array('msg'=>$barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription'],'success'=>false));exit;
  4797. // }
  4798. // else if(isset($barcode['TrackingNumber']))
  4799. // {
  4800. // $pdf = $this->_pdf($barcode['ReturnLabel'],'t-'.$barcode['TrackingNumber'],$bctime);
  4801. // $read = 'PostalRouting:'.$barcode['PostalRouting'].' - TrackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['TrackingNumber'].'.pdf" target="_blank">'.$barcode['TrackingNumber'].'</a>';
  4802. // $this->$fu->save(array('returndata'=>$read),$data['id']);
  4803. // echo json_encode(array('msg'=>'生成Return Label成功!','data'=>$read,'success'=>true));exit;
  4804. // }
  4805. // else
  4806. // {
  4807. // echo json_encode(array('msg'=>'请求失败,请稍后重试!','cs'=>$barcode,'success'=>false));exit;
  4808. // }
  4809. if(isset($barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription']))
  4810. {
  4811. echo json_encode(array('msg'=>$barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription'],'success'=>false));exit;
  4812. }
  4813. else if(isset($barcode['trackingNumber']))
  4814. {
  4815. $pdf = $this->_pdf($barcode['returnLabelImage'],'t-'.$barcode['trackingNumber'],$bctime);
  4816. $read = 'PostalRouting:'.$barcode['routingInformation'].' - TrackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['trackingNumber'].'.pdf" target="_blank">'.$barcode['trackingNumber'].'</a>';
  4817. $this->$fu->save(array('returndata'=>$read),$data['id']);
  4818. echo json_encode(array('msg'=>'生成Return Label成功!','data'=>$read,'success'=>true));exit;
  4819. }
  4820. else
  4821. {
  4822. echo json_encode(array('msg'=>'请求失败,请稍后重试!'.json_encode($barcode),'cs'=>$barcode,'success'=>false));exit;
  4823. }
  4824. }
  4825. /**
  4826. $post = $this->input->post(NULL, TRUE);
  4827. if(isset($post['orderinfo']))
  4828. {
  4829. $orderinfo = $this->input->post('orderinfo',true);
  4830. $data = $this->fullorder->get_orderinfo($orderinfo);
  4831. $fu = 'fullorder';
  4832. if(!$data)
  4833. {
  4834. $data = $this->fullorder_smt->get_orderinfo($orderinfo);
  4835. $fu = 'fullorder_smt';
  4836. }
  4837. $bctime = date('Ymd',time());
  4838. if($data['returndata'] != "")
  4839. {
  4840. echo json_encode(array('msg'=>'请求失败,已有Return Label信息!','success'=>false));exit;
  4841. }
  4842. $barcode = $this->usps->get_return($data);
  4843. if(isset($barcode['error']['message']))
  4844. {
  4845. echo json_encode(array('msg'=>$barcode['error']['message'],'success'=>false));exit;
  4846. }
  4847. else if(isset($barcode['trackingNumber']))
  4848. {
  4849. $pdf = $this->_pdf($barcode['returnLabelImage'],'t-'.$barcode['trackingNumber'],$bctime);
  4850. $read = 'trackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['trackingNumber'].'.pdf" target="_blank">'.$barcode['trackingNumber'].'</a>';
  4851. $this->$fu->save(array('returndata'=>$read),$data['id']);
  4852. echo json_encode(array('msg'=>'生成Return Label成功!','data'=>$read,'success'=>true));exit;
  4853. }
  4854. else
  4855. {
  4856. echo json_encode(array('msg'=>'请求失败,请稍后重试!','cs'=>$barcode,'success'=>false));exit;
  4857. }
  4858. }**/
  4859. }
  4860. public function _pdf($pdf,$title,$bctime)
  4861. {
  4862. $pdf_path = './data/pdf/'.$bctime.'/';
  4863. $file_base64 = $pdf;
  4864. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4865. $file_base64 = base64_decode($file_base64);
  4866. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  4867. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  4868. return $bctime;
  4869. }
  4870. public function _find($find)
  4871. {
  4872. preg_match_all('/\d+/',$find,$n);
  4873. $a = '';
  4874. foreach($n[0] as $v)
  4875. {
  4876. $a .= $v;
  4877. }
  4878. return $a;
  4879. }
  4880. public function _dqpm()
  4881. {
  4882. if(isset($_SESSION['api']))
  4883. {
  4884. $user = $this->user->get_api($_SESSION['api']);
  4885. $usp = $user;
  4886. $fgshop = "";$sid = "";
  4887. $usersp = explode('|',trim($user['shop'],'|'));
  4888. foreach ($usersp as $value)
  4889. {
  4890. $fgshop .= " shop = ".$value." or";
  4891. $sid .= " id = ".$value." or";
  4892. }
  4893. }
  4894. $post = $this->input->post(NULL, TRUE);
  4895. if(isset($post['page']))
  4896. {
  4897. $timetk = $this->input->post('timetk',true);
  4898. $timetj = $this->input->post('timetj',true);
  4899. $timetk = strtotime($timetk);
  4900. $timetj = strtotime($timetj);
  4901. $where = "mergeid = 0 and (".rtrim($fgshop,'or').")";
  4902. if($timetk && $timetj)
  4903. {
  4904. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4905. }
  4906. //数据排序
  4907. $order_str = "dtime desc";
  4908. if(empty($page))
  4909. {
  4910. $start = 0;
  4911. $perpage = 1;
  4912. }
  4913. else
  4914. {
  4915. $start = ($page - 1)*$perpage;
  4916. }
  4917. $continentdata = '';
  4918. $continent = array();//陆地板块
  4919. $num = $this->fullorder->find_count($where);//订单总数量
  4920. $country = $this->country->find_all('1=1','id,continent,ename,zname');
  4921. foreach ($country as $k=>$v)
  4922. {
  4923. $tc = $this->typeclass->read($v['continent']);
  4924. $continent[$v['continent']] = array(0=>$tc['title'],1=>0,2=>'');
  4925. }
  4926. foreach ($country as $k=>$v)
  4927. {
  4928. $n = $this->fullorder->find_count($where.' and country = "'.$v['id'].'"');
  4929. $country[$k]['continent'] = $continent[$v['continent']][0];//此国家数量
  4930. $country[$k]['zname'] = '<a href="/fullorder/dqpmprovince/'.$v['id'].'/'.$timetk.'/'.$timetj.'">'.$v['zname'].'</a>';//此国家数量
  4931. $country[$k]['num'] = $n;//此国家数量
  4932. $country[$k]['zb'] = (sprintf("%.4f",$n/$num)*100).'%';//此国家占比
  4933. $continent[$v['continent']]['1'] += $n;//此洲数量增加;
  4934. }
  4935. array_multisort(array_column($continent, '1'), SORT_DESC, $continent);
  4936. array_multisort(array_column($country, 'num'), SORT_DESC, $country);
  4937. foreach ($continent as $k=>$v)
  4938. {
  4939. $continentdata .= $v['0'].' 总量:'.$v['1'].' 占比:'.(sprintf("%.4f",$v['1']/$num)*100).'%&nbsp;&nbsp; - &nbsp;&nbsp;';
  4940. }
  4941. echo json_encode(array('ewnr'=>$continentdata,'rows'=>$country,'total'=>count($country),'over'=>0,'pagenum'=>1,'success'=>true));exit;
  4942. }
  4943. $this->_Template('fullorder_dqpm',$this->data);
  4944. }
  4945. public function _dqpmprovince($arg_array)
  4946. {
  4947. if(isset($_SESSION['api']))
  4948. {
  4949. $user = $this->user->get_api($_SESSION['api']);
  4950. $usp = $user;
  4951. $fgshop = "";$sid = "";
  4952. $usersp = explode('|',trim($user['shop'],'|'));
  4953. foreach ($usersp as $value)
  4954. {
  4955. $fgshop .= " shop = ".$value." or";
  4956. $sid .= " id = ".$value." or";
  4957. }
  4958. }
  4959. $post = $this->input->post(NULL, TRUE);
  4960. if(isset($post['page']))
  4961. {
  4962. $country = $this->input->post('country',true);
  4963. $timetk = $this->input->post('timetk',true);
  4964. $timetj = $this->input->post('timetj',true);
  4965. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  4966. $province = array();
  4967. $city_list = $this->fullorder->find_all($where,'id,province');
  4968. $ToState = array('AL'=>'alabama','AK'=>'alaska','AZ'=>'arizona','AR'=>'arkansas','CA'=>'california','CO'=>'colorado','CT'=>'connecticut','DE'=>'delaware','FL'=>'florida','GA'=>'georgia','HI'=>'hawaii','ID'=>'idaho','IL'=>'illinois','IN'=>'indiana','IA'=>'iowa','KS'=>'kansas','KY'=>'kentucky','LA'=>'louisiana','ME'=>'maine','MD'=>'maryland','MA'=>'massachusetts','MI'=>'michigan','MN'=>'minnesota','MS'=>'mississippi','MO'=>'missouri','MT'=>'montana','NE'=>'nebraska','NV'=>'nevada','NH'=>'new hampshire','NJ'=>'new jersey','NM'=>'new mexico','NY'=>'new york','NC'=>'north carolina','ND'=>'north dakota','OH'=>'ohio','OK'=>'oklahoma','OR'=>'oregon','PA'=>'pennsylvania','RI'=>'rhode island','SC'=>'south carolina','SD'=>'south dakota','TN'=>'tennessee','TX'=>'texas','UT'=>'utah','VT'=>'vermont','VA'=>'virginia','WA'=>'washington','WV'=>'west virginia','WI'=>'wisconsin','WY'=>'wyoming','DC'=>'district of columbia','VI'=>'virgin islands');
  4969. foreach ($city_list as $k=>$v)
  4970. {
  4971. $v['province'] = strtoupper(trim($v['province'],' '));
  4972. if(isset($ToState[$v['province']]))
  4973. {
  4974. $v['province'] = $ToState[$v['province']];
  4975. }
  4976. if(!isset($province[$v['province']]))
  4977. {
  4978. $province[$v['province']] = array('id'=>$v['id'],'province'=>'<a href="/fullorder/ddpmdata/'.$country.'/'.$timetk.'/'.$timetj.'/'.strtoupper($v['province']).'">'.$v['province'].'</a>','num'=>0,'zb'=>'');
  4979. }
  4980. $province[$v['province']]['num'] += 1;
  4981. }
  4982. array_multisort(array_column($province, 'num'), SORT_DESC, $province);
  4983. $province = array_values($province);
  4984. foreach ($province as $k=>$v)
  4985. {
  4986. $province[$k]['zb'] = (sprintf("%.4f",$v['num']/count($city_list))*100).'%';
  4987. }
  4988. echo json_encode(array('rows'=>($province),'total'=>count($province),'over'=>0,'pagenum'=>1,'success'=>true));exit;
  4989. }
  4990. $this->data['arg_array'] = $arg_array;
  4991. $this->_Template('fullorder_dqpmprovince',$this->data);
  4992. }
  4993. public function _ddpmdata($arg_array)
  4994. {
  4995. $arg_array[3] = str_replace('%20',' ',$arg_array[3]);
  4996. if(isset($_SESSION['api']))
  4997. {
  4998. $user = $this->user->get_api($_SESSION['api']);
  4999. $usp = $user;
  5000. $fgshop = "";$sid = "";
  5001. $usersp = explode('|',trim($user['shop'],'|'));
  5002. foreach ($usersp as $value)
  5003. {
  5004. $fgshop .= " shop = ".$value." or";
  5005. $sid .= " id = ".$value." or";
  5006. }
  5007. }
  5008. $post = $this->input->post(NULL, TRUE);
  5009. if(isset($post['page']))
  5010. {
  5011. $page = $this->input->post('page',true);
  5012. $perpage = $this->input->post('perpage',true);
  5013. $province = $this->input->post('province',true);
  5014. $timetk = $this->input->post('timetk',true);;
  5015. $timetj = $this->input->post('timetj',true);;
  5016. $country = $this->input->post('country',true);;
  5017. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  5018. if($province)
  5019. {
  5020. $where .= " and province = '$province'";
  5021. }
  5022. $order_str = "dtime desc";
  5023. if(empty($page))
  5024. {
  5025. $start = 0;
  5026. $perpage = 1;
  5027. }
  5028. else
  5029. {
  5030. $start = ($page - 1)*$perpage;
  5031. }
  5032. $info_list = $this->fullorder->find_all($where,'id,orderinfo,number,shipremarks,shouldmoney',$order_str,$start,$perpage);
  5033. $total = $this->fullorder->find_count($where);
  5034. $pagenum = ceil($total/$perpage);
  5035. $over = $total-($start+$perpage);
  5036. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5037. echo json_encode($rows);exit;
  5038. }
  5039. $province = array();
  5040. $city_list = $this->fullorder->find_all("mergeid = 0 and dtime > '$arg_array[1]' and dtime < '$arg_array[2]' and country = '$arg_array[0]' and (".rtrim($fgshop,'or').")",'province');
  5041. $ToState = array('AL'=>'alabama','AK'=>'alaska','AZ'=>'arizona','AR'=>'arkansas','CA'=>'california','CO'=>'colorado','CT'=>'connecticut','DE'=>'delaware','FL'=>'florida','GA'=>'georgia','HI'=>'hawaii','ID'=>'idaho','IL'=>'illinois','IN'=>'indiana','IA'=>'iowa','KS'=>'kansas','KY'=>'kentucky','LA'=>'louisiana','ME'=>'maine','MD'=>'maryland','MA'=>'massachusetts','MI'=>'michigan','MN'=>'minnesota','MS'=>'mississippi','MO'=>'missouri','MT'=>'montana','NE'=>'nebraska','NV'=>'nevada','NH'=>'new hampshire','NJ'=>'new jersey','NM'=>'new mexico','NY'=>'new york','NC'=>'north carolina','ND'=>'north dakota','OH'=>'ohio','OK'=>'oklahoma','OR'=>'oregon','PA'=>'pennsylvania','RI'=>'rhode island','SC'=>'south carolina','SD'=>'south dakota','TN'=>'tennessee','TX'=>'texas','UT'=>'utah','VT'=>'vermont','VA'=>'virginia','WA'=>'washington','WV'=>'west virginia','WI'=>'wisconsin','WY'=>'wyoming','DC'=>'district of columbia','VI'=>'virgin islands');
  5042. foreach ($city_list as $k=>$v)
  5043. {
  5044. $v['province'] = strtoupper(trim($v['province'],' '));
  5045. if(isset($ToState[$v['province']]))
  5046. {
  5047. $v['province'] = $ToState[$v['province']];
  5048. }
  5049. $province[$v['province']] = array('province'=>$v['province']);
  5050. }
  5051. $this->data['province'] = $province;
  5052. $this->data['arg_array'] = $arg_array;
  5053. $this->_Template('fullorder_ddpmdata',$this->data);
  5054. }
  5055. public function _ddpmexcel($arg_array)
  5056. {
  5057. if(isset($_SESSION['api']))
  5058. {
  5059. $user = $this->user->get_api($_SESSION['api']);
  5060. $usp = $user;
  5061. $fgshop = "";$sid = "";
  5062. $usersp = explode('|',trim($user['shop'],'|'));
  5063. foreach ($usersp as $value)
  5064. {
  5065. $fgshop .= " shop = ".$value." or";
  5066. $sid .= " id = ".$value." or";
  5067. }
  5068. }
  5069. $province = $this->input->get('province',true);
  5070. $timetk = $arg_array[1];
  5071. $timetj = $arg_array[2];
  5072. $country = $arg_array[0];
  5073. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  5074. if($province)
  5075. {
  5076. $where .= " and province = '$province'";
  5077. }
  5078. $order_str = "dtime desc";
  5079. $info_list = $this->fullorder->find_all($where,'orderinfo,number,shipremarks,shouldmoney',$order_str);
  5080. $country = $this->country->read($arg_array[0]);
  5081. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5082. $titlename = "<table border=1>
  5083. <tr><th colspan='4' align='left'><h3>".$title."<h3></th></tr>
  5084. <tr>
  5085. <td>订单号</td>
  5086. <td>订单编号</td>
  5087. <td>仓库品名</td>
  5088. <td>订单金额</td>
  5089. </tr>
  5090. </table>";
  5091. $filename = $title.".xls";
  5092. $tail = "\n";
  5093. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5094. }
  5095. public function _statedc()
  5096. {
  5097. $user = $this->user->get_api($_SESSION['api']);
  5098. if($user)
  5099. {
  5100. $fgshop = "";$sid = "";
  5101. $user = explode('|',trim($user['shop'],'|'));
  5102. foreach ($user as $value)
  5103. {
  5104. $fgshop .= " shop = ".$value." or";
  5105. $sid .= " id = ".$value." or";
  5106. }
  5107. }
  5108. $post = $this->input->get(NULL, TRUE);
  5109. if(isset($post['timetk']))
  5110. {
  5111. $page = $this->input->get('page',true);
  5112. $perpage = $this->input->get('perpage',true);
  5113. $timetk = $this->input->get('timetk',true);
  5114. $timetj = $this->input->get('timetj',true);
  5115. $shop = $this->input->get('shop',true);
  5116. $source = $this->input->get('source',true);
  5117. $state = $this->input->get('state',true);
  5118. $review = $this->input->get('review',true);
  5119. $express = $this->input->get('express',true);
  5120. $fs = $this->input->get('fs',true);
  5121. $orderinfo = $this->input->get('orderinfo',true);
  5122. $number = $this->input->get('number',true);
  5123. $user = $this->input->get('user',true);
  5124. $name = $this->input->get('name',true);
  5125. $waybill = $this->input->get('waybill',true);
  5126. $expressstate = $this->input->get('expressstate',true);
  5127. $wltype = $this->input->get('wltype',true);
  5128. $wlyc = $this->input->get('wlyc',true);
  5129. $xztime = $this->input->get('xztime',true);
  5130. $timetk = strtotime($timetk);
  5131. $timetj = strtotime($timetj);
  5132. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5133. if($timetk && $timetj)
  5134. {
  5135. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5136. }
  5137. if($xztime == 'librarytime')
  5138. {
  5139. $order_str = "librarytime desc";
  5140. }
  5141. else if($xztime == 'dtime')
  5142. {
  5143. $order_str = "dtime desc";
  5144. }
  5145. if($shop)
  5146. {
  5147. $where .= " and shop = '$shop'";
  5148. }
  5149. if($source)
  5150. {
  5151. if($source == 11)
  5152. {
  5153. $where .= " and source != '1'";
  5154. }
  5155. else
  5156. {
  5157. $where .= " and source = '$source'";
  5158. }
  5159. }
  5160. if($fs)
  5161. {
  5162. if($fs == '2')
  5163. {
  5164. $where .= " and exstateerror != ''";
  5165. }
  5166. else
  5167. {
  5168. $where .= " and exstateerror = ''";
  5169. }
  5170. }
  5171. if($state)
  5172. {
  5173. $where .= " and state = '$state'";
  5174. }
  5175. if($review)
  5176. {
  5177. $where .= " and review = '$review'";
  5178. }
  5179. if($expressstate != "")
  5180. {
  5181. $where .= " and expressstate = '$expressstate'";
  5182. }
  5183. if($wltype != "")
  5184. {
  5185. $where .= " and wltype = '$wltype'";
  5186. }
  5187. if($wlyc != "")
  5188. {
  5189. $where .= " and wlyc = '$wlyc'";
  5190. }
  5191. if($express)
  5192. {
  5193. $where .= " and express = '$express'";
  5194. }
  5195. if($orderinfo)
  5196. {
  5197. $where .= " and orderinfo = '$orderinfo'";
  5198. }
  5199. if($number)
  5200. {
  5201. $where .= " and number = '$number'";
  5202. }
  5203. if($user)
  5204. {
  5205. $where .= " and user = '$user'";
  5206. }
  5207. if($name)
  5208. {
  5209. $where .= " and name = '$name'";
  5210. }
  5211. if($waybill)
  5212. {
  5213. $where .= " and waybill = '$waybill'";
  5214. }
  5215. if(empty($page))
  5216. {
  5217. $start = 0;
  5218. $perpage = 1;
  5219. }
  5220. else
  5221. {
  5222. $start = ($page - 1)*$perpage;
  5223. }
  5224. //取得信息列表
  5225. $info_list = $this->fullorder->find_all($where,'shop,number,country,library,librarytime,expressstate,express,waybill,content,exstateerror,excontent',$order_str);
  5226. //格式化数据
  5227. foreach ($info_list as $key=>$value)
  5228. {
  5229. $shop = $this->shop->read($value['shop']);
  5230. $info_list[$key]['shop'] = $shop['shopname'];
  5231. $country = $this->country->read($value['country']);
  5232. $info_list[$key]['country'] = $country['name'];
  5233. //$state = $this->typeclass->read($value['state']);
  5234. //$info_list[$key]['state'] = $state['title'];
  5235. if($value['library'] == 1)
  5236. {
  5237. $info_list[$key]['library'] = "未出库";
  5238. }
  5239. else if($value['library'] == 2)
  5240. {
  5241. $info_list[$key]['library'] = "已出库";
  5242. }
  5243. else if($value['library'] == 3)
  5244. {
  5245. $info_list[$key]['library'] = "已退库";
  5246. }
  5247. if($value['librarytime'] == '0')
  5248. {
  5249. $info_list[$key]['librarytime'] = '无';
  5250. }
  5251. else
  5252. {
  5253. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  5254. }
  5255. if($value['expressstate'] == 0)
  5256. {
  5257. $info_list[$key]['expressstate'] = "无信息";
  5258. }
  5259. else if($value['expressstate'] == 2)
  5260. {
  5261. $info_list[$key]['expressstate'] = "已取件";
  5262. }
  5263. else if($value['expressstate'] == 3)
  5264. {
  5265. $info_list[$key]['expressstate'] = "在途中";
  5266. }
  5267. /**
  5268. else if($value['expressstate'] == 4)
  5269. {
  5270. $info_list[$key]['expressstate'] = "到达目的地国";
  5271. }
  5272. **/
  5273. else if($value['expressstate'] == 4 || $value['expressstate'] == 5)
  5274. {
  5275. $info_list[$key]['expressstate'] = "即将派送";
  5276. }
  5277. else if($value['expressstate'] == 6)
  5278. {
  5279. $info_list[$key]['expressstate'] = "已签收";
  5280. }
  5281. else if($value['expressstate'] == 1)
  5282. {
  5283. $info_list[$key]['expressstate'] = "派送异常";
  5284. }
  5285. $express = $this->express->read($value['express']);
  5286. $info_list[$key]['express'] = $express['servicename'];
  5287. }
  5288. }
  5289. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5290. $titlename = "<table border=1>
  5291. <tr>
  5292. <td>店铺名称</td>
  5293. <td>编号</td>
  5294. <td>收件人国家</td>
  5295. <td>出库状态</td>
  5296. <td>发货时间</td>
  5297. <td>物流状态</td>
  5298. <td>快递公司</td>
  5299. <td>运单号</td>
  5300. <td>消息状态</td>
  5301. <td>错误提示</td>
  5302. <td>物流信息</td>
  5303. </tr>
  5304. </table>";
  5305. $filename = $title.".xls";
  5306. $tail = "\n";
  5307. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5308. }
  5309. public function _statedcwl()
  5310. {
  5311. $user = $this->user->get_api($_SESSION['api']);
  5312. if($user)
  5313. {
  5314. $fgshop = "";$sid = "";
  5315. $user = explode('|',trim($user['shop'],'|'));
  5316. foreach ($user as $value)
  5317. {
  5318. $fgshop .= " shop = ".$value." or";
  5319. $sid .= " id = ".$value." or";
  5320. }
  5321. }
  5322. $post = $this->input->get(NULL, TRUE);
  5323. if(isset($post['timetk']))
  5324. {
  5325. $dowid = $this->input->get('a');
  5326. $wid = "";
  5327. if($dowid != "")
  5328. {
  5329. $id_arr = explode(',',rtrim($dowid,','));
  5330. $wid .= " id = 0 or";
  5331. foreach ($id_arr as $v)
  5332. {
  5333. $wid .= " id = '$v' or";
  5334. }
  5335. $wid = " and".rtrim($wid,'or');
  5336. }
  5337. $page = $this->input->get('page',true);
  5338. $perpage = $this->input->get('perpage',true);
  5339. $timetk = $this->input->get('timetk',true);
  5340. $timetj = $this->input->get('timetj',true);
  5341. $shop = $this->input->get('shop',true);
  5342. $expressstate = $this->input->get('expressstate',true);
  5343. $fs = $this->input->get('fs',true);
  5344. $state = $this->input->get('state',true);
  5345. $express = $this->input->get('express',true);
  5346. $orderinfo = $this->input->get('orderinfo',true);
  5347. $number = $this->input->get('number',true);
  5348. $waybill = $this->input->get('waybill',true);
  5349. $wlyc = $this->input->get('wlyc',true);
  5350. $wltype = $this->input->get('wltype',true);
  5351. $source = $this->input->get('source',true);
  5352. $xztime = $this->input->get('xztime',true);
  5353. $timetk = strtotime($timetk);
  5354. $timetj = strtotime($timetj);
  5355. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5356. if($timetk && $timetj)
  5357. {
  5358. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5359. }
  5360. if($xztime == 'librarytime')
  5361. {
  5362. $order_str = "librarytime desc";
  5363. }
  5364. else if($xztime == 'dtime')
  5365. {
  5366. $order_str = "dtime desc";
  5367. }else if($xztime == 'wlfstime'){
  5368. $order_str = "wlfstime desc";
  5369. }
  5370. if($shop)
  5371. {
  5372. $where .= " and shop = '$shop'";
  5373. }
  5374. if($expressstate)
  5375. {
  5376. $where .= " and expressstate = '$expressstate'";
  5377. }
  5378. if($fs)
  5379. {
  5380. if($fs == '1')
  5381. {
  5382. $where .= " and wlcontent != ''";
  5383. }
  5384. if($fs == '2')
  5385. {
  5386. $where .= " and wlerror != ''";
  5387. }
  5388. if($fs == '3')
  5389. {
  5390. $where .= " and wlcontent = '' and shouldmoney > 100";
  5391. }
  5392. else if($fs == '4')
  5393. {
  5394. $where .= " and wltype = '1'";
  5395. }
  5396. }
  5397. if($state)
  5398. {
  5399. $where .= " and state = '$state'";
  5400. }
  5401. if($express)
  5402. {
  5403. $where .= " and express = '$express'";
  5404. }
  5405. if($orderinfo)
  5406. {
  5407. $where .= " and orderinfo = '$orderinfo'";
  5408. }
  5409. if($number)
  5410. {
  5411. $where .= " and number = '$number'";
  5412. }
  5413. if($waybill)
  5414. {
  5415. $where .= " and waybill = '$waybill'";
  5416. }
  5417. if($wlyc!='')
  5418. {
  5419. $where .= " and wlyc = '$wlyc'";
  5420. }
  5421. if($wltype!='')
  5422. {
  5423. $where .= " and wltype = '$wltype'";
  5424. }
  5425. if($source)
  5426. {
  5427. if($source == 1)
  5428. {
  5429. $where .= " and source = '$source'";
  5430. }
  5431. else
  5432. {
  5433. $where .= " and source != '1'";
  5434. }
  5435. }
  5436. $info_list = $this->fullorder->find_all($where.$wid,'orderinfo,number,country,library,librarytime,expressstate,express,waybill,wlbz,orderremarks,shipremarks,wlfstime,email,phone,wlcontent,wlerror,excontent',$order_str);
  5437. //格式化数据
  5438. foreach ($info_list as $key=>$value)
  5439. {
  5440. $country = $this->country->read($value['country']);
  5441. $info_list[$key]['country'] = $country['name'];
  5442. //$state = $this->typeclass->read($value['state']);
  5443. //$info_list[$key]['state'] = $state['title'];
  5444. if($value['library'] == 1)
  5445. {
  5446. $info_list[$key]['library'] = "未出库";
  5447. }
  5448. else if($value['library'] == 2)
  5449. {
  5450. $info_list[$key]['library'] = "已出库";
  5451. }
  5452. else if($value['library'] == 3)
  5453. {
  5454. $info_list[$key]['library'] = "已退库";
  5455. }
  5456. if($value['librarytime'] == '0')
  5457. {
  5458. $info_list[$key]['librarytime'] = '无';
  5459. }
  5460. else
  5461. {
  5462. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  5463. }
  5464. if($value['expressstate'] == 0)
  5465. {
  5466. $info_list[$key]['expressstate'] = "无信息";
  5467. }
  5468. else if($value['expressstate'] == 2)
  5469. {
  5470. $info_list[$key]['expressstate'] = "已取件";
  5471. }
  5472. else if($value['expressstate'] == 3)
  5473. {
  5474. $info_list[$key]['expressstate'] = "在途中";
  5475. }
  5476. /**
  5477. else if($value['expressstate'] == 4)
  5478. {
  5479. $info_list[$key]['expressstate'] = "到达目的地国";
  5480. }
  5481. **/
  5482. else if($value['expressstate'] == 4 || $value['expressstate'] == 5)
  5483. {
  5484. $info_list[$key]['expressstate'] = "即将派送";
  5485. }
  5486. else if($value['expressstate'] == 6)
  5487. {
  5488. $info_list[$key]['expressstate'] = "已签收";
  5489. }
  5490. else if($value['expressstate'] == 1)
  5491. {
  5492. $info_list[$key]['expressstate'] = "派送异常";
  5493. }
  5494. $info_list[$key]['wlfstime'] = date('Y-m-d H:i:s',$value['wlfstime']);
  5495. $express = $this->express->read($value['express']);
  5496. $info_list[$key]['express'] = $express['servicename'];
  5497. $info_list[$key]['excontent'] = str_replace('<br />','',$value['excontent']);
  5498. }
  5499. }
  5500. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5501. $titlename = "<table border=1>
  5502. <tr>
  5503. <td>订单号</td>
  5504. <td>编号</td>
  5505. <td>收件人国家</td>
  5506. <td>出库状态</td>
  5507. <td>出库时间</td>
  5508. <td>物流状态</td>
  5509. <td>快递公司</td>
  5510. <td>运单号</td>
  5511. <td>物流备注</td>
  5512. <td>订单备注</td>
  5513. <td>仓库品名</td>
  5514. <td>发送时间</td>
  5515. <td>邮箱</td>
  5516. <td>电话</td>
  5517. <td>邮件发送</td>
  5518. <td>错误提示</td>
  5519. <td>物流信息</td>
  5520. </tr>
  5521. </table>";
  5522. $filename = $title.".xls";
  5523. $tail = "\n";
  5524. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5525. }
  5526. public function _waybillemail()
  5527. {
  5528. $user = $this->user->get_api($_SESSION['api']);
  5529. if($user)
  5530. {
  5531. $fgshop = "";$sid = "";
  5532. $user = explode('|',trim($user['shop'],'|'));
  5533. foreach ($user as $value)
  5534. {
  5535. $fgshop .= " shop = ".$value." or";
  5536. $sid .= " id = ".$value." or";
  5537. }
  5538. }
  5539. $post = $this->input->post(NULL, TRUE);
  5540. if(isset($post['page']))
  5541. {
  5542. $page = $this->input->post('page',true);
  5543. $perpage = $this->input->post('perpage',true);
  5544. $timetk = $this->input->post('timetk',true);
  5545. $timetj = $this->input->post('timetj',true);
  5546. $shop = $this->input->post('shop',true);
  5547. $source = $this->input->post('source',true);
  5548. $expressstate = $this->input->post('expressstate',true);
  5549. $fs = $this->input->post('fs',true);
  5550. $state = $this->input->post('state',true);
  5551. $express = $this->input->post('express',true);
  5552. $orderinfo = $this->input->post('orderinfo',true);
  5553. $number = $this->input->post('number',true);
  5554. $waybill = $this->input->post('waybill',true);
  5555. $dlzemail = $this->input->post('dlzemail',true);
  5556. $xztime = $this->input->post('xztime',true);
  5557. $timetk = strtotime($timetk);
  5558. $timetj = strtotime($timetj);
  5559. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5560. if($timetk && $timetj)
  5561. {
  5562. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5563. }
  5564. $order_str = $xztime." desc";
  5565. if($source)
  5566. {
  5567. if($source == '2d')
  5568. {
  5569. $where .= " and source >= '2' and shop != 19";
  5570. }
  5571. else
  5572. {
  5573. $where .= " and source = '$source'";
  5574. }
  5575. }
  5576. if($shop)
  5577. {
  5578. $where .= " and shop = '$shop'";
  5579. }
  5580. if($expressstate)
  5581. {
  5582. $where .= " and expressstate = '$expressstate'";
  5583. }
  5584. if($state)
  5585. {
  5586. $where .= " and state = '$state'";
  5587. }
  5588. if($express)
  5589. {
  5590. $where .= " and express = '$express'";
  5591. }
  5592. if($orderinfo)
  5593. {
  5594. $where .= " and orderinfo = '$orderinfo'";
  5595. }
  5596. if($number)
  5597. {
  5598. $where .= " and number = '$number'";
  5599. }
  5600. if($waybill)
  5601. {
  5602. $where .= " and waybill = '$waybill'";
  5603. }
  5604. if($dlzemail != '')
  5605. {
  5606. $where .= " and dlzemail = '$dlzemail'";
  5607. }
  5608. if(empty($page))
  5609. {
  5610. $start = 0;
  5611. $perpage = 1;
  5612. }
  5613. else
  5614. {
  5615. $start = ($page - 1)*$perpage;
  5616. }
  5617. //取得信息列表
  5618. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,country,library,librarytime,express,waybill,dlzemail,dlzemailtime',$order_str,$start,$perpage);
  5619. //格式化数据
  5620. foreach ($info_list as $key=>$value)
  5621. {
  5622. $shop = $this->shop->read($value['shop']);
  5623. $info_list[$key]['shop'] = $shop['shopname'];
  5624. $country = $this->country->read($value['country']);
  5625. $info_list[$key]['country'] = $country['name'];
  5626. //$state = $this->typeclass->read($value['state']);
  5627. //$info_list[$key]['state'] = $state['title'];
  5628. if($value['library'] == 1)
  5629. {
  5630. $info_list[$key]['library'] = "未出库";
  5631. }
  5632. else if($value['library'] == 2)
  5633. {
  5634. $info_list[$key]['library'] = "已出库";
  5635. }
  5636. else if($value['library'] == 3)
  5637. {
  5638. $info_list[$key]['library'] = "已退库";
  5639. }
  5640. if($value['librarytime'] == '0')
  5641. {
  5642. $info_list[$key]['librarytime'] = '无';
  5643. }
  5644. else
  5645. {
  5646. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']);
  5647. }
  5648. $express = $this->express->read($value['express']);
  5649. $info_list[$key]['express'] = $express['servicename'];
  5650. if($value['dlzemail'] == '1')
  5651. {
  5652. $info_list[$key]['dlzemail'] = '发送成功';
  5653. }
  5654. else if ($value['dlzemail'] == '2')
  5655. {
  5656. $info_list[$key]['dlzemail'] = '发送失败';
  5657. }
  5658. else
  5659. {
  5660. $info_list[$key]['dlzemail'] = '';
  5661. }
  5662. $info_list[$key]['dlzemailtime'] = ($value['dlzemailtime']>0)?date('Y-m-d H:i:s',$value['dlzemailtime']):'';
  5663. }
  5664. $total = $this->fullorder->find_count($where);
  5665. $pagenum = ceil($total/$perpage);
  5666. $over = $total-($start+$perpage);
  5667. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5668. echo json_encode($rows);exit;
  5669. }
  5670. $notice = $this->notice->find_all("type = '2' and (".rtrim($fgshop,'or').")");
  5671. $this->data['notice'] = $notice;
  5672. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  5673. $this->data['wlshop'] = $wlshop;
  5674. $this->data['express'] = $this->express->find_all();
  5675. $this->_Template('fullorder_waybillemail',$this->data);
  5676. }
  5677. public function _khdd()
  5678. {
  5679. $dt = 0;$fgshop = "shop = 0";$sid = 'id = 0';
  5680. if(isset($_SESSION['api']))
  5681. {
  5682. $user = $this->user->get_api($_SESSION['api']);
  5683. $usp = $user;
  5684. $fgshop = "";$sid = "";
  5685. $usersp = explode('|',trim($user['shop'],'|'));
  5686. foreach ($usersp as $value)
  5687. {
  5688. $fgshop .= " shop = ".$value." or";
  5689. $sid .= " id = ".$value." or";
  5690. }
  5691. if($user['vip'] == 1)
  5692. {
  5693. $vip = 1;
  5694. }
  5695. else
  5696. {
  5697. $vip = 0;
  5698. }
  5699. }
  5700. $post = $this->input->post(NULL, TRUE);
  5701. if(isset($_GET['excel']))
  5702. {
  5703. $page = $this->input->get('page',true);
  5704. $perpage = $this->input->get('perpage',true);
  5705. $warehouse = $this->input->get('warehouse',true);
  5706. $timetk = $this->input->get('timetk',true);
  5707. $timetj = $this->input->get('timetj',true);
  5708. $shop = $this->input->get('shop',true);
  5709. $source = $this->input->get('source',true);
  5710. $state = $this->input->get('state',true);
  5711. $review = $this->input->get('review',true);
  5712. $type = $this->input->get('type',true);
  5713. $express = $this->input->get('express',true);
  5714. $orderinfo = $this->input->get('orderinfo',true);
  5715. $user = $this->input->get('user',true);
  5716. $client = $this->input->get('name',true);
  5717. $waybill = $this->input->get('waybill',true);
  5718. $number = $this->input->get('number',true);
  5719. $email = $this->input->get('email',true);
  5720. $phone = $this->input->get('phone',true);
  5721. $dlz = $this->input->get('dlz',true);
  5722. $print = $this->input->get('print',true);
  5723. $library = $this->input->get('library',true);
  5724. $js = $this->input->get('js',true);
  5725. $exstate = $this->input->get('exstate',true);
  5726. $xztime = $this->input->get('xztime',true);
  5727. $libraryconfirm = $this->input->get('libraryconfirm',true);
  5728. $timetk = strtotime($timetk);
  5729. $timetj = strtotime($timetj);
  5730. $plorder = $this->input->get('pl',true);
  5731. $paypal = $this->input->get('paypal',true);
  5732. $zf = $this->input->get('zf',true);
  5733. $pay = $this->input->get('pay',true);
  5734. $excel = $this->input->get('excel',true);
  5735. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5736. if($warehouse)
  5737. {
  5738. $where .= " and type = '$warehouse'";
  5739. }
  5740. if($timetk && $timetj)
  5741. {
  5742. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5743. }
  5744. if($shop)
  5745. {
  5746. $where .= " and shop = '$shop'";
  5747. }
  5748. if($source)
  5749. {
  5750. if($source == '2d')
  5751. {
  5752. $where .= " and source >= '2'";
  5753. }
  5754. else
  5755. {
  5756. $where .= " and source = '$source'";
  5757. }
  5758. }
  5759. if($state)
  5760. {
  5761. $where .= " and state = '$state'";
  5762. }
  5763. if($review)
  5764. {
  5765. $where .= " and review = '$review'";
  5766. }
  5767. if($type)
  5768. {
  5769. $where .= " and type = '$type'";
  5770. }
  5771. if($express)
  5772. {
  5773. $where .= " and express = '$express'";
  5774. }
  5775. if($orderinfo)
  5776. {
  5777. $where .= " and orderinfo = '$orderinfo'";
  5778. }
  5779. if($user)
  5780. {
  5781. $where .= " and user = '$user'";
  5782. }
  5783. if($client)
  5784. {
  5785. $where .= " and client like '%$client%'";
  5786. }
  5787. if($waybill)
  5788. {
  5789. $where .= " and waybill = '$waybill'";
  5790. }
  5791. if($number)
  5792. {
  5793. $where .= " and number = '$number'";
  5794. }
  5795. if($email)
  5796. {
  5797. $where .= " and email = '$email'";
  5798. }
  5799. if($phone)
  5800. {
  5801. $where .= " and phone like '%$phone%'";
  5802. }
  5803. if($library)
  5804. {
  5805. $where .= " and library = '$library'";
  5806. }
  5807. if($print)
  5808. {
  5809. $where .= " and print = '$print'";
  5810. }
  5811. if($dlz != '')
  5812. {
  5813. $where .= " and dlz = '$dlz'";
  5814. }
  5815. if($js)
  5816. {
  5817. $where .= " and js = '$js'";
  5818. }
  5819. if($exstate)
  5820. {
  5821. $where .= " and exstate = '$exstate'";
  5822. }
  5823. if($libraryconfirm)
  5824. {
  5825. $where .= " and libraryconfirm = '$libraryconfirm'";
  5826. }
  5827. if($paypal)
  5828. {
  5829. $where .= " and paypal = '$paypal'";
  5830. }
  5831. if($pay)
  5832. {
  5833. $where .= " and pay = '$pay'";
  5834. }
  5835. if($zf)
  5836. {
  5837. if($zf == 1)
  5838. {
  5839. $where .= " and paypal not like '%-%-%-%'";
  5840. }
  5841. else
  5842. {
  5843. $where .= " and paypal like '%-%-%-%'";
  5844. }
  5845. }
  5846. if($plorder)
  5847. {
  5848. $plorderinfo = '';$plnumber = '';$pln = 0;
  5849. $plorder = explode(',',trim($plorder,','));
  5850. foreach ($plorder as $value)
  5851. {
  5852. if(is_numeric($value))
  5853. {
  5854. $plorderinfo .= " orderinfo = ".$value." or";
  5855. }
  5856. else if($value != '')
  5857. {
  5858. $plorderinfo .= " number = '".$value."' or";
  5859. }
  5860. }
  5861. if($pln > 0)
  5862. {
  5863. $where .= " and (".rtrim($plorderinfo,'or').") and (".rtrim($plnumber,'or').")";
  5864. }
  5865. else
  5866. {
  5867. $where .= " and (".rtrim($plorderinfo,'or').")";
  5868. }
  5869. }
  5870. //数据排序
  5871. $order_str = "dtime desc";
  5872. if(empty($page))
  5873. {
  5874. $start = 0;
  5875. $perpage = 1;
  5876. }
  5877. else
  5878. {
  5879. $start = ($page - 1)*$perpage;
  5880. }
  5881. if($excel == '1')
  5882. {
  5883. $shop = array();
  5884. $shopdata = $this->shop->find_all("type = '269'");
  5885. foreach ($shopdata as $v)
  5886. {
  5887. $shop[$v['id']] = array('t'=>$v['brandname'],'z'=>0,'l'=>0,'x'=>0);//店铺名称,总客户,老客户,新客户
  5888. }
  5889. $oldnumber = 0;$newnumber = 0;
  5890. $info_list = $this->db->query('select distinct shop,email from crowd_fullorder where '.$where)->result_array();
  5891. foreach ($info_list as $key=>$v)
  5892. {
  5893. $shop[$v['shop']]['z'] += 1;
  5894. $num = $this->fullorder->find_count("email = '".$v['email']."' and shop = '".$v['shop']."' and ".$xztime." < '$timetj'");
  5895. if($num > 1)
  5896. {
  5897. $shop[$v['shop']]['l'] += 1;
  5898. }
  5899. else
  5900. {
  5901. $shop[$v['shop']]['x'] += 1;
  5902. }
  5903. if(isset($v['email']) && $usp['excelpass'] == '1')
  5904. {
  5905. $emailpass = $this->setting->get_excelpass($v['email']);
  5906. $info_list[$key]['email'] = $emailpass;
  5907. }
  5908. }
  5909. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5910. $titlename = "<table border=1>
  5911. <tr>
  5912. <td>店铺</td>
  5913. <td>客户数</td>
  5914. <td>老客户数</td>
  5915. <td>新客户数</td>
  5916. </tr>
  5917. </table>";
  5918. $filename = $title.".xls";
  5919. $tail = "\n";
  5920. $this->excel->get_fz2($shop,$titlename,$filename,$tail);
  5921. }
  5922. else if($excel == '2' || $excel == '3')
  5923. {
  5924. $kh = array();
  5925. $info_list = $this->db->query('select distinct shop,email from crowd_fullorder where email != "" and '.$where)->result_array();
  5926. foreach ($info_list as $key=>$v)
  5927. {
  5928. $k = $this->fullorder->find_all("shop = '".$v['shop']."' and email = '".$v['email']."' and ".$xztime." < '$timetj'",'name,email,dtime,shouldmoney','dtime desc');
  5929. if($excel == 2 && count($k) > 1)
  5930. {
  5931. $kh[] = array($k[0]['name'],$k[0]['email'],date("Y-m-d H:i:s",$k[0]['dtime']),count($k),array_sum(array_column($k,'shouldmoney')));
  5932. }
  5933. if($excel == 3 && count($k) < 2)
  5934. {
  5935. $kh[] = array($k[0]['name'],$k[0]['email'],date("Y-m-d H:i:s",$k[0]['dtime']),count($k),array_sum(array_column($k,'shouldmoney')));
  5936. }
  5937. if(isset($v['email']) && $usp['excelpass'] == '1')
  5938. {
  5939. $emailpass = $this->setting->get_excelpass($v['email']);
  5940. $info_list[$key]['email'] = $emailpass;
  5941. }
  5942. }
  5943. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5944. $titlename = "<table border=1>
  5945. <tr>
  5946. <td>名称</td>
  5947. <td>邮箱</td>
  5948. <td>最后购买时间</td>
  5949. <td>购买次数</td>
  5950. <td>购买总额</td>
  5951. </tr>
  5952. </table>";
  5953. $filename = $title.".xls";
  5954. $tail = "\n";
  5955. $this->excel->get_fz2($kh,$titlename,$filename,$tail);
  5956. }
  5957. else if($excel == '4' || $excel == '5')
  5958. {
  5959. $kh = array();
  5960. $info_list = $this->db->query('select distinct shop,email from crowd_fullorder where email != "" and '.$where)->result_array();
  5961. foreach ($info_list as $key=>$value)
  5962. {
  5963. $k = $this->fullorder->find_all("shop = '".$value['shop']."' and email = '".$value['email']."' and ".$xztime." < '$timetj'",'orderinfo,state,product,name,email,dtime,shouldmoney','dtime desc');
  5964. if($excel == 4 && count($k) > 1)
  5965. {
  5966. foreach ($k as $v)
  5967. {
  5968. $typeclass = $this->typeclass->read($v['state']);
  5969. $kh[] = array($v['orderinfo'],$typeclass['spare'],$v['product'],$v['name'],$v['email'],date("Y-m-d H:i:s",$v['dtime']),$v['shouldmoney']);
  5970. }
  5971. }
  5972. if($excel == 5 && count($k) < 2)
  5973. {
  5974. if(!isset($k[0]['state']))
  5975. {
  5976. $typeclass = $k[0]['state'].'-数据字典无此信息';
  5977. }
  5978. else
  5979. {
  5980. $typeclass = $this->typeclass->read($k[0]['state']);
  5981. }
  5982. $kh[] = array($k[0]['orderinfo'],$typeclass['spare'],$k[0]['product'],$k[0]['name'],$k[0]['email'],date("Y-m-d H:i:s",$k[0]['dtime']),$k[0]['shouldmoney']);
  5983. }
  5984. if(isset($value['email']) && $usp['excelpass'] == '1')
  5985. {
  5986. $emailpass = $this->setting->get_excelpass($value['email']);
  5987. $info_list[$key]['email'] = $emailpass;
  5988. }
  5989. }
  5990. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5991. $titlename = "<table border=1>
  5992. <tr>
  5993. <td>订单号</td>
  5994. <td>订单状态</td>
  5995. <td>产品名</td>
  5996. <td>客户名</td>
  5997. <td>客户邮箱</td>
  5998. <td>下单时间</td>
  5999. <td>订单金额</td>
  6000. </tr>
  6001. </table>";
  6002. $filename = $title.".xls";
  6003. $tail = "\n";
  6004. $this->excel->get_fz2($kh,$titlename,$filename,$tail);
  6005. }
  6006. }
  6007. }
  6008. public function _klarnadata()
  6009. {
  6010. $post = $this->input->post(NULL, TRUE);
  6011. if(isset($post['number']))
  6012. {
  6013. $number = $this->input->post('number',true);
  6014. $data = $this->fullorder->get_number($number);
  6015. $shop = $this->shop->read($data['shop']);
  6016. $f = '';
  6017. if($data['pay'] == '23')
  6018. {
  6019. $url = 'https://api-na.klarna.com/ordermanagement/v1/orders/'.$data['paypal'];
  6020. $header[] = "Content-Type:application/json";
  6021. $header[] = "Authorization: Basic ".base64_encode($shop['klarnaname'].":".$shop['klarnapass']);
  6022. $ch = curl_init();
  6023. curl_setopt($ch, CURLOPT_URL, $url);
  6024. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6025. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  6026. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6027. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  6028. $res = curl_exec($ch);
  6029. curl_close($ch);
  6030. $res = json_decode($res,true);
  6031. if(isset($res['fraud_status']) && $shop['klarnaname'] != '')
  6032. {
  6033. $f = (($res['fraud_status'] == 'ACCEPTED')?1:2).'|<strong>'.$res['purchase_currency'].($res['order_amount']/100).'</strong> , '.(($res['fraud_status'] != 'ACCEPTED')?'<font style="color:#f00">'.$res['fraud_status'].'</font>':$res['fraud_status']).' , description:'.$res['initial_payment_method']['description'].' , number of installments:'.$res['initial_payment_method']['number_of_installments'].'|'.$res['billing_address']['street_address'].(($res['billing_address']['street_address2']!='')?' '.$res['billing_address']['street_address2']:'').','.$res['billing_address']['city'].','.$res['billing_address']['region'].','.$res['billing_address']['postal_code'].','.$res['billing_address']['country'].','.$res['billing_address']['given_name'].' '.$res['billing_address']['family_name'].','.$res['billing_address']['phone'].','.$res['billing_address']['email'].'|'.$res['shipping_address']['street_address'].(($res['shipping_address']['street_address2']!='')?' '.$res['shipping_address']['street_address2']:'').','.$res['shipping_address']['city'].','.$res['shipping_address']['region'].','.$res['shipping_address']['postal_code'].','.$res['shipping_address']['country'].','.$res['shipping_address']['given_name'].' '.$res['shipping_address']['family_name'].','.$res['shipping_address']['phone'].','.$res['shipping_address']['email'];
  6034. }
  6035. }
  6036. else if(($data['pay'] == '22' || $data['pay'] == '7') && $shop['paypalname'] != '')
  6037. {
  6038. $f = $this->paypal->data($data['paypal'],$shop);
  6039. }
  6040. else if(($data['pay'] == '26') && $shop['afterpayname'] != '')
  6041. {
  6042. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$data['paypal'];
  6043. $header[] = "Accept:application/json";
  6044. $header[] = "User-Agent: Readme.io API Simulator'";
  6045. $header[] = "Authorization: Basic ".base64_encode($shop['afterpayname'].":".$shop['afterpaypass']);
  6046. $ch = curl_init();
  6047. curl_setopt($ch, CURLOPT_URL, $url);
  6048. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6049. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  6050. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6051. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  6052. $res = curl_exec($ch);
  6053. curl_close($ch);
  6054. $res = json_decode($res,true);
  6055. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  6056. {
  6057. $f = $res['results'][0]['orderDetails']['consumer']['email'].'|'.$res['results'][0]['orderDetails']['billing']['line1'].','.$res['results'][0]['orderDetails']['billing']['line2'].','.$res['results'][0]['orderDetails']['billing']['area1'].','.$res['results'][0]['orderDetails']['billing']['region'].','.$res['results'][0]['orderDetails']['billing']['postcode'].','.$res['results'][0]['orderDetails']['billing']['countryCode'].','.$res['results'][0]['orderDetails']['billing']['name'].','.$res['results'][0]['orderDetails']['billing']['phoneNumber'].'|'.$res['results'][0]['orderDetails']['shipping']['line1'].','.$res['results'][0]['orderDetails']['shipping']['line2'].','.$res['results'][0]['orderDetails']['shipping']['area1'].','.$res['results'][0]['orderDetails']['shipping']['region'].','.$res['results'][0]['orderDetails']['shipping']['postcode'].','.$res['results'][0]['orderDetails']['shipping']['countryCode'].','.$res['results'][0]['orderDetails']['shipping']['name'].','.$res['results'][0]['orderDetails']['shipping']['phoneNumber'];
  6058. $f = str_replace(',,',',',$f);
  6059. }
  6060. }
  6061. else if(($data['pay'] == '27') && $shop['clearpayname'] != '')
  6062. {
  6063. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$data['paypal'];
  6064. $header[] = "Accept:application/json";
  6065. $header[] = "User-Agent: Readme.io API Simulator'";
  6066. $header[] = "Authorization: Basic ".base64_encode($shop['clearpayname'].":".$shop['clearpaypass']);
  6067. $ch = curl_init();
  6068. curl_setopt($ch, CURLOPT_URL, $url);
  6069. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6070. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  6071. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6072. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  6073. $res = curl_exec($ch);
  6074. curl_close($ch);
  6075. $res = json_decode($res,true);
  6076. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  6077. {
  6078. $f = $res['results'][0]['orderDetails']['consumer']['email'].'|'.$res['results'][0]['orderDetails']['billing']['line1'].','.$res['results'][0]['orderDetails']['billing']['line2'].','.$res['results'][0]['orderDetails']['billing']['area1'].','.$res['results'][0]['orderDetails']['billing']['region'].','.$res['results'][0]['orderDetails']['billing']['postcode'].','.$res['results'][0]['orderDetails']['billing']['countryCode'].','.$res['results'][0]['orderDetails']['billing']['name'].','.$res['results'][0]['orderDetails']['billing']['phoneNumber'].'|'.$res['results'][0]['orderDetails']['shipping']['line1'].','.$res['results'][0]['orderDetails']['shipping']['line2'].','.$res['results'][0]['orderDetails']['shipping']['area1'].','.$res['results'][0]['orderDetails']['shipping']['region'].','.$res['results'][0]['orderDetails']['shipping']['postcode'].','.$res['results'][0]['orderDetails']['shipping']['countryCode'].','.$res['results'][0]['orderDetails']['shipping']['name'].','.$res['results'][0]['orderDetails']['shipping']['phoneNumber'];
  6079. $f = str_replace(',,',',',$f);
  6080. }
  6081. }
  6082. else if($data['pay'] == '1211')
  6083. {
  6084. $url = 'https://api.stripe.com/v1/payment_intents/'.$data['paypal'];
  6085. $header[] = "Authorization:Bearer ".$shop['stripe'];
  6086. $ch = curl_init();
  6087. curl_setopt($ch, CURLOPT_URL, $url);
  6088. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6089. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  6090. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6091. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  6092. $res = curl_exec($ch);
  6093. curl_close($ch);
  6094. $res = json_decode($res,true);
  6095. $f = '';
  6096. if(isset($res['shipping']['name']))
  6097. {
  6098. $line = ($res['shipping']['address']['line2'] != '')?$res['shipping']['address']['line1'].' '.$res['shipping']['address']['line2']:$res['shipping']['address']['line1'];
  6099. $f = 'stripe|'.json_encode(array('name'=>$res['shipping']['name'],'email'=>$res['receipt_email'],'address'=>$line.','.$res['shipping']['address']['city'].','.$res['shipping']['address']['state'].','.$res['shipping']['address']['postal_code'].','.$res['shipping']['address']['country'].','.$res['shipping']['phone'],'shouldmoney'=>$res['amount']/100));
  6100. }
  6101. }
  6102. else
  6103. {
  6104. echo json_encode(array('msg'=>'此店铺没有对接信息','success'=>false));exit;
  6105. }
  6106. if($f != '')
  6107. {
  6108. if($this->fullorder->save(array('klarnadata'=>$f),$data['id']))
  6109. {
  6110. echo json_encode(array('msg'=>'获取成功,请关闭此页重新打开','success'=>true));exit;
  6111. }
  6112. else
  6113. {
  6114. echo json_encode(array('msg'=>'写入失败,请重试','success'=>false));exit;
  6115. }
  6116. }
  6117. else
  6118. {
  6119. echo json_encode(array('msg'=>'获取失败,请稍后重试','cl'=>base64_encode($shop['afterpayname'].":".$shop['afterpaypass']),'a'=>$data['paypal'],'success'=>false));exit;
  6120. }
  6121. }
  6122. }
  6123. public function _kcyz($warehouse,$whlabel,$id,$shop,$number)
  6124. {
  6125. if(!$whlabel || $whlabel == '|')
  6126. {
  6127. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  6128. }
  6129. $w = $this->warehouse->read($warehouse);
  6130. if($w['zd'] != 1)
  6131. {
  6132. return 1;
  6133. }
  6134. $pp = explode('|',trim($whlabel,'|'));
  6135. $x = 0;$save = array();
  6136. foreach ($pp as $va)
  6137. {
  6138. $num = explode('-',$va);
  6139. if($number)
  6140. {
  6141. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and (shop IS NULL or shop = '')");//通用
  6142. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  6143. }
  6144. else
  6145. {
  6146. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  6147. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  6148. }
  6149. $x++;
  6150. if(count($whlabel)+count($shopwhlabel) < $num[1])
  6151. {
  6152. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  6153. }
  6154. }
  6155. return $save;
  6156. }
  6157. public function _epod()
  6158. {
  6159. $post = $this->input->post(NULL, TRUE);
  6160. if(isset($post['number']))
  6161. {
  6162. $number = $this->input->post('number',true);
  6163. $data = $this->fullorder->get_number($number);
  6164. if(is_file('./data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf'))
  6165. {
  6166. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].'/data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf','success'=>true));exit;
  6167. }
  6168. else
  6169. {
  6170. $epod = $this->dhl->get_epod($data);
  6171. if($epod['c'] == 1)
  6172. {
  6173. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].$epod['d'],'success'=>true));exit;
  6174. }
  6175. else
  6176. {
  6177. echo json_encode(array('msg'=>$epod['d'],'success'=>false));exit;
  6178. }
  6179. }
  6180. }
  6181. }
  6182. public function _zw($arg_array)
  6183. {
  6184. $arg_array = $arg_array[0];$fpdata = array();
  6185. $fullorder = $this->fullorder->read($arg_array);
  6186. $fullorder['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$fullorder['shipremarks']);
  6187. $fullorder['parameter'] = str_replace(",","---",$fullorder['parameter']);
  6188. $this->data['fullorder'] = $fullorder;
  6189. $this->data['countrys'] = $this->country->find_all();
  6190. $this->data['express'] = $this->express->find_all();
  6191. $warehouse = $this->warehouse->read($fullorder['type']);
  6192. if(stripos($fullorder['fpdata'],';') !== false)
  6193. {
  6194. $fpdata = explode(';',rtrim($fullorder['fpdata'],';'));
  6195. foreach ($fpdata as $k=>$v)
  6196. {
  6197. $xxv = explode('|',$v);
  6198. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  6199. {
  6200. $xxv['zd'] = "<p>已占单</p>";
  6201. $bdck = $warehouse['bdck'];
  6202. if(stripos($xxv[9],'~') !== false)
  6203. {
  6204. $dxxv = explode('~',trim($xxv[9],'~'));
  6205. foreach ($dxxv as $val)
  6206. {
  6207. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  6208. if($wzid['details'] != '')
  6209. {
  6210. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  6211. }
  6212. }
  6213. }
  6214. else
  6215. {
  6216. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  6217. if($wzid['details'] != '')
  6218. {
  6219. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  6220. }
  6221. }
  6222. }
  6223. $fpdata[$k] = $xxv;
  6224. }
  6225. }
  6226. $this->data['fpdata'] = $fpdata;
  6227. $this->data['fpdata'] = $fpdata;
  6228. $thfpdataxs = array();
  6229. if($fullorder['thfpdata'] != '')
  6230. {
  6231. $thfpdata = explode(';',trim($fullorder['thfpdata'],';'));
  6232. foreach ($thfpdata as $k=>$v)
  6233. {
  6234. $thxs = explode('~',trim($v,'~'));
  6235. $thxs[0] = explode('|',trim($thxs[0],'|'));
  6236. $thxs[1] = explode('|',trim($thxs[1],'|'));
  6237. $thfpdataxs[] = array("<p>".$thxs[0][1]."<i class='fa fa-level-down'></i></p><p>".$thxs[1][1]."</p>","<p>".$thxs[0][2]."</p><p>".$thxs[1][2]."</p>","<p>旧</p><p>新</p>",$thxs[1][0]);
  6238. }
  6239. }
  6240. $this->data['thfpdata'] = $thfpdataxs;
  6241. $shop = $this->shop->read($fullorder['shop']);
  6242. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  6243. $is = 0;
  6244. if($shop['type'] == 269 || $shop['type'] == 2678)//判断是否独立站,269是独立站
  6245. {
  6246. $is = 1;
  6247. }
  6248. $this->data['is'] = $is;
  6249. //单项开始
  6250. $warehouse = $this->warehouse->read($fullorder['warehouse']);//发货仓库
  6251. $state = $this->typeclass->read($fullorder['state']);//订单状态
  6252. $country = $this->country->read($fullorder['country']);//国家
  6253. if($fullorder['capital'] == 1)
  6254. {
  6255. $capital = '暂未支付';
  6256. }
  6257. else if($fullorder['capital'] == 2)
  6258. {
  6259. $capital = '部分支付';
  6260. }
  6261. else if($fullorder['capital'] == 3)
  6262. {
  6263. $capital = '全部支付';
  6264. }
  6265. if($fullorder['printtype'] == 1)
  6266. {
  6267. $printtype = '运单';
  6268. }
  6269. else if($fullorder['printtype'] == 2)
  6270. {
  6271. $printtype = '发货单';
  6272. }
  6273. else if($fullorder['printtype'] == 3)
  6274. {
  6275. $printtype = '不打印单据';
  6276. }
  6277. else
  6278. {
  6279. $printtype = '未选择';
  6280. }
  6281. $this->data['warehouse'] = $warehouse['title'];
  6282. $this->data['state'] = $state['title'];
  6283. $this->data['capital'] = $capital;
  6284. $this->data['country'] = $country['name'];
  6285. $this->data['printtype'] = $printtype;
  6286. //单项结束
  6287. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  6288. $downwaybill = '';$dwls = array();
  6289. $oldwaybill = explode('-',ltrim($fullorder['oldwaybill'],'-'));
  6290. if(isset($oldwaybill[0][1]))
  6291. {
  6292. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  6293. foreach ($oldwaybill as $v)
  6294. {
  6295. $dw = explode('/',$v);
  6296. if(isset($dw[1]))
  6297. {
  6298. if(stripos($downwaybill,$dw[1]) === false)
  6299. {
  6300. $dwls[$dw[1]] = 1;
  6301. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  6302. }
  6303. }
  6304. }
  6305. }
  6306. if($fullorder['printtype'] == 1)
  6307. {
  6308. if($fullorder['waybill'] != '' && !isset($dwls[$fullorder['waybill']]))
  6309. {
  6310. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullorder['printtime']).'/y-'.$fullorder['waybill'].'.pdf" target="_blank">'.$fullorder['waybill'].'</a>、'.$downwaybill;
  6311. }
  6312. }
  6313. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  6314. /** 历史打印时间 **/
  6315. $printtime = '';
  6316. if($fullorder['oldprinttime'])
  6317. {
  6318. $pte = explode('-',rtrim($fullorder['oldprinttime'],'-'));
  6319. foreach ($pte as $v)
  6320. {
  6321. $printtime .= date('Y-m-d H:i:s',$v).'、';
  6322. }
  6323. }
  6324. $this->data['printtime'] = rtrim($printtime,'、');
  6325. $product = '';
  6326. $fullorder['product'] = str_replace("'","",$fullorder['product']);
  6327. if($fullorder['link'] != '' && $fullorder['source'] != '1')
  6328. {
  6329. $pt = explode(',',$fullorder['product']);
  6330. $lk = explode(',',$fullorder['link']);
  6331. for($i=0;$i<count($pt);$i++)
  6332. {
  6333. if(isset($lk[$i]))
  6334. {
  6335. $octs = $this->colourorderts->get_texturl($pt[$i],$lk[$i]);
  6336. }
  6337. else
  6338. {
  6339. $octs = '';
  6340. }
  6341. $a = $octs?'<font style="color:#'.$octs['colour'].'">'.$pt[$i].'</font>':$pt[$i];
  6342. //$a = (stripos($pt[$i],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($pt[$i],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($pt[$i],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($pt[$i],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($pt[$i],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($pt[$i],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($pt[$i],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($pt[$i],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($pt[$i],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$pt[$i].'</font>':$pt[$i];
  6343. if(isset($lk[$i]))
  6344. {
  6345. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  6346. }
  6347. else
  6348. {
  6349. $product .= ($product != '')?' , '.$a:$a;
  6350. }
  6351. }
  6352. }
  6353. else
  6354. {
  6355. $octs = $this->colourorderts->get_text($fullorder['product']);
  6356. $a = $octs?'<font style="color:#F39">'.$fullorder['product'].'</font>':$fullorder['product'];
  6357. //$a = (stripos($fullorder['product'],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($fullorder['product'],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($fullorder['product'],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($fullorder['product'],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($fullorder['product'],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($fullorder['product'],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($fullorder['product'],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($fullorder['product'],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($fullorder['product'],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$fullorder['product'].'</font>':$fullorder['product'];
  6358. $product = $a;
  6359. }
  6360. $this->data['product'] = $product;
  6361. $out = $this->systemtransfer->find_all("number = '".$fullorder['number']."'");
  6362. $outread = '';
  6363. if($out)
  6364. {
  6365. foreach ($out as $val)
  6366. {
  6367. $list = '';
  6368. $rk = explode('|',trim($val['rk'],'|'));
  6369. $rktime = explode('|',trim($val['rktime'],'|'));
  6370. $zw = array();
  6371. $t = $this->transfer->find_all("1=1");
  6372. foreach ($t as $v)
  6373. {
  6374. $zw[$v['id']] = $v['title'];
  6375. }
  6376. if($val['rk'] != '' && count($rk) > 0)
  6377. {
  6378. for($i=0;$i<count($rk);$i++)
  6379. {
  6380. if(!isset($rktime[$i]))
  6381. {
  6382. $list .= $zw[$cz[$i]];
  6383. }
  6384. else
  6385. {
  6386. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  6387. }
  6388. }
  6389. }
  6390. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  6391. }
  6392. }
  6393. else
  6394. {
  6395. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullorder['number']."'");
  6396. $outread = array();
  6397. if($systemwigsout)
  6398. {
  6399. foreach ($systemwigsout as $v)
  6400. {
  6401. if($v['czwarehouse'] == 37)
  6402. {
  6403. $outread[] = '华荣厂';
  6404. }
  6405. else if($v['czwarehouse'] == 0)
  6406. {
  6407. $outread[] = '龙盈厂';
  6408. }
  6409. $cz = explode('|',trim($v['cz'],'|'));
  6410. $cztime = explode('|',trim($v['cztime'],'|'));
  6411. $zw = $this->transfer->get_list();
  6412. if($v['cz'] != '' && count($cz) > 0)
  6413. {
  6414. for($i=0;$i<count($cz);$i++)
  6415. {
  6416. if(!isset($cztime[$i]))
  6417. {
  6418. $outread[] = $zw[$cz[$i]].' -&gt; ';
  6419. }
  6420. else
  6421. {
  6422. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  6423. }
  6424. }
  6425. $outread[] = '<br>';
  6426. }
  6427. }
  6428. }
  6429. }
  6430. $klarnacolor = '';
  6431. if($fullorder['klarnadata'] !='')
  6432. {
  6433. $klarnadata = explode('|',$fullorder['klarnadata']);
  6434. if($klarnadata[0] == 'paypal' || $klarnadata[0] == 'stripe')
  6435. {
  6436. $klarnadata[1] = json_decode($klarnadata[1],true);
  6437. if($klarnadata[0] == 'stripe' && $klarnadata[1]['shouldmoney'] != $fullorder['shouldmoney'] && $fullorder['pay'] == 1211)
  6438. {
  6439. $klarnacolor = 'style="color:#F00"';
  6440. }
  6441. }
  6442. else if($klarnadata[0]!=1 && $fullorder['pay']!=26 && $fullorder['pay']!=27 && $fullorder['pay']!=1211)
  6443. {
  6444. $klarnacolor = 'style="color:#F00"';
  6445. }
  6446. if($fullorder['pay'] == 23)//klarna
  6447. {
  6448. $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','guam'=>'GU','puerto rico'=>'PR');
  6449. $ToState = array_flip($ToState);
  6450. $klarnadata3 = str_replace(' ','',$klarnadata[3]);
  6451. $city = str_replace(' ','',$fullorder['city']);
  6452. $klarnadataaddress = explode($city,$klarnadata3);
  6453. if(isset($klarnadataaddress[1]))
  6454. {
  6455. $klarnadata3 = $city.$klarnadataaddress[1];
  6456. $klarnadatacolor = explode(',',$klarnadata3);
  6457. unset($klarnadatacolor[4]);
  6458. unset($klarnadatacolor[6]);
  6459. if(isset($ToState[$klarnadatacolor[1]]))
  6460. {
  6461. $klarnadatacolor[1] = ucwords($ToState[$klarnadatacolor[1]]);
  6462. }
  6463. $klarnadata['color'] = $klarnadataaddress[0].implode(",",$klarnadatacolor);
  6464. }
  6465. else
  6466. {
  6467. $klarnadata['color'] = $klarnadata3;
  6468. }
  6469. }
  6470. }
  6471. else
  6472. {
  6473. $klarnadata = '';
  6474. }
  6475. $p = explode('-',$fullorder['paypal']);
  6476. $this->data['klarnacolor'] = $klarnacolor;
  6477. $this->data['klarnadata'] = $klarnadata;
  6478. $this->data['systemwigsout'] = $outread;
  6479. $this->_Template('fullorder_zw',$this->data);
  6480. }
  6481. public function _dcdxyz()
  6482. {
  6483. $post = $this->input->get(NULL, TRUE);
  6484. if(isset($post['timetk']))
  6485. {
  6486. $timetk = $this->input->get('timetk',true);
  6487. $timetj = $this->input->get('timetj',true);
  6488. $timetk = strtotime($timetk);
  6489. $timetj = strtotime($timetj);
  6490. $where = "oldwaybill != ''";
  6491. if($timetk && $timetj)
  6492. {
  6493. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  6494. }
  6495. //数据排序
  6496. $order_str = "dtime desc";
  6497. //取得信息列表
  6498. $info_list = $this->fullorder->find_all($where,'orderinfo,number,oldwaybill',$order_str);
  6499. $data = array();
  6500. foreach ($info_list as $key=>$value)
  6501. {
  6502. $ob = '';
  6503. $oldwaybill = explode('-',trim($value['oldwaybill'],'-'));
  6504. if(count($oldwaybill) < 2)
  6505. {
  6506. continue;
  6507. }
  6508. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  6509. foreach ($oldwaybill as $v)
  6510. {
  6511. $dw = explode('/',$v);
  6512. if(isset($dw[1]))
  6513. {
  6514. $dwls[$dw[1]] = 1;
  6515. $ob .= $dw[1].'、';
  6516. }
  6517. }
  6518. $info_list[$key]['oldwaybill'] = trim($ob,'、');
  6519. $data[] = $info_list[$key];
  6520. }
  6521. $title = "多运单信息 ".date("Y-m-d");
  6522. $titlename = "<table border=1>
  6523. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  6524. <tr>
  6525. <td>订单号</td>
  6526. <td>编号</td>
  6527. <td>运单号</td>
  6528. </tr>
  6529. </table>";
  6530. $filename = $title.".xls";
  6531. $tail = "\n";
  6532. $this->excel->get_fz2($data,$titlename,$filename,$tail);
  6533. }
  6534. }
  6535. public function _thxz()
  6536. {
  6537. $post = $this->input->get(NULL, TRUE);
  6538. if(isset($post['timetk']))
  6539. {
  6540. $timetk = $this->input->get('timetk',true);
  6541. $timetj = $this->input->get('timetj',true);
  6542. $timetk = strtotime($timetk);
  6543. $timetj = strtotime($timetj);
  6544. $where = "returndata != ''";
  6545. if($timetk && $timetj)
  6546. {
  6547. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  6548. }
  6549. //数据排序
  6550. $order_str = "dtime desc";
  6551. //取得信息列表
  6552. $info_list = $this->fullorder->find_all($where,'orderinfo,number,returndata',$order_str);
  6553. foreach ($info_list as $key=>$value)
  6554. {
  6555. $ydh = explode('">',$value['returndata']);
  6556. $ydh = explode('</a>',$ydh[1]);
  6557. $info_list[$key]['returndata'] = $ydh[0];
  6558. $time = explode('pdf/',$value['returndata']);
  6559. $time = explode('/',$time[1]);
  6560. $info_list[$key]['time'] = $time[0];
  6561. }
  6562. $title = "退货订单信息 ".date("Y-m-d");
  6563. $titlename = "<table border=1>
  6564. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  6565. <tr>
  6566. <td>订单号</td>
  6567. <td>编号</td>
  6568. <td>退货运单号</td>
  6569. <td>退货时间</td>
  6570. </tr>
  6571. </table>";
  6572. $filename = $title.".xls";
  6573. $tail = "\n";
  6574. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  6575. }
  6576. }
  6577. public function _ddcf()
  6578. {
  6579. $post = $this->input->post(NULL, TRUE);
  6580. if(isset($post['number']))
  6581. {
  6582. $number = $this->input->post('number',true);
  6583. $data = $this->fullorder->get_number($number);
  6584. if(!$data)
  6585. {
  6586. echo json_encode(array('msg'=>'没有找到此订单','success'=>false));exit;
  6587. }
  6588. if($data['review'] != 1 && $data['review'] != 2)
  6589. {
  6590. echo json_encode(array('msg'=>'必须是 待审核 状态才能拆分','success'=>false));exit;
  6591. }
  6592. if($data['merge'] != 0)
  6593. {
  6594. echo json_encode(array('msg'=>'已合并的订单无法使用此拆分功能','success'=>false));exit;
  6595. }
  6596. $cfnum = explode('-',trim($number,'-'));
  6597. // if((count($cfnum) > 3 && stripos($number,'-PF-') === false))
  6598. // {
  6599. // echo json_encode(array('msg'=>'只能在原单操作拆分','success'=>false));exit;
  6600. // }
  6601. if(count($cfnum) > 4 && stripos($number,'-PF-') !== false)
  6602. {
  6603. echo json_encode(array('msg'=>'只能在原单操作拆分','success'=>false));exit;
  6604. }
  6605. $num = $this->fullorder->find_count("number like '".$number."%'");
  6606. $data['number'] = $data['number'].'-'.$num;
  6607. $data['orderinfo'] = $data['shop'].date('ymdHis',time()).rand(0,1);;
  6608. $data['shouldmoney'] = 0;
  6609. $data['budget'] = 0;
  6610. $data['shipremarks'] = '';
  6611. $data['source'] = 1;
  6612. //$data['review'] = 2;
  6613. $data['extra_status'] = 1;//拆分的订单
  6614. unset($data['id']);
  6615. unset($data['jweight']);
  6616. unset($data['fpcount']);
  6617. unset($data['returndata']);
  6618. unset($data['waybill']);
  6619. unset($data['oldwaybill']);
  6620. unset($data['printtime']);
  6621. if($this->fullorder->insert($data))
  6622. {
  6623. echo json_encode(array('msg'=>'拆分成功!新订单编号:'.$data['number'],'success'=>true));exit;
  6624. }
  6625. else
  6626. {
  6627. echo json_encode(array('msg'=>'拆分失败,请重试','success'=>false));exit;
  6628. }
  6629. }
  6630. }
  6631. public function _cf() //合并订单拆分
  6632. {
  6633. $post = $this->input->post(NULL, TRUE);
  6634. if(isset($post['id']))
  6635. {
  6636. $id = $this->input->post('id',true);
  6637. $b = $this->fullorder->read($id);
  6638. $order = array();
  6639. if($b['merge'] == $b['id'])
  6640. {
  6641. $data = $this->fullorder->find_all("merge = '".$b['merge']."'");
  6642. foreach ($data as $v)
  6643. {
  6644. $a = $this->fullorderhb->get_orderinfo($v['orderinfo']);
  6645. if($a)
  6646. {
  6647. $this->fullorder->save($a,$v['id']);
  6648. }
  6649. $order[] = $v['id'];
  6650. }
  6651. echo json_encode(array('msg'=>'拆分成功!','d'=>$order,'success'=>true));exit;
  6652. }
  6653. else
  6654. {
  6655. echo json_encode(array('msg'=>'拆分条件错误!','success'=>false));exit;
  6656. }
  6657. }
  6658. }
  6659. }