Fullorder.php 238 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786
  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 <= 2 and number NOT like '%-%-%-%' and (".rtrim($fgshop,'or').")";
  822. $where = "print != 999 and state = 207 and review <= 2 and (".rtrim($fgshop,'or').")";
  823. if($shop)
  824. {
  825. $where .= " and shop = '$shop'";
  826. }
  827. if($email)
  828. {
  829. $where .= " and email = '$email'";
  830. }
  831. if($timetk && $timetj)
  832. {
  833. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  834. }
  835. //数据排序
  836. $order_str = "id desc";
  837. if(empty($page))
  838. {
  839. $start = 0;
  840. $perpage = 1;
  841. }
  842. else
  843. {
  844. $start = ($page - 1)*$perpage;
  845. }
  846. //取得信息列表
  847. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,name,email,address,state,dtime,shipremarks,type,merge');
  848. $info = array();
  849. $len = count($info_list);
  850. //格式化数据
  851. foreach ($info_list as $key=>$value)
  852. {
  853. $ud = $this->fullorder->read($value['id']);
  854. $shop = $this->shop->read($value['shop']);
  855. $warehouse = $this->warehouse->read($value['type']);
  856. $info_list[$key]['shop'] = '<p>'.$shop['shopname'].'</p>'.'<p>'.$warehouse['title'].'</p>';
  857. $info_list[$key]['email'] = '<p>'.$value['email'].'</p>'.'<p>'.$ud['phone'].'</p>';
  858. $typeclass = $this->typeclass->read($value['state']);
  859. $info_list[$key]['state'] = $typeclass['spare'];
  860. $info_list[$key]['type'] = $ud['orderremarks'];
  861. $info_list[$key]['dtime'] = '<p>'.date('Y-m-d',$value['dtime']).'</p><p>'.date('H:i:s',$value['dtime']).'</p>';
  862. if($value['merge'] == 0)
  863. {
  864. $info_list[$key]['merge'] = "<p>可合并</p>";
  865. }
  866. else
  867. {
  868. if($value['merge'] == $value['id'])
  869. {
  870. if($ud['print'] < '3' && $ud['library'] == '1')
  871. {
  872. $info_list[$key]['merge'] = "<p><b class='cforder' data-id='".$value['id']."'>拆分订单</b></p>";
  873. }
  874. else
  875. {
  876. $info_list[$key]['merge'] = "已合并";
  877. }
  878. }
  879. else
  880. {
  881. $info_list[$key]['merge'] = "被合并";
  882. }
  883. }
  884. }
  885. /** 操作合并
  886. if($value['merge'] == 0)
  887. {
  888. $info_list[$key]['merge'] = "<p><b class='jd' data-type='5'>合并订单</b></p>";
  889. }
  890. else
  891. {
  892. if($value['merge'] == $value['id'])
  893. {
  894. $info_list[$key]['merge'] = "已合并";
  895. }
  896. else
  897. {
  898. $info_list[$key]['merge'] = "被合并";
  899. }
  900. }
  901. **/
  902. $asd = array();
  903. for($i=0;$i<$len;$i++)
  904. {
  905. for($j=$i+1;$j<$len;$j++)
  906. {
  907. 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']
  908. {
  909. if(!array_key_exists($j,$info))
  910. {
  911. $info[$j] = $info_list[$j];
  912. }
  913. if(!array_key_exists($i,$info))
  914. {
  915. $info[$i] = $info_list[$i];
  916. }
  917. }
  918. }
  919. }
  920. rsort($info);
  921. $total = count($info);
  922. $pagenum = ceil($total/$perpage);
  923. $over = $total-($start+$perpage);
  924. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_slice($info,$start,$perpage)));
  925. echo json_encode($rows);exit;
  926. }
  927. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  928. $this->data['wlshop'] = $wlshop;
  929. $this->_Template('fullorder_repeat',$this->data);
  930. }
  931. //修改
  932. public function _edit($arg_array)
  933. {
  934. if(isset($_SESSION['api']))
  935. {
  936. $user = $this->user->get_api($_SESSION['api']);
  937. if($user['vip'] == 1)
  938. {
  939. $vip = 1;
  940. }
  941. else
  942. {
  943. $vip = 0;
  944. }
  945. $this->data['userid'] = $user['id'];
  946. }
  947. else
  948. {
  949. $this->data['userid'] = 0;
  950. $vip = 0;
  951. }
  952. $post = $this->input->post(NULL, TRUE);
  953. if(isset($post['id']))
  954. {
  955. // $dtsbjz = $this->input->post('dtsbjz',true);
  956. // $ts = $this->input->post('ts',true);
  957. // $dtsbjz = sprintf("%.2f",$dtsbjz);
  958. // $total_sbjz = $dtsbjz*$ts;
  959. // $tmp_zsbjz = $this->input->post('zsbjz',true);
  960. // $tmp_zsbjz = sprintf("%.2f",$tmp_zsbjz);
  961. // if($tmp_zsbjz*1 != $total_sbjz){
  962. // echo json_encode(array('msg'=>'单条申报价为2为小数!','success'=>false));exit;
  963. // }
  964. $id = $this->input->post('id',true);
  965. $data = $this->fullorder->read($id);
  966. $post['type'] = $this->input->post('warehouse',true);
  967. $post['country'] = $this->input->post('country',true);
  968. $currency = $this->country->read($post['country']);
  969. $post['al'] = $currency['lb'];
  970. $post['freight'] = $this->input->post('freight',true);
  971. $post['expressmoney'] = $this->input->post('expressmoney',true);
  972. $post['shouldmoney'] = $this->input->post('shouldmoney',true);
  973. $orderremarks = $this->input->post('orderremarks');
  974. $orderremarks = str_replace(array('%26','%2B'),array('&','+'),$orderremarks);
  975. $post['orderremarks'] = $orderremarks;
  976. $shipremarks = $this->input->post('shipremarks');
  977. $shipremarks = str_replace(array('%26','%2B'),array('&','+'),$shipremarks);
  978. $post['shipremarks'] = preg_replace('/( | | |\s)/',' ',$shipremarks);
  979. $email = $this->input->post('email',true);
  980. $post['email'] = preg_replace('/( | | |\s)/','',$email);
  981. //$post['paypal'] = $this->input->post('paypal',true);
  982. $name = $this->input->post('name',true);
  983. $post['name'] = str_replace("'","’",$name);
  984. $post['phone'] = $this->input->post('phone',true);
  985. $post['phone'] = preg_replace('/\D/s','',$post['phone']);
  986. $post['phone'] = preg_replace('/( | | |\s)/','',$post['phone']);
  987. $post['country'] = $this->input->post('country',true);
  988. $post['province'] = $this->input->post('province',true);//省、州
  989. $post['province'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['province']); //替换开头空字符
  990. $post['province'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['province']); //替换结尾空字符
  991. $post['city'] = $this->input->post('city',true);//城市
  992. $post['city'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['city']); //替换开头空字符
  993. $post['city'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['city']); //替换结尾空字符
  994. $post['zipcode'] = $this->input->post('zipcode',true);//邮编
  995. $post['zipcode'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['zipcode']); //替换开头空字符
  996. $post['zipcode'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['zipcode']); //替换结尾空字符
  997. $post['street'] = $this->input->post('street',true);
  998. $address = $this->input->post('address',true);
  999. $address = preg_replace('/( | | |\s)/',' ',$address);
  1000. $post['address'] = str_replace("'","’",$address);
  1001. $address2 = $this->input->post('address2',true);
  1002. $address2 = preg_replace('/( | | |\s)/',' ',$address2);
  1003. if($address2 == ' ')
  1004. {
  1005. $address2 = '';
  1006. }
  1007. $post['address2'] = str_replace("'","’",$address2);
  1008. $post['express'] = $this->input->post('express',true);
  1009. $post['printtype'] = $this->input->post('printtype',true);
  1010. $fpdata = $this->input->post('fpdata');
  1011. $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
  1012. $post['fpdata'] = $fpdata;
  1013. $post['waybill'] = $this->input->post('waybill',true);
  1014. $post['msg'] = $this->input->post('msg',true);
  1015. $post['zsbjz'] = $this->input->post('zsbjz',true);
  1016. $post['refundy'] = $this->input->post('refundy',true);
  1017. $post['refundj'] = $this->input->post('refundj',true);
  1018. $rtime = $this->input->post('rtime',true);
  1019. $post['rtime'] = strtotime($rtime);
  1020. $post['rpaypal'] = $this->input->post('rpaypal',true);
  1021. $post['rtext'] = $this->input->post('rtext',true);
  1022. $post['sbpm'] = $this->input->post('sbpm',true);
  1023. $post['edittime'] = time();
  1024. $editstate = $this->input->post('state',true);
  1025. if(!$editstate)
  1026. {
  1027. $editstate = $data['state'];
  1028. }
  1029. $whlabel = $this->input->post('whlabel',true);
  1030. $fpcount = $this->input->post('fpcount',true);
  1031. $post['ioss'] = $this->input->post('ioss',true);
  1032. $post['waybill'] = preg_replace('/( | | | |\s)/','',$post['waybill']);
  1033. $pay = $this->pay->get_typeclass($data['pay']);
  1034. $yga = $post['shouldmoney'];
  1035. $ygc = $data['estimaterate'];
  1036. $post['budget'] = 0;
  1037. if($post['email'] == $post['send_email']){
  1038. $post['send_email'] = '';
  1039. }
  1040. $ifbudget = eval("return $yga*1.$ygc;");
  1041. if($ifbudget > 0)
  1042. {
  1043. $post['budget'] = eval("return $yga*1.$ygc;");
  1044. }
  1045. if($data['estimaterate'] == 1){
  1046. $post['budget'] = $post['shouldmoney'];
  1047. }
  1048. $whlabeldata = explode('|',trim($whlabel,'|'));$way = 0;
  1049. foreach ($whlabeldata as $va)
  1050. {
  1051. if(stripos($va,'z') !== false)
  1052. {
  1053. $way += 1;
  1054. }
  1055. }
  1056. //如果备注中出现网红的两个字 ,那么在fpdata种的品名中必须有 WH这两个字 且美仓不用
  1057. if($post['type'] !=5 ){
  1058. if(stripos($post['shipremarks'],'网红') !== false){
  1059. if(stripos($post['fpdata'],'-2090-') === false){
  1060. echo json_encode(array('msg'=>'网红单请在商品名称中勾选WH!','success'=>false));exit;
  1061. }
  1062. }
  1063. }
  1064. if((($post['express'] == 2 || $post['express'] == 63 || $post['express'] == 64 || $post['express'] == 81 || $post['express'] == 85 || $post['express'] == 87 ) && $post['type'] != 5) )
  1065. {
  1066. echo json_encode(array('msg'=>'此快递方式必须从美仓发货!','success'=>false));exit;
  1067. }
  1068. // if( ($post['express'] != 2 && $post['express'] != 63 && $post['express'] != 64 && $post['express'] != 81 && $post['express'] != 85 && $post['express'] != 87 && $post['type'] == 5)){
  1069. // echo json_encode(array('msg'=>'此快递方式不能美仓发货!','success'=>false));exit;
  1070. // }
  1071. if((!in_array($post['express'],[2,63,64,81,85,86,87])) && ($post['type'] == 5)){
  1072. echo json_encode(array('msg'=>'此快递方式不能美仓发货!','success'=>false));exit;
  1073. }
  1074. //仅独立站 地址美国对电话 10或者11位进行判断
  1075. if($post['country'] == 192){
  1076. if((strlen($post['phone'])!= 10) && (strlen($post['phone'])!= 11)){
  1077. echo json_encode(array('msg'=>'美国电话号码应为10/11位!','success'=>false));exit;
  1078. }
  1079. }
  1080. //减少代码复用吧
  1081. $lo_ret = $this->logic_order->checkEditExpress($post);
  1082. if($lo_ret['code'] != 1){
  1083. echo json_encode(array('msg'=>$lo_ret['msg'],'success'=>false));exit;
  1084. }
  1085. //检测PayPal有但是为空的情况
  1086. if(isset($post['paypal'])){
  1087. if(empty($post['paypal'])){
  1088. echo json_encode(array('msg'=>'交易号不可为空!','success'=>false));exit;
  1089. }
  1090. }else{
  1091. $tmp_info = $this->fullorder->read($post['id']);
  1092. if(empty($tmp_info)){
  1093. echo json_encode(array('msg'=>'订单信息异常','success'=>false));exit;
  1094. }
  1095. if(empty($tmp_info['paypal'])){
  1096. echo json_encode(array('msg'=>'交易号不可为空!','success'=>false));exit;
  1097. }
  1098. }
  1099. // if($post['express'] == 42 && $post['sbpm'] != 'Human Hair Wigs' && $post['sbpm'] != 'Human Hair Goods')//$post['express'] == 3 ||
  1100. // {
  1101. // echo json_encode(array('msg'=>'此快递方式必须选择Human Hair Wigs/Human Hair Goods!','success'=>false));exit;
  1102. // }
  1103. // if($post['express'] == 24 && $post['sbpm'] != 'Hair Sample' && $post['sbpm'] != 'Human Hair Wigs' && $post['sbpm'] != 'Human Hair Goods')//$post['express'] == 3 ||
  1104. // {
  1105. // echo json_encode(array('msg'=>'此快递方式必须选择Hair Sample/Human Hair Wigs/Human Hair Goods!','success'=>false));exit;
  1106. // }
  1107. // if($post['country'] != 192 && $post['express'] == 1 && $post['sbpm'] != 'Synthetic Hair Wigs' && $post['sbpm'] != 'Synthetic Hair Goods')//$post['express'] == 3 ||
  1108. // {
  1109. // echo json_encode(array('msg'=>'非美国选择官方DHL必须选择Synthetic Hair Wigs/Synthetic Hair Goods','success'=>false));exit;
  1110. // }
  1111. if($way == count($whlabeldata) && $post['type'] != 12)
  1112. {
  1113. echo json_encode(array('msg'=>'必须选择特殊仓!','success'=>false));exit;
  1114. }
  1115. if($way == '0' && $post['type'] == 12)
  1116. {
  1117. echo json_encode(array('msg'=>'特殊仓必须包含特殊仓货物!','success'=>false));exit;
  1118. }
  1119. $post['review'] = 1;
  1120. if($post['zsbjz'] < '0.01')
  1121. {
  1122. echo json_encode(array('msg'=>'总申报价错误!','success'=>false));exit;
  1123. }
  1124. if($data['library'] == 1)
  1125. {
  1126. if($data['print'] != 3)
  1127. {
  1128. $post['print'] = 1;
  1129. $post['libraryconfirm'] = 1;
  1130. $post['librarynot'] = "订单未打印,未审核或未通过";
  1131. }
  1132. else
  1133. {
  1134. $post['libraryconfirm'] = 1;
  1135. $post['librarynot'] = "订单被修改或重新提交";
  1136. }
  1137. }
  1138. if($data['yhs'] == 1)
  1139. {
  1140. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  1141. }
  1142. if($post['express'] == 2 && (stripos($post['name'],'&') !== false || stripos($post['name'],"'") !== false))
  1143. {
  1144. echo json_encode(array('msg'=>'USPS收件人或公司名不可用特殊符号!','success'=>false));exit;
  1145. }
  1146. if(strlen($post['client']) > 34 || strlen($post['name']) > 34)//收件人姓名或公司名不允许超过35位
  1147. {
  1148. echo json_encode(array('msg'=>'收件人姓名或公司名不可超过34个字符!','success'=>false));exit;
  1149. }
  1150. if($post['express'] == '3' && $post['address2'] != '')//UPS不允许提交地址2
  1151. {
  1152. echo json_encode(array('msg'=>'UPS不允许提交地址2','success'=>false));exit;
  1153. }
  1154. if(($post['express'] == '5' || $post['express'] == '24' || $post['express'] == '42' || $post['express'] == '31') && $post['country'] != 192)
  1155. {
  1156. echo json_encode(array('msg'=>'非美国无法选择Fedex、DHL官方-美国!','success'=>false));exit;
  1157. }
  1158. if($post['express'] == '3' && $post['country'] != 192 && $post['country'] != 35)
  1159. {
  1160. echo json_encode(array('msg'=>'非美国和加拿大无法选择UPS!','success'=>false));exit;
  1161. }
  1162. if($post['country'] == 35 && $post['zsbjz'] > 20)
  1163. {
  1164. echo json_encode(array('msg'=>'加拿大最高申报不可超过20','success'=>false));exit;
  1165. }
  1166. if(($post['express'] == '28' || $post['express'] == '7') && $post['country'] != 191)
  1167. {
  1168. echo json_encode(array('msg'=>'非英国无法选择CNE和GES!','success'=>false));exit;
  1169. }
  1170. $express = $this->express->read($post['express']);
  1171. if($express['ioss'] == 1 && $post['ioss'] == '')
  1172. {
  1173. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  1174. }
  1175. if(strlen($post['address']) > $express['addresssize'] || strlen($post['address2']) > $express['addresssize'])
  1176. {
  1177. echo json_encode(array('msg'=>'此快递地址不可超出'.$express['addresssize'].'个字符','success'=>false));exit;
  1178. }
  1179. if(strlen($post['address']) < 5)
  1180. {
  1181. echo json_encode(array('msg'=>'地址不可留空!','success'=>false));exit;
  1182. }
  1183. if(($express['sbjz'] > 0) && ($post['zsbjz'] > $express['sbjz']))
  1184. {
  1185. echo json_encode(array('msg'=>'总申报价值不可超出'.$express['sbjz'],'success'=>false));exit;
  1186. }
  1187. if($post['shouldmoney'] > $express['shouldmoney'] && $express['shouldmoney'] != 0)
  1188. {
  1189. echo json_encode(array('msg'=>'订单金额不可超出'.$express['shouldmoney'],'success'=>false));exit;
  1190. }
  1191. if($post['express'] == '2' && $post['zzl'] > '16' && isset($post['js']) && $post['js'] == '0')
  1192. {
  1193. echo json_encode(array('msg'=>'重量大于16不可按Ground Advantage提交!','success'=>false));exit;
  1194. }
  1195. // if($post['express'] == '2' && isset($post['js']) && $post['js'] == '0'&& $post['qm'] == '1')
  1196. // {
  1197. // echo json_encode(array('msg'=>'Ground Advantage不可使用签名服务!','success'=>false));exit;
  1198. // }
  1199. if(isset($post['bx']))
  1200. {
  1201. if($post['express'] == '99' && $post['bx'] > 0)
  1202. {
  1203. echo json_encode(array('msg'=>'此物流不允许购买保险','success'=>false));exit;
  1204. }
  1205. }
  1206. if(($post['express'] == '3' || $post['express'] == '42' || $post['express'] == '24') && $post['shouldmoney'] < 1)
  1207. {
  1208. //echo json_encode(array('msg'=>'零金额订单不可发 UPS/DHL官方-美国/Fedex(杭州)','success'=>false));exit;
  1209. }
  1210. if($post['express'] == '42' && $post['zsbjz'] < 1)
  1211. {
  1212. echo json_encode(array('msg'=>'零申报金额不可发 DHL官方-美国','success'=>false));exit;
  1213. }
  1214. if($post['express'] == '6' && $post['province'] == '')
  1215. {
  1216. echo json_encode(array('msg'=>'选择DPEX必须填写州信息','success'=>false));exit;
  1217. }
  1218. if(($post['express'] == '3') && $post['shouldmoney'] == 0)
  1219. {
  1220. echo json_encode(array('msg'=>'0金额订单不可发UPS/Fedex(杭州)!!!','success'=>false));exit;
  1221. }
  1222. if($post['country'] == '35' && $post['zsbjz'] > 20)
  1223. {
  1224. echo json_encode(array('msg'=>'加拿大不可申报超过20美金!!!','success'=>false));exit;
  1225. }
  1226. if($post['printtype'] == 1)//如果是运单
  1227. {
  1228. $post['productdescription'] = $this->input->post('productdescription',true);
  1229. $post['customs'] = $this->input->post('customs',true);
  1230. }
  1231. if($post['express'] == 2 && strlen($post['zipcode']) != 5)//如果usps 邮编不是5位
  1232. {
  1233. echo json_encode(array('msg'=>'USPS-USA的邮编需按5位数格式提交!','success'=>false));exit;
  1234. }
  1235. if(strlen($post['phone']) > 11 && $post['express'] == 63)
  1236. {
  1237. echo json_encode(array('msg'=>'美国联邦,电话号码不允许超过11位!','success'=>false));exit;
  1238. }
  1239. /**
  1240. if($post['paypal'] != '')
  1241. {
  1242. $pp = $this->fullorder->get_paypal($post['paypal']);
  1243. if(isset($pp['number']) && $pp['number'] != $data['number'])
  1244. {
  1245. echo json_encode(array('msg'=>'此交易号的订单已存在!-'.$pp['number'],'success'=>false));exit;
  1246. }
  1247. }
  1248. **/
  1249. /**
  1250. if($editstate == 216 && $data['state'] != 216)
  1251. {
  1252. echo json_encode(array('msg'=>'不可修改为完成状态','success'=>false));exit;
  1253. }
  1254. **/
  1255. $post['review'] = $data['review'];
  1256. $post['state'] = $editstate;
  1257. if($editstate == 216)
  1258. {
  1259. foreach ($post as $k=>$v)
  1260. {
  1261. 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')
  1262. {
  1263. continue;
  1264. }
  1265. else
  1266. {
  1267. //当时不知道为会把 当前不可修改订单信息 给注释掉 但是 如果注释掉 这个判断就没意义了 还引起了报错 我这里就注释掉了
  1268. // if($v != $data[$k])
  1269. // {
  1270. // //echo json_encode(array('msg'=>'当前不可修改订单信息','cs'=>$k,'success'=>false));exit;
  1271. // }
  1272. }
  1273. }
  1274. }
  1275. /**
  1276. if($editstate == 216 && $post['waybill'] != '' && $data['waybill'] != '')//if($editstate == 216 && preg_match('/\d/is',$post['waybill']) != true)
  1277. {
  1278. echo json_encode(array('msg'=>'当前信息不可修改订单状态','success'=>false));exit;
  1279. }
  1280. else
  1281. {
  1282. $post['review'] = $data['review'];
  1283. $post['state'] = $editstate;
  1284. }
  1285. **/
  1286. $thisdata = $this->fullorder->read($id);
  1287. $warehouse = $this->warehouse->read($thisdata['type']);
  1288. $warehousenew = $this->warehouse->read($post['type']);
  1289. if($warehousenew['bdcountry'] != 0 && $post['country'] != $warehousenew['bdcountry'])
  1290. {
  1291. echo json_encode(array('msg'=>'当前国家无法选择'.$warehousenew['title'].'!','success'=>false));exit;
  1292. }
  1293. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  1294. {
  1295. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  1296. }
  1297. $expt = $this->express->read($post['express']);
  1298. if($expt['pt'] != '' && stripos($post['fpdata'],$expt['pt']) !== false)
  1299. {
  1300. echo json_encode(array('msg'=>$expt['ptts'],'success'=>false));exit;
  1301. }
  1302. if($expt['province'] != '' && stripos($expt['province'],$post['province'].'、') !== false)
  1303. {
  1304. echo json_encode(array('msg'=>'此省/州不可使用 '.$expt['servicename'],'success'=>false));exit;
  1305. }
  1306. /**
  1307. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  1308. {
  1309. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  1310. }
  1311. **/
  1312. //开始注释 xyxg
  1313. /**
  1314. $ft = array();
  1315. $ftdata = explode('|',rtrim($fpcount,'|'));
  1316. foreach ($ftdata as $va)
  1317. {
  1318. $ftitle = '';
  1319. $va = explode('-',trim($va,'-'));
  1320. foreach ($va as $v)
  1321. {
  1322. $v = $this->typeclass->read($v);
  1323. $ftitle .= $v['title'].' ';
  1324. }
  1325. $ft[] = rtrim($ftitle,' ');
  1326. }
  1327. if($data['library'] == 1)
  1328. {
  1329. $tqkcyz = $this->_kcyz($post['type'],$whlabel,$id,$data['shop'],$data['number']);
  1330. if(isset($tqkcyz[0]))
  1331. {
  1332. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$tqkcyz,'success'=>false));exit;
  1333. }
  1334. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  1335. {
  1336. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  1337. if($tskcyz['t'] > '0')
  1338. {
  1339. echo $tskcyz['m'];exit;
  1340. }
  1341. }
  1342. $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']);//旧状态、新状态、仓库占单设置、仓库预设设置、新仓库、新产品简化数字、旧产品数字、旧产品名称、订单号、订单店铺、旧订单仓库、旧产品简化数字
  1343. if($kcyz['t'] > '0')
  1344. {
  1345. echo $kcyz['m'];exit;
  1346. }
  1347. }
  1348. //结束注释
  1349. **/
  1350. /** 重新写产品名称
  1351. $dtctitle = array();
  1352. $dictionaries = $this->typeclass->find_all();
  1353. foreach ($dictionaries as $v)
  1354. {
  1355. $dtctitle[$v['id']] = array($v['title'],$v['bqsku']);
  1356. }
  1357. if(stripos($fpdata,'-128-') !== false || stripos($fpdata,'-127-') !== false)
  1358. {
  1359. $dfp = explode(';',trim($fpdata,';'));
  1360. $fdata = '';
  1361. foreach ($dfp as $k=>$v)
  1362. {
  1363. $ptitleb = '';
  1364. $fp = explode('|',trim($v,'|'));
  1365. $fp0 = explode(',',$fp[0]);
  1366. $fp1 = explode('-',trim($fp0[1],'-'));
  1367. foreach ($fp1 as $vv)
  1368. {
  1369. $ptitleb .= isset($dtctitle[$vv])?$dtctitle[$vv][0].' ':'';
  1370. }
  1371. $ptitleb .= $dtctitle[$fp0[0]][1].'inch ';
  1372. $fp[1] = $ptitleb;
  1373. $fdata .= implode("|",$fp).";";
  1374. }
  1375. $fpdata = $fdata;
  1376. }
  1377. **/
  1378. $warehouse = $this->warehouse->read($post['type']);
  1379. //未出库或者(已退库并且订单的状态不是等待买家收货和代发货状态)
  1380. if($data['library'] == 1 || ($data['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  1381. {
  1382. // echo "<pre>";
  1383. // var_dump($post['state']);
  1384. // var_dump($warehouse);
  1385. // var_dump($thisdata['shop']);
  1386. // var_dump($thisdata['number']);
  1387. // var_dump($whlabel);
  1388. // var_dump($fpdata);
  1389. // die;
  1390. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  1391. if($kcyz['t'] > '0')
  1392. {
  1393. echo $kcyz['m'];exit;
  1394. }
  1395. else if($kcyz['fpdata'] != '')
  1396. {
  1397. $post['whlabel'] = $kcyz['whlabel'];
  1398. $post['fpdata'] = $kcyz['fpdata'];
  1399. }
  1400. }
  1401. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  1402. $post['sfxh'] = $fl['sfxh'];
  1403. $post['ckfl'] = $fl['ckfl'];
  1404. //查询净重开始
  1405. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  1406. unset($post[0]);
  1407. //查询净重结束
  1408. if($this->fullorder->save($post,$id))
  1409. {
  1410. if($data['printtime'] == '0')
  1411. {
  1412. $xghz = ',将自动禁止打印';
  1413. }
  1414. else if($data['printtime'] > '0' && $data['librarytime'] == '0')
  1415. {
  1416. $q = '';
  1417. if($data['libraryconfirm'] == 1)
  1418. {
  1419. $q = ',<em style="color: #F00;">改前状态为:禁止出库</em>';
  1420. }
  1421. $xghz = ',将自动禁止发货'.$q;
  1422. }
  1423. else
  1424. {
  1425. $xghz = '';
  1426. }
  1427. echo json_encode(array('msg'=>'修改成功'.$xghz,'id'=>$id,'success'=>true));exit;
  1428. }
  1429. else
  1430. {
  1431. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  1432. }
  1433. }
  1434. $this->data['vip'] = $vip;
  1435. $arg_array = $arg_array[0];$fpdata = array();
  1436. $fullorder = $this->fullorder->read($arg_array);
  1437. $returngoods = $this->returngoods->get_orderinfo($fullorder['orderinfo']);
  1438. $this->data['returngoods'] = 0;
  1439. if(!empty($returngoods)){
  1440. if($returngoods['status'] != 120){
  1441. $this->data['returngoods'] = 1;
  1442. }
  1443. }
  1444. $fullorder['parameter'] = str_replace(",","---",$fullorder['parameter']);
  1445. $country = $this->country->find_all('1=1','id,name','name asc');//所有国家信息
  1446. $express = $this->express->find_all('1=1');//所有快递配置信息
  1447. $this->data['fullorder'] = $fullorder;
  1448. if($fullorder['express'] == 2)
  1449. {
  1450. $zzhl = 'oz';
  1451. }
  1452. else
  1453. {
  1454. $zzhl = 'kg';
  1455. }
  1456. $this->data['zzhl'] = $zzhl;
  1457. $this->data['country'] = $country;
  1458. $this->data['express'] = $express;
  1459. $this->data['dtime'] = date('Y-m-d H:i:s',$fullorder['dtime']);
  1460. $warehouse = $this->warehouse->read($fullorder['type']);
  1461. if(stripos($fullorder['fpdata'],';') !== false)
  1462. {
  1463. $fpdata = explode(';',rtrim($fullorder['fpdata'],';'));
  1464. foreach ($fpdata as $k=>$v)
  1465. {
  1466. $xxv = explode('|',$v);
  1467. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  1468. {
  1469. $xxv['zd'] = "<p>已占单</p>";
  1470. $bdck = $warehouse['bdck'];
  1471. if(stripos($xxv[9],'~') !== false)
  1472. {
  1473. $dxxv = explode('~',trim($xxv[9],'~'));
  1474. foreach ($dxxv as $val)
  1475. {
  1476. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  1477. if($wzid['details'] != '')
  1478. {
  1479. if($fullorder['type'] == 5){
  1480. $xxv['zd'] .= '<p>位置:'.$wzid['details'].'</p>';
  1481. }else{
  1482. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1483. }
  1484. }
  1485. }
  1486. }
  1487. else
  1488. {
  1489. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  1490. if($wzid['details'] != '')
  1491. {
  1492. if($fullorder['type'] == 5){
  1493. $xxv['zd'] .= '<p>位置:'.$wzid['details'].'</p>';
  1494. }else{
  1495. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1496. }
  1497. }
  1498. }
  1499. }
  1500. $fpdata[$k] = $xxv;
  1501. }
  1502. }
  1503. $fpdata = $this->logic_order->checkOrderProduct($fpdata);
  1504. $tmp_features = array_column($fpdata,0);
  1505. $do_trans_pms = [];
  1506. foreach ($tmp_features as $k=>$v) {
  1507. if(strpos($v,",") === false){
  1508. $do_trans_pms[] = [
  1509. 'features'=>$v
  1510. ];
  1511. }else{
  1512. $tmp_arr = explode(",",$v);
  1513. $do_trans_pms[] = [
  1514. 'features'=>$tmp_arr[1].$tmp_arr[0]."-"
  1515. ];
  1516. }
  1517. }
  1518. $r = $this->logic_whlabel->dataTran($do_trans_pms,['pm']);
  1519. foreach ($fpdata as $k=>$v) {
  1520. $fpdata[$k]['pm'] = $r[$k]['pm'];
  1521. }
  1522. $this->data['fpdata'] = $fpdata;
  1523. $thfpdataxs = array();
  1524. if($fullorder['thfpdata'] != '')
  1525. {
  1526. $thfpdata = explode(';',trim($fullorder['thfpdata'],';'));
  1527. foreach ($thfpdata as $k=>$v)
  1528. {
  1529. $thxs = explode('~',trim($v,'~'));
  1530. $thxs[0] = explode('|',trim($thxs[0],'|'));
  1531. $thxs[1] = explode('|',trim($thxs[1],'|'));
  1532. $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]);
  1533. }
  1534. }
  1535. $this->data['thfpdata'] = $thfpdataxs;
  1536. $shop = $this->shop->read($fullorder['shop']);
  1537. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  1538. $is = 0;
  1539. if($shop['type'] == 269 || $shop['type'] == 2768)//判断是否独立站,269是独立站
  1540. {
  1541. $is = 1;
  1542. }
  1543. $this->data['is'] = $is;
  1544. if(isset($_SESSION['api']))
  1545. {
  1546. $user = $this->user->get_api($_SESSION['api']);
  1547. if($user['vip'] == 1)
  1548. {
  1549. $vip = 1;
  1550. }
  1551. else
  1552. {
  1553. $vip = 0;
  1554. }
  1555. }
  1556. else
  1557. {
  1558. $vip = 0;
  1559. }
  1560. $this->data['power'] = $vip;
  1561. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  1562. $downwaybill = '';$dwls = array();
  1563. $oldwaybill = explode('-',ltrim($fullorder['oldwaybill'],'-'));
  1564. if(isset($oldwaybill[0][1]))
  1565. {
  1566. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  1567. foreach ($oldwaybill as $v)
  1568. {
  1569. $dw = explode('/',$v);
  1570. if(isset($dw[1]))
  1571. {
  1572. if(stripos($downwaybill,$dw[1]) === false)
  1573. {
  1574. $dwls[$dw[1]] = 1;
  1575. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  1576. }
  1577. }
  1578. }
  1579. }
  1580. if($fullorder['printtype'] == 1)
  1581. {
  1582. if($fullorder['waybill'] != '' && !isset($dwls[$fullorder['waybill']]))
  1583. {
  1584. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullorder['printtime']).'/y-'.$fullorder['waybill'].'.pdf" target="_blank">'.$fullorder['waybill'].'</a>、'.$downwaybill;
  1585. }
  1586. }
  1587. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  1588. /** 历史打印时间 **/
  1589. $printtime = '';
  1590. if($fullorder['oldprinttime'])
  1591. {
  1592. $pte = explode('-',rtrim($fullorder['oldprinttime'],'-'));
  1593. foreach ($pte as $v)
  1594. {
  1595. if(!empty($v)){
  1596. $printtime .= date('Y-m-d H:i:s',$v).'、';
  1597. }
  1598. }
  1599. }
  1600. $this->data['printtime'] = rtrim($printtime,'、');
  1601. $product = '';
  1602. $fullorder['product'] = str_replace("'","",$fullorder['product']);
  1603. if($fullorder['link'] != '' && $fullorder['source'] != '1')
  1604. {
  1605. $pt = explode(',',$fullorder['product']);
  1606. $lk = explode(',',$fullorder['link']);
  1607. for($i=0;$i<count($pt);$i++)
  1608. {
  1609. if(isset($lk[$i]))
  1610. {
  1611. $octs = $this->colourorderts->get_texturl($pt[$i],$lk[$i]);
  1612. }
  1613. else
  1614. {
  1615. $octs = '';
  1616. }
  1617. $a = $octs?'<font style="color:#'.$octs['colour'].'">'.$pt[$i].'</font>':$pt[$i];
  1618. //$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];
  1619. if(isset($lk[$i]))
  1620. {
  1621. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  1622. }
  1623. else
  1624. {
  1625. $product .= ($product != '')?' , '.$a:$a;
  1626. }
  1627. }
  1628. }
  1629. else
  1630. {
  1631. $octs = $this->colourorderts->get_text($fullorder['product']);
  1632. $a = $octs?'<font style="color:#F39">'.$fullorder['product'].'</font>':$fullorder['product'];
  1633. //$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'];
  1634. $product = $a;
  1635. }
  1636. $this->data['product'] = $product;
  1637. $out = $this->systemtransfer->find_all("number = '".$fullorder['number']."'");
  1638. $outread = '';
  1639. if($out)
  1640. {
  1641. foreach ($out as $val)
  1642. {
  1643. $list = '';
  1644. $rk = explode('|',trim($val['rk'],'|'));
  1645. $rktime = explode('|',trim($val['rktime'],'|'));
  1646. $zw = array();
  1647. $t = $this->transfer->find_all("1=1");
  1648. foreach ($t as $v)
  1649. {
  1650. $zw[$v['id']] = $v['title'];
  1651. }
  1652. if($val['rk'] != '' && count($rk) > 0)
  1653. {
  1654. for($i=0;$i<count($rk);$i++)
  1655. {
  1656. if(!isset($rktime[$i]))
  1657. {
  1658. if(isset($cz[$i]))
  1659. {
  1660. $list .= $zw[$cz[$i]];
  1661. }
  1662. }
  1663. else
  1664. {
  1665. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  1666. }
  1667. }
  1668. }
  1669. $outread .= '<span style="color:#f00">'.$val['shipremarks'].'</span>:'.$list.'<br>';
  1670. //$outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  1671. }
  1672. }
  1673. else
  1674. {
  1675. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullorder['number']."'");
  1676. $outread = array();
  1677. if($systemwigsout)
  1678. {
  1679. foreach ($systemwigsout as $v)
  1680. {
  1681. if($v['czwarehouse'] == 37)
  1682. {
  1683. $outread[] = '华荣厂';
  1684. }
  1685. else if($v['czwarehouse'] == 0)
  1686. {
  1687. $outread[] = '龙盈厂';
  1688. }
  1689. $cz = explode('|',trim($v['cz'],'|'));
  1690. $cztime = explode('|',trim($v['cztime'],'|'));
  1691. $zw = $this->transfer->get_list();
  1692. if($v['cz'] != '' && count($cz) > 0)
  1693. {
  1694. for($i=0;$i<count($cz);$i++)
  1695. {
  1696. if(!isset($cztime[$i]))
  1697. {
  1698. $outread[] = $zw[$cz[$i]].' -&gt; ';
  1699. }
  1700. else
  1701. {
  1702. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  1703. }
  1704. }
  1705. $outread[] = '<br>';
  1706. }
  1707. }
  1708. }
  1709. }
  1710. $klarnacolor = '';
  1711. if($fullorder['klarnadata'] !='')
  1712. {
  1713. $klarnadata = explode('|',$fullorder['klarnadata']);
  1714. if($klarnadata[0] == 'paypal' || $klarnadata[0] == 'stripe')
  1715. {
  1716. $klarnadata[1] = json_decode($klarnadata[1],true);
  1717. if($klarnadata[0] == 'stripe' && $klarnadata[1]['shouldmoney'] != $fullorder['shouldmoney'] && $fullorder['pay'] == 1211)
  1718. {
  1719. $klarnacolor = 'style="color:#F00"';
  1720. }
  1721. }
  1722. else if($klarnadata[0]!=1 && $fullorder['pay']!=26 && $fullorder['pay']!=27 && $fullorder['pay']!=1211)
  1723. {
  1724. $klarnacolor = 'style="color:#F00"';
  1725. }
  1726. if($fullorder['pay'] == 23)//klarna
  1727. {
  1728. $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');
  1729. $ToState = array_flip($ToState);
  1730. $klarnadata3 = str_replace(' ','',$klarnadata[3]);
  1731. $city = str_replace(' ','',$fullorder['city']);
  1732. $klarnadataaddress = explode($city,$klarnadata3);
  1733. if(isset($klarnadataaddress[1]))
  1734. {
  1735. $klarnadata3 = $city.$klarnadataaddress[1];
  1736. $klarnadatacolor = explode(',',$klarnadata3);
  1737. unset($klarnadatacolor[4]);
  1738. unset($klarnadatacolor[6]);
  1739. if(isset($ToState[$klarnadatacolor[1]]))
  1740. {
  1741. $klarnadatacolor[1] = ucwords($ToState[$klarnadatacolor[1]]);
  1742. }
  1743. $klarnadata['color'] = $klarnadataaddress[0].implode(",",$klarnadatacolor);
  1744. }
  1745. else
  1746. {
  1747. $klarnadata['color'] = $klarnadata3;
  1748. }
  1749. }
  1750. }
  1751. else
  1752. {
  1753. $klarnadata = '';
  1754. }
  1755. $p = explode('-',$fullorder['paypal']);
  1756. $this->data['klarnacolor'] = $klarnacolor;
  1757. $this->data['klarnadata'] = $klarnadata;
  1758. $this->data['systemwigsout'] = $outread;
  1759. $quantity = explode(';',trim($fullorder['quantity'],';'));
  1760. $qc = 0;
  1761. foreach ($quantity as $v)
  1762. {
  1763. if($v > 1)
  1764. {
  1765. $qc += 1;
  1766. }
  1767. }
  1768. $this->data['qc'] = $qc;
  1769. //新增row_total和sub_total
  1770. $product_ids = $row_total = $sub_total = "";
  1771. if(!empty($fullorder['extra_price'])){
  1772. $extra_price = json_decode($fullorder['extra_price'],true);
  1773. foreach($extra_price as $k=>$v){
  1774. $row_total .= sprintf("%.2f",($v['qty']* $v['price'])).";";
  1775. $sub_total .= sprintf("%.2f",$v['sub_total']).";";
  1776. if(!empty($v['product_id'])){
  1777. $product_ids .= $v['product_id'].";";
  1778. }
  1779. }
  1780. }
  1781. $this->data['row_total'] = trim($row_total,";");
  1782. $this->data['sub_total'] = trim($sub_total,";");
  1783. $this->data['product_ids'] = trim($product_ids,";");
  1784. $this->_Template('fullorder_edit',$this->data);
  1785. }
  1786. //不可修改
  1787. public function _readonly($arg_array)
  1788. {
  1789. $post = $this->input->post(NULL, TRUE);
  1790. if(isset($post['id']))
  1791. {
  1792. $id = $this->input->post('id',true);
  1793. $ud = $this->fullorder->read($id);
  1794. $post['type'] = $this->input->post('warehouse',true);
  1795. $post['orderremarks'] = $this->input->post('orderremarks',true);
  1796. $post['state'] = $this->input->post('state',true);
  1797. $post['msg'] = $this->input->post('msg',true);
  1798. $post['refundy'] = $this->input->post('refundy',true);
  1799. $post['refundj'] = $this->input->post('refundj',true);
  1800. $fpdata = $this->input->post('fpdata');
  1801. $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
  1802. $post['fpdata'] = $fpdata;
  1803. $rtime = $this->input->post('rtime',true);
  1804. $post['rtime'] = strtotime($rtime);
  1805. $post['rpaypal'] = $this->input->post('rpaypal',true);
  1806. $post['rtext'] = $this->input->post('rtext',true);
  1807. $post['express'] = $this->input->post('express',true);
  1808. $whlabel = $this->input->post('whlabel',true);
  1809. //$post['ioss'] = $this->input->post('ioss',true);
  1810. $post['edittime'] = time();
  1811. $editstate = $post['state'];
  1812. if(!$editstate)
  1813. {
  1814. $editstate = $ud['state'];
  1815. $post['state'] = $editstate;
  1816. }
  1817. /**
  1818. if($post['state'] == 216 && $ud['state'] != 216)
  1819. {
  1820. echo json_encode(array('msg'=>'不可修改为完成状态','success'=>false));exit;
  1821. }
  1822. **/
  1823. $whlabeldata = explode('|',trim($whlabel,'|'));$way = 0;
  1824. foreach ($whlabeldata as $va)
  1825. {
  1826. if(stripos($va,'z') !== false)
  1827. {
  1828. $way += 1;
  1829. }
  1830. }
  1831. 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))
  1832. {
  1833. echo json_encode(array('msg'=>'此快递方式必须选择美仓!','success'=>false));exit;
  1834. }
  1835. if($way == count($whlabeldata) && $post['type'] != 12)
  1836. {
  1837. echo json_encode(array('msg'=>'必须选择特殊仓!','success'=>false));exit;
  1838. }
  1839. if($way == '0' && $post['type'] == 12)
  1840. {
  1841. echo json_encode(array('msg'=>'特殊仓必须包含特殊仓货物!','success'=>false));exit;
  1842. }
  1843. $fpcount = $this->input->post('fpcount',true);
  1844. if(!$fpcount)
  1845. {
  1846. echo json_encode(array('msg'=>'需要先清理浏览器缓存,刷新当前页面后再试!','success'=>false));exit;
  1847. }
  1848. if($ud['library'] == 1)
  1849. {
  1850. if($ud['print'] != 3)
  1851. {
  1852. $post['print'] = 1;
  1853. $post['libraryconfirm'] = 1;
  1854. $post['librarynot'] = "订单未打印,未审核或未通过";
  1855. }
  1856. else
  1857. {
  1858. $post['libraryconfirm'] = 1;
  1859. $post['librarynot'] = "订单被重新提交";
  1860. }
  1861. }
  1862. if(($post['express'] == '5' || $post['express'] == '42' ) && $ud['country'] != 192)
  1863. {
  1864. echo json_encode(array('msg'=>'非美国无法选择Fedex、DHL官方-美国!','success'=>false));exit;
  1865. }
  1866. if($post['express'] == '3' && $ud['country'] != 192 && $ud['country'] != 35)
  1867. {
  1868. echo json_encode(array('msg'=>'非美国和加拿大无法选择UPS!','success'=>false));exit;
  1869. }
  1870. if(($post['express'] == '28' || $post['express'] == '7') && $ud['country'] != 191)
  1871. {
  1872. echo json_encode(array('msg'=>'非英国无法选择CNE和GES!','success'=>false));exit;
  1873. }
  1874. $express = $this->express->read($post['express']);
  1875. /**
  1876. if($express['ioss'] == 1 && $post['ioss'] == '')
  1877. {
  1878. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  1879. }
  1880. **/
  1881. $thisdata = $this->fullorder->read($id);
  1882. $warehouse = $this->warehouse->read($thisdata['type']);
  1883. $warehousenew = $this->warehouse->read($post['type']);
  1884. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  1885. {
  1886. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  1887. }
  1888. if($ud['yhs'] == 1)
  1889. {
  1890. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  1891. }
  1892. $expt = $this->express->read($post['express']);
  1893. if($expt['pt'] != '' && stripos($post['fpdata'],$expt['pt']) !== false)
  1894. {
  1895. echo json_encode(array('msg'=>$expt['ptts'],'success'=>false));exit;
  1896. }
  1897. if($expt['province'] != '' && stripos($expt['province'],$ud['province'].'、') !== false)
  1898. {
  1899. echo json_encode(array('msg'=>'此省/州不可使用 '.$expt['servicename'],'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. // if($post['type'] == 5 && !in_array($post['express'],[2,63,64,81]))
  1906. // {
  1907. // echo json_encode(array('msg'=>"此快递方式不能美仓发货!",'success'=>false));exit;
  1908. // }
  1909. if((!in_array($post['express'],[2,63,64,81,85,86,87])) && ($post['type'] == 5)){
  1910. echo json_encode(array('msg'=>'此快递方式不能美仓发货!','success'=>false));exit;
  1911. }
  1912. /**
  1913. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  1914. {
  1915. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  1916. }
  1917. **/
  1918. /**
  1919. if($warehousenew['zd'] == '1' && $editstate != $thisdata['state'] && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  1920. {
  1921. echo json_encode(array('msg'=>'如需更改订单状态,请先把仓库选择为非开启库存模式仓库或等待订单出库!','success'=>false));exit;
  1922. }
  1923. if($warehousenew['zd'] == '1' && $editstate != '207' && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  1924. {
  1925. echo json_encode(array('msg'=>'非待发货状态,不允许修改为开启库存模式仓库','success'=>false));exit;
  1926. }
  1927. **/
  1928. //开始注释 xyxg
  1929. /**
  1930. $ft = array();
  1931. $ftdata = explode('|',rtrim($fpcount,'|'));
  1932. foreach ($ftdata as $va)
  1933. {
  1934. $ftitle = '';
  1935. $va = explode('-',trim($va,'-'));
  1936. foreach ($va as $v)
  1937. {
  1938. $v = $this->typeclass->read($v);
  1939. $ftitle .= $v['title'].' ';
  1940. }
  1941. $ft[] = rtrim($ftitle,' ');
  1942. }
  1943. $user = $this->user->get_api($_SESSION['api']);
  1944. if($ud['library'] == 1)
  1945. {
  1946. $tqkcyz = $this->_kcyz($post['type'],$whlabel,$id,$ud['shop'],$ud['number']);
  1947. if(isset($tqkcyz[0]))
  1948. {
  1949. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$tqkcyz,'success'=>false));exit;
  1950. }
  1951. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  1952. {
  1953. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  1954. if($tskcyz['t'] > '0')
  1955. {
  1956. echo $tskcyz['m'];exit;
  1957. }
  1958. }
  1959. $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']);//旧状态、新状态、仓库占单设置、仓库预设设置、新仓库、新产品简化数字、旧产品数字、旧产品名称、订单号、订单店铺、旧订单仓库、旧产品简化数字
  1960. if($kcyz['t'] > '0')
  1961. {
  1962. echo $kcyz['m'];exit;
  1963. }
  1964. }
  1965. //结束注释
  1966. **/
  1967. // $post['fpdata'] = preg_replace('/\s+/', '', $post['fpdata']);str_replace(" ", "", ); // 去除所有空格
  1968. // $post['fpdata'] = str_replace(array("\r", "\n"), "", $post['fpdata']);
  1969. // $ud['fpdata'] = str_replace(" ", "", $ud['fpdata']); // 去除所有空格
  1970. // $ud['fpdata'] = str_replace(array("\r", "\n"), "", $ud['fpdata']);
  1971. $post['express'] = $ud['express'];
  1972. $post['qm'] = $ud['qm'];
  1973. $post['country'] = $ud['country'];
  1974. $post['zipcode'] = $ud['zipcode'];
  1975. $post['zsbjz'] =$ud['zsbjz'];
  1976. $post['zzl'] = $ud['zzl'];
  1977. $post['js'] = $ud['js'];
  1978. $post['sbpm'] = $ud['sbpm'];
  1979. //减少代码复用吧
  1980. $lo_ret = $this->logic_order->checkEditExpress($post);
  1981. if($lo_ret['code'] != 1){
  1982. echo json_encode(array('msg'=>$lo_ret['msg'],'success'=>false));exit;
  1983. }
  1984. if($ud['estimaterate'] == 1){
  1985. $post['budget'] = $ud['shouldmoney'];
  1986. }
  1987. if($ud['state'] == 216 && $post['whlabel'] != $ud['whlabel'])
  1988. {
  1989. echo json_encode(array('msg'=>'商品信息需要找梦体修改','success'=>false));exit;
  1990. }
  1991. $warehouse = $this->warehouse->read($post['type']);
  1992. if($ud['library'] == 1 || ($ud['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  1993. {
  1994. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  1995. if($kcyz['t'] > '0')
  1996. {
  1997. echo $kcyz['m'];exit;
  1998. }
  1999. else if($kcyz['fpdata'] != '')
  2000. {
  2001. $post['whlabel'] = $kcyz['whlabel'];
  2002. $post['fpdata'] = $kcyz['fpdata'];
  2003. }
  2004. }
  2005. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  2006. $post['sfxh'] = $fl['sfxh'];
  2007. $post['ckfl'] = $fl['ckfl'];
  2008. //查询净重开始
  2009. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  2010. //查询净重结束
  2011. if($this->fullorder->save($post,$id))
  2012. {
  2013. if($ud['printtime'] == '0')
  2014. {
  2015. $xghz = ',将自动禁止打印';
  2016. }
  2017. else if($ud['printtime'] > '0' && $ud['librarytime'] == '0')
  2018. {
  2019. $q = '';
  2020. if($ud['libraryconfirm'] == 1)
  2021. {
  2022. $q = ',<em style="color: #F00;">改前状态为:禁止出库</em>';
  2023. }
  2024. $xghz = ',将自动禁止发货'.$q;
  2025. }
  2026. else
  2027. {
  2028. $xghz = '';
  2029. }
  2030. echo json_encode(array('msg'=>'修改成功'.$xghz,'id'=>$id,'cs'=>$ud['state'].' - '.$post['fpdata'].' - '.$ud['fpdata'],'success'=>true));exit;
  2031. }
  2032. else
  2033. {
  2034. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  2035. }
  2036. }
  2037. $arg_array = $arg_array[0];$fpdata = array();
  2038. $fullorder = $this->fullorder->read($arg_array);
  2039. $returngoods = $this->returngoods->get_orderinfo($fullorder['orderinfo']);
  2040. $this->data['returngoods'] = $returngoods?1:0;
  2041. $fullorder['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$fullorder['shipremarks']);
  2042. $fullorder['parameter'] = str_replace(",","---",$fullorder['parameter']);
  2043. $this->data['fullorder'] = $fullorder;
  2044. if($fullorder['express'] == 2)
  2045. {
  2046. $zzhl = 'oz';
  2047. }
  2048. else
  2049. {
  2050. $zzhl = 'kg';
  2051. }
  2052. $this->data['zzhl'] = $zzhl;
  2053. $this->data['countrys'] = $this->country->find_all();
  2054. $this->data['express'] = $this->express->find_all();
  2055. $warehouse = $this->warehouse->read($fullorder['type']);
  2056. if(stripos($fullorder['fpdata'],';') !== false)
  2057. {
  2058. $fpdata = explode(';',rtrim($fullorder['fpdata'],';'));
  2059. foreach ($fpdata as $k=>$v)
  2060. {
  2061. $xxv = explode('|',$v);
  2062. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  2063. {
  2064. $xxv['zd'] = "<p>已占单</p>";
  2065. $bdck = $warehouse['bdck'];
  2066. if(stripos($xxv[9],'~') !== false)
  2067. {
  2068. $dxxv = explode('~',trim($xxv[9],'~'));
  2069. foreach ($dxxv as $val)
  2070. {
  2071. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  2072. if($wzid['details'] != '')
  2073. {
  2074. if($fullorder['type'] == 5){
  2075. $xxv['zd'] .= '<p>位置:'.$wzid['details'].'</p>';
  2076. }else{
  2077. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  2078. }
  2079. }
  2080. }
  2081. }
  2082. else
  2083. {
  2084. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  2085. if($wzid['details'] != '')
  2086. {
  2087. if($fullorder['type'] == 5){
  2088. $xxv['zd'] .= '<p>位置:'.$wzid['details'].'</p>';
  2089. }else{
  2090. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  2091. }
  2092. }
  2093. }
  2094. }
  2095. $fpdata[$k] = $xxv;
  2096. }
  2097. }
  2098. $this->data['fpdata'] = $fpdata;
  2099. // $tmp_features = array_column($fpdata,0);
  2100. // $do_trans_pms = [];
  2101. // foreach ($tmp_features as $k=>$v) {
  2102. // if(strpos($v,",") === false){
  2103. // $do_trans_pms[] = [
  2104. // 'features'=>$v
  2105. // ];
  2106. // }else{
  2107. // $tmp_arr = explode(",",$v);
  2108. // $do_trans_pms[] = [
  2109. // 'features'=>$tmp_arr[1].$tmp_arr[0]."-"
  2110. // ];
  2111. // }
  2112. // }
  2113. // $r = $this->logic_whlabel->dataTran($do_trans_pms,['pm']);
  2114. // foreach ($fpdata as $k=>$v) {
  2115. // $fpdata[$k]['pm'] = $r[$k]['pm'];
  2116. // }
  2117. $this->data['fpdata'] = $fpdata;
  2118. $thfpdataxs = array();
  2119. if($fullorder['thfpdata'] != '')
  2120. {
  2121. $thfpdata = explode(';',trim($fullorder['thfpdata'],';'));
  2122. foreach ($thfpdata as $k=>$v)
  2123. {
  2124. $thxs = explode('~',trim($v,'~'));
  2125. $thxs[0] = explode('|',trim($thxs[0],'|'));
  2126. $thxs[1] = explode('|',trim($thxs[1],'|'));
  2127. $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]);
  2128. }
  2129. }
  2130. $this->data['thfpdata'] = $thfpdataxs;
  2131. $shop = $this->shop->read($fullorder['shop']);
  2132. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  2133. $is = 0;
  2134. if($shop['type'] == 269 || $shop['type']==2768 )//判断是否独立站,269是独立站
  2135. {
  2136. $is = 1;
  2137. }
  2138. $this->data['is'] = $is;
  2139. //单项开始
  2140. $warehouse = $this->warehouse->read($fullorder['warehouse']);//发货仓库
  2141. $state = $this->typeclass->read($fullorder['state']);//订单状态
  2142. $country = $this->country->read($fullorder['country']);//国家
  2143. if($fullorder['capital'] == 1)
  2144. {
  2145. $capital = '暂未支付';
  2146. }
  2147. else if($fullorder['capital'] == 2)
  2148. {
  2149. $capital = '部分支付';
  2150. }
  2151. else if($fullorder['capital'] == 3)
  2152. {
  2153. $capital = '全部支付';
  2154. }
  2155. if($fullorder['printtype'] == 1)
  2156. {
  2157. $printtype = '运单';
  2158. }
  2159. else if($fullorder['printtype'] == 2)
  2160. {
  2161. $printtype = '发货单';
  2162. }
  2163. else if($fullorder['printtype'] == 3)
  2164. {
  2165. $printtype = '不打印单据';
  2166. }
  2167. else
  2168. {
  2169. $printtype = '未选择';
  2170. }
  2171. $this->data['warehouse'] = $warehouse['title'];
  2172. $this->data['state'] = $state['title'];
  2173. $this->data['capital'] = $capital;
  2174. $this->data['country'] = $country['name'];
  2175. $this->data['printtype'] = $printtype;
  2176. //单项结束
  2177. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  2178. $downwaybill = '';$dwls = array();
  2179. $oldwaybill = explode('-',ltrim($fullorder['oldwaybill'],'-'));
  2180. if(isset($oldwaybill[0][1]))
  2181. {
  2182. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  2183. foreach ($oldwaybill as $v)
  2184. {
  2185. $dw = explode('/',$v);
  2186. if(isset($dw[1]))
  2187. {
  2188. if(stripos($downwaybill,$dw[1]) === false)
  2189. {
  2190. $dwls[$dw[1]] = 1;
  2191. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  2192. }
  2193. }
  2194. }
  2195. }
  2196. if($fullorder['printtype'] == 1)
  2197. {
  2198. if($fullorder['waybill'] != '' && !isset($dwls[$fullorder['waybill']]))
  2199. {
  2200. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullorder['printtime']).'/y-'.$fullorder['waybill'].'.pdf" target="_blank">'.$fullorder['waybill'].'</a>、'.$downwaybill;
  2201. }
  2202. }
  2203. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  2204. /** 历史打印时间 **/
  2205. $printtime = '';
  2206. if($fullorder['oldprinttime'])
  2207. {
  2208. $pte = explode('-',rtrim($fullorder['oldprinttime'],'-'));
  2209. foreach ($pte as $v)
  2210. {
  2211. $printtime .= date('Y-m-d H:i:s',$v).'、';
  2212. }
  2213. }
  2214. $this->data['printtime'] = rtrim($printtime,'、');
  2215. $product = '';
  2216. $fullorder['product'] = str_replace("'","",$fullorder['product']);
  2217. if($fullorder['link'] != '' && $fullorder['source'] != '1')
  2218. {
  2219. $pt = explode(',',$fullorder['product']);
  2220. $lk = explode(',',$fullorder['link']);
  2221. for($i=0;$i<count($pt);$i++)
  2222. {
  2223. if(isset($lk[$i]))
  2224. {
  2225. $octs = $this->colourorderts->get_texturl($pt[$i],$lk[$i]);
  2226. }
  2227. else
  2228. {
  2229. $octs = '';
  2230. }
  2231. $a = $octs?'<font style="color:#'.$octs['colour'].'">'.$pt[$i].'</font>':$pt[$i];
  2232. //$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];
  2233. if(isset($lk[$i]))
  2234. {
  2235. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  2236. }
  2237. else
  2238. {
  2239. $product .= ($product != '')?' , '.$a:$a;
  2240. }
  2241. }
  2242. }
  2243. else
  2244. {
  2245. $octs = $this->colourorderts->get_text($fullorder['product']);
  2246. $a = $octs?'<font style="color:#F39">'.$fullorder['product'].'</font>':$fullorder['product'];
  2247. //$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'];
  2248. $product = $a;
  2249. }
  2250. $this->data['product'] = $product;
  2251. $out = $this->systemtransfer->find_all("number = '".$fullorder['number']."'");
  2252. $outread = '';
  2253. if($out)
  2254. {
  2255. foreach ($out as $val)
  2256. {
  2257. $list = '';
  2258. $rk = explode('|',trim($val['rk'],'|'));
  2259. $rktime = explode('|',trim($val['rktime'],'|'));
  2260. $zw = array();
  2261. $t = $this->transfer->find_all("1=1");
  2262. foreach ($t as $v)
  2263. {
  2264. $zw[$v['id']] = $v['title'];
  2265. }
  2266. if($val['rk'] != '' && count($rk) > 0)
  2267. {
  2268. for($i=0;$i<count($rk);$i++)
  2269. {
  2270. if(!isset($rktime[$i]))
  2271. {
  2272. $list .= $zw[$cz[$i]];
  2273. }
  2274. else
  2275. {
  2276. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  2277. }
  2278. }
  2279. }
  2280. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  2281. }
  2282. }
  2283. else
  2284. {
  2285. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullorder['number']."'");
  2286. $outread = array();
  2287. if($systemwigsout)
  2288. {
  2289. foreach ($systemwigsout as $v)
  2290. {
  2291. if($v['czwarehouse'] == 37)
  2292. {
  2293. $outread[] = '华荣厂';
  2294. }
  2295. else if($v['czwarehouse'] == 0)
  2296. {
  2297. $outread[] = '龙盈厂';
  2298. }
  2299. $cz = explode('|',trim($v['cz'],'|'));
  2300. $cztime = explode('|',trim($v['cztime'],'|'));
  2301. $zw = $this->transfer->get_list();
  2302. if($v['cz'] != '' && count($cz) > 0)
  2303. {
  2304. for($i=0;$i<count($cz);$i++)
  2305. {
  2306. if(!isset($cztime[$i]))
  2307. {
  2308. $outread[] = $zw[$cz[$i]].' -&gt; ';
  2309. }
  2310. else
  2311. {
  2312. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  2313. }
  2314. }
  2315. $outread[] = '<br>';
  2316. }
  2317. }
  2318. }
  2319. }
  2320. $klarnacolor = '';
  2321. if($fullorder['klarnadata'] !='')
  2322. {
  2323. $klarnadata = explode('|',$fullorder['klarnadata']);
  2324. if($klarnadata[0] == 'paypal' || $klarnadata[0] == 'stripe')
  2325. {
  2326. $klarnadata[1] = json_decode($klarnadata[1],true);
  2327. if($klarnadata[0] == 'stripe' && $klarnadata[1]['shouldmoney'] != $fullorder['shouldmoney'] && $fullorder['pay'] == 1211)
  2328. {
  2329. $klarnacolor = 'style="color:#F00"';
  2330. }
  2331. }
  2332. else if($klarnadata[0]!=1 && $fullorder['pay']!=26 && $fullorder['pay']!=27 && $fullorder['pay']!=1211)
  2333. {
  2334. $klarnacolor = 'style="color:#F00"';
  2335. }
  2336. if($fullorder['pay'] == 23)//klarna
  2337. {
  2338. $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');
  2339. $ToState = array_flip($ToState);
  2340. $klarnadata3 = str_replace(' ','',$klarnadata[3]);
  2341. $city = str_replace(' ','',$fullorder['city']);
  2342. $klarnadataaddress = explode($city,$klarnadata3);
  2343. if(isset($klarnadataaddress[1]))
  2344. {
  2345. $klarnadata3 = $city.$klarnadataaddress[1];
  2346. $klarnadatacolor = explode(',',$klarnadata3);
  2347. unset($klarnadatacolor[4]);
  2348. unset($klarnadatacolor[6]);
  2349. if(isset($ToState[$klarnadatacolor[1]]))
  2350. {
  2351. $klarnadatacolor[1] = ucwords($ToState[$klarnadatacolor[1]]);
  2352. }
  2353. $klarnadata['color'] = $klarnadataaddress[0].implode(",",$klarnadatacolor);
  2354. }
  2355. else
  2356. {
  2357. $klarnadata['color'] = $klarnadata3;
  2358. }
  2359. }
  2360. }
  2361. else
  2362. {
  2363. $klarnadata = '';
  2364. }
  2365. $p = explode('-',$fullorder['paypal']);
  2366. $this->data['klarnacolor'] = $klarnacolor;
  2367. $this->data['klarnadata'] = $klarnadata;
  2368. $this->data['systemwigsout'] = $outread;
  2369. $quantity = explode(';',trim($fullorder['quantity'],';'));
  2370. $qc = 0;
  2371. foreach ($quantity as $v)
  2372. {
  2373. if($v > 1)
  2374. {
  2375. $qc += 1;
  2376. }
  2377. }
  2378. $this->data['qc'] = $qc;
  2379. //新增row_total和sub_total
  2380. $product_ids = $row_total = $sub_total = "";
  2381. if(!empty($fullorder['extra_price'])){
  2382. $extra_price = json_decode($fullorder['extra_price'],true);
  2383. foreach($extra_price as $k=>$v){
  2384. $row_total .= sprintf("%.2f",($v['qty']* $v['price'])).";";
  2385. $sub_total .= sprintf("%.2f",$v['sub_total']).";";
  2386. if(!empty($v['product_id'])){
  2387. $product_ids .= $v['product_id'].";";
  2388. }
  2389. }
  2390. }
  2391. $this->data['row_total'] = trim($row_total,";");
  2392. $this->data['sub_total'] = trim($sub_total,";");
  2393. $this->data['product_ids'] = trim($product_ids,";");
  2394. $this->_Template('fullorder_readonly',$this->data);
  2395. }
  2396. //浏览列表
  2397. public function _readlist()
  2398. {
  2399. if(isset($_SESSION['api']))
  2400. {
  2401. $user = $this->user->get_api($_SESSION['api']);
  2402. $usp = $user;
  2403. $fgshop = "";$sid = "";
  2404. $usersp = explode('|',trim($user['shop'],'|'));
  2405. foreach ($usersp as $value)
  2406. {
  2407. $fgshop .= " shop = ".$value." or";
  2408. $sid .= " id = ".$value." or";
  2409. }
  2410. }
  2411. $post = $this->input->post(NULL, TRUE);
  2412. if(isset($post['page']))
  2413. {
  2414. $page = $this->input->post('page',true);
  2415. $perpage = $this->input->post('perpage',true);
  2416. $shop = $this->input->post('shop',true);
  2417. $warehouse = $this->input->post('warehouse',true);
  2418. $express = $this->input->post('express',true);
  2419. $state = $this->input->post('state',true);
  2420. $print = $this->input->post('print',true);
  2421. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2422. $orderinfo = $this->input->post('orderinfo',true);
  2423. $client = $this->input->post('name',true);
  2424. $email = $this->input->post('email',true);
  2425. $number = $this->input->post('number',true);
  2426. $waybill = $this->input->post('waybill',true);
  2427. $authorid = $this->input->post('authorid',true);
  2428. $sourcecontentid = $this->input->post('sourcecontentid',true);
  2429. $timetk = $this->input->post('timetk',true);
  2430. $timetj = $this->input->post('timetj',true);
  2431. $timetk = strtotime($timetk);
  2432. $timetj = strtotime($timetj);
  2433. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  2434. if($shop)
  2435. {
  2436. $where .= " and shop = '$shop'";
  2437. }
  2438. if($warehouse)
  2439. {
  2440. $where .= " and type = '$warehouse'";
  2441. }
  2442. if($express)
  2443. {
  2444. $where .= " and express = '$express'";
  2445. }
  2446. if($state)
  2447. {
  2448. $where .= " and state = '$state'";
  2449. }
  2450. if($print)
  2451. {
  2452. $where .= " and print = '$print'";
  2453. }
  2454. if($libraryconfirm)
  2455. {
  2456. $where .= " and libraryconfirm = '$libraryconfirm'";
  2457. }
  2458. if($orderinfo)
  2459. {
  2460. $where .= " and orderinfo = '$orderinfo'";
  2461. }
  2462. if($client)
  2463. {
  2464. $where .= " and client like '%$client%'";
  2465. }
  2466. if($email)
  2467. {
  2468. $where .= " and email = '$email'";
  2469. }
  2470. if($number)
  2471. {
  2472. $where .= " and number = '$number'";
  2473. }
  2474. if($waybill)
  2475. {
  2476. $where .= " and waybill = '$waybill'";
  2477. }
  2478. if($authorid)
  2479. {
  2480. $where .= " and authorid = '$authorid'";
  2481. }
  2482. if($sourcecontentid)
  2483. {
  2484. $where .= " and sourcecontentid = '$sourcecontentid'";
  2485. }
  2486. if($timetk && $timetj)
  2487. {
  2488. $timetj = $timetj+24*3600;
  2489. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2490. }
  2491. //数据排序
  2492. $order_str = "dtime desc";
  2493. if(empty($page))
  2494. {
  2495. $start = 0;
  2496. $perpage = 1;
  2497. }
  2498. else
  2499. {
  2500. $start = ($page - 1)*$perpage;
  2501. }
  2502. //取得信息列表
  2503. $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);
  2504. //格式化数据
  2505. $dt = 0;
  2506. foreach ($info_list as $key=>$value)
  2507. {
  2508. $ud = $this->fullorder->read($value['id']);
  2509. $ud['address'] = str_replace("'","’",$ud['address']);
  2510. $ud['name'] = str_replace("'","’",$ud['name']);
  2511. $customer = $this->customer->get_email($ud['email'],$value['shop']);
  2512. $customernum = $this->fullorder->find_count("email = '".$ud['email']."' and shop = '".$value['shop']."'");
  2513. preg_match_all('/[0-9]/u',$ud['phone'],$result);
  2514. $numphone = join('',$result[0]);
  2515. $customerb = $this->customer->find_all("type = 2 and (email = '".$ud['email']."' or address = '".$ud['address']."' or numphone = '".$numphone."')",'*','id desc');
  2516. $customerc = $this->customer->find_all("type = 1 and shop = '".$ud['shop']."' and address = '".$ud['address']."' and numphone = '".$numphone."'",'*','id desc');
  2517. //$a = array_column($customer, 'email'); //三维找其中健的数组
  2518. //$a = array_flip($a); //键和值调换
  2519. $lkh = $value['sname'];
  2520. $djlkh = 0;$djhmd = 0;
  2521. if($customer)
  2522. {
  2523. if(($customer['type'] == 1 && $customernum > 1))// || $customerc['type'] == 1 && $customerc['num'] > 1
  2524. {
  2525. $count = $customer['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>':'';
  2526. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户</p>";
  2527. $djlkh = 1;
  2528. $djcount = $count;
  2529. }
  2530. else if(isset($customerc[0]['num']))
  2531. {
  2532. if($customerc[0]['num'] > 1)
  2533. {
  2534. $count = $customer['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>':'';
  2535. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户</p>";
  2536. $djlkh = 1;
  2537. $djcount = $count;
  2538. }
  2539. }
  2540. }
  2541. if($customerb)
  2542. {
  2543. $hmsp = $this->shop->read($customerb[0]['shop']);
  2544. $count = $customerb[0]['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customerb[0]['count'].'"></i>':'';
  2545. $lkh = "<p>".$value['sname']."</p><p style='color:#9900CC'>".$count."黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  2546. $djhmd = 1;
  2547. }
  2548. if($djlkh == '1' && $djhmd == '1')
  2549. {
  2550. $lkh = "<p>".$value['sname']."</p><p style='color:#9900CC'><em style='color:#FF3333'>".$djcount."老客户</em> - ".$count."黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  2551. }
  2552. $info_list[$key]['sname'] = $lkh;
  2553. $shop = $this->shop->read($value['shop']);
  2554. $info_list[$key]['shop'] = $shop['shopname'];
  2555. //$info_list[$key]['user'] = $shop['shopuser'];
  2556. $warehouse = $this->warehouse->read($value['type']);
  2557. $warehousetitle = $warehouse['title'];
  2558. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  2559. $info_list[$key]['type'] = $warehousetitle;
  2560. $typeclass = $this->typeclass->read($value['state']);
  2561. $info_list[$key]['state'] = $typeclass['spare'];
  2562. $wl = '';
  2563. if($value['exstate'] == '99')
  2564. {
  2565. $wl = '<font style="color:#ccc">未获取到物流信息</font>';
  2566. }
  2567. else if($value['exstate'] == '1')
  2568. {
  2569. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">已揽收<font style="display: none">'.$ud['excontent'].'</font></font>';
  2570. }
  2571. else if($value['exstate'] == '2')
  2572. {
  2573. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">在途中<font style="display: none">'.$ud['excontent'].'</font></font>';
  2574. }
  2575. else if($value['exstate'] == '3')
  2576. {
  2577. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">派送中<font style="display: none">'.$ud['excontent'].'</font></font>';
  2578. }
  2579. else if($value['exstate'] == '4')
  2580. {
  2581. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">已签收<font style="display: none">'.$ud['excontent'].'</font></font>';
  2582. }
  2583. else if($value['exstate'] == '5')
  2584. {
  2585. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">派送异常<font style="display: none">'.$ud['excontent'].'</font></font>';
  2586. }
  2587. $info_list[$key]['exstate'] = $wl.'<br />';
  2588. if($ud['source'] == 1) //线下单用订单时间,其他用付款时间
  2589. {
  2590. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$ud['dtime']).'</p><p>'.date('H:i:s',$ud['dtime']).'</p>';
  2591. }
  2592. else
  2593. {
  2594. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']+$dt).'</p><p>'.date('H:i:s',$value['buytime']+$dt).'</p>';
  2595. }
  2596. if($value['review'] == 1)
  2597. {
  2598. $info_list[$key]['review'] = "未送审";
  2599. }
  2600. else if($value['review'] == 2)
  2601. {
  2602. $info_list[$key]['review'] = "<font style='color:#555'>待审核</font>";
  2603. }
  2604. else if($value['review'] == 3)
  2605. {
  2606. $info_list[$key]['review'] = "<font style='color:#f90f4b'>不通过</font>";
  2607. }
  2608. else if($value['review'] == 4)
  2609. {
  2610. $info_list[$key]['review'] = "取消重审";
  2611. }
  2612. else if($value['review'] == 5)
  2613. {
  2614. $info_list[$key]['review'] = "<font style='color:#2f80f9'>审核通过</font>";
  2615. }
  2616. else if($value['review'] == 6)
  2617. {
  2618. $info_list[$key]['review'] = "<font style='color:#2f80f9'>自动通过</font>";
  2619. }
  2620. if($ud['dlz'] == 1)
  2621. {
  2622. $dlz = "<p>独立站已更新</p>";
  2623. }
  2624. else if($ud['dlz'] == 3)
  2625. {
  2626. $dlz = "<p>不需要更新</p>";
  2627. }
  2628. else if($ud['dlz'] == 2)
  2629. {
  2630. $dlz = "<p style='color:#C3C'>独立站更新失败</p>";
  2631. }
  2632. else
  2633. {
  2634. $dlz = "";
  2635. }
  2636. if($value['waybill'] != "")
  2637. {
  2638. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz;
  2639. if( !empty($value['waybillid'])){
  2640. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz."<p>".$value['waybillid']."</p>";
  2641. }
  2642. }
  2643. if($value['express'] != 0)
  2644. {
  2645. $express = $this->express->read($value['express']);
  2646. $expressservicename = $express['servicename'];
  2647. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  2648. $info_list[$key]['express'] = $expressservicename;
  2649. }
  2650. else
  2651. {
  2652. $info_list[$key]['express'] = "无";
  2653. }
  2654. $tly = "";
  2655. if($value['clientremarks'] != "")
  2656. {
  2657. $tly = "<p style='color:#FF3333'>有客户留言</p>";
  2658. }
  2659. if($value['library'] == 1 && $ud['printtype'] == 3)
  2660. {
  2661. $info_list[$key]['library'] = "不需要";
  2662. }
  2663. else if($value['library'] == 1 && $ud['printtype'] != 3)
  2664. {
  2665. $info_list[$key]['library'] = "未出库";
  2666. }
  2667. else if($value['library'] == 2)
  2668. {
  2669. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  2670. }
  2671. else if($value['library'] == 3)
  2672. {
  2673. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  2674. }
  2675. if($ud['authorid'] != '' && $ud['authorid'] != 0)
  2676. {
  2677. $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>';
  2678. }
  2679. unset($info_list[$key]['waybillid']);
  2680. }
  2681. $total = $this->fullorder->find_count($where);
  2682. $pagenum = ceil($total/$perpage);
  2683. $over = $total-($start+$perpage);
  2684. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2685. echo json_encode($rows);exit;
  2686. }
  2687. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2688. $this->data['wlshop'] = $wlshop;
  2689. $this->_Template('fullorder_readlist',$this->data);
  2690. }
  2691. public function _readlistdown()
  2692. {
  2693. if(isset($_SESSION['api']))
  2694. {
  2695. $user = $this->user->get_api($_SESSION['api']);
  2696. $usp = $user;
  2697. $fgshop = "";$sid = "";
  2698. $usersp = explode('|',trim($user['shop'],'|'));
  2699. foreach ($usersp as $value)
  2700. {
  2701. $fgshop .= " shop = ".$value." or";
  2702. $sid .= " id = ".$value." or";
  2703. }
  2704. }
  2705. $post = $this->input->get(NULL, TRUE);
  2706. if(isset($post['excel']))
  2707. {
  2708. $shop = $this->input->get('shop',true);
  2709. $warehouse = $this->input->get('warehouse',true);
  2710. $express = $this->input->get('express',true);
  2711. $state = $this->input->get('state',true);
  2712. $print = $this->input->get('print',true);
  2713. $libraryconfirm = $this->input->get('libraryconfirm',true);
  2714. $orderinfo = $this->input->get('orderinfo',true);
  2715. $client = $this->input->get('name',true);
  2716. $email = $this->input->get('email',true);
  2717. $number = $this->input->get('number',true);
  2718. $waybill = $this->input->get('waybill',true);
  2719. $authorid = $this->input->get('authorid',true);
  2720. $sourcecontentid = $this->input->get('sourcecontentid',true);
  2721. $timetk = $this->input->get('timetk',true);
  2722. $timetj = $this->input->get('timetj',true);
  2723. $timetk = strtotime($timetk);
  2724. $timetj = strtotime($timetj);
  2725. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  2726. if($shop)
  2727. {
  2728. $where .= " and shop = '$shop'";
  2729. }
  2730. if($warehouse)
  2731. {
  2732. $where .= " and type = '$warehouse'";
  2733. }
  2734. if($express)
  2735. {
  2736. $where .= " and express = '$express'";
  2737. }
  2738. if($state)
  2739. {
  2740. $where .= " and state = '$state'";
  2741. }
  2742. if($print)
  2743. {
  2744. $where .= " and print = '$print'";
  2745. }
  2746. if($libraryconfirm)
  2747. {
  2748. $where .= " and libraryconfirm = '$libraryconfirm'";
  2749. }
  2750. if($orderinfo)
  2751. {
  2752. $where .= " and orderinfo = '$orderinfo'";
  2753. }
  2754. if($client)
  2755. {
  2756. $where .= " and client like '%$client%'";
  2757. }
  2758. if($email)
  2759. {
  2760. $where .= " and email = '$email'";
  2761. }
  2762. if($number)
  2763. {
  2764. $where .= " and number = '$number'";
  2765. }
  2766. if($waybill)
  2767. {
  2768. $where .= " and waybill = '$waybill'";
  2769. }
  2770. if($authorid)
  2771. {
  2772. $where .= " and authorid = '$authorid'";
  2773. }
  2774. if($sourcecontentid)
  2775. {
  2776. $where .= " and sourcecontentid = '$sourcecontentid'";
  2777. }
  2778. if($timetk && $timetj)
  2779. {
  2780. $timetj = $timetj+24*3600;
  2781. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2782. }
  2783. //数据排序
  2784. $order_str = "dtime desc";
  2785. //取得信息列表
  2786. $info_list = $this->fullorder->find_all($where,'shop,number,orderinfo,buytime,name,express,waybill,email,shipremarks,shouldmoney,orderremarks,librarytime,authorid,sourcecontentid',$order_str);
  2787. //格式化数据
  2788. $dt = 0;
  2789. foreach ($info_list as $key=>$value)
  2790. {
  2791. $shop = $this->shop->read($value['shop']);
  2792. $info_list[$key]['shop'] = $shop['shopname'];
  2793. $info_list[$key]['buytime'] = date('Y-m-d H:i:s',$value['buytime']);
  2794. if($value['librarytime'] > 0)
  2795. {
  2796. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  2797. }
  2798. if($value['express'] != 0)
  2799. {
  2800. $express = $this->express->read($value['express']);
  2801. $info_list[$key]['express'] = $express['servicename'];
  2802. }
  2803. else
  2804. {
  2805. $info_list[$key]['express'] = "无";
  2806. }
  2807. }
  2808. $title = "订单列表 ".date("Y-m-d");
  2809. $titlename = "<table border=1>
  2810. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  2811. <tr>
  2812. <td>店铺</td>
  2813. <td>编号</td>
  2814. <td>订单号</td>
  2815. <td>订单日期</td>
  2816. <td>客户姓名</td>
  2817. <td>快递方式</td>
  2818. <td>运单号</td>
  2819. <td>邮箱</td>
  2820. <td>仓库品名</td>
  2821. <td>订单金额</td>
  2822. <td>订单备注</td>
  2823. <td>出库时间</td>
  2824. <td>author_id</td>
  2825. <td>source_content_id</td>
  2826. </tr>
  2827. </table>";
  2828. $filename = $title.".xls";
  2829. $tail = "\n";
  2830. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  2831. }
  2832. }
  2833. //删除
  2834. public function _del()
  2835. {
  2836. echo json_encode(array('msg'=>'不允许执行!','success'=>false));exit;
  2837. $post = $this->input->post(NULL, TRUE);
  2838. if(isset($post['s']))
  2839. {
  2840. $id_arr = $this->input->post('s');
  2841. $id_arr = explode(',',$id_arr);
  2842. if(!$id_arr)
  2843. {
  2844. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2845. }
  2846. //循环删除记录
  2847. foreach ($id_arr as $v)
  2848. {
  2849. $this->fullorder->remove($v);
  2850. }
  2851. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  2852. }
  2853. }
  2854. //查找商品价格
  2855. public function _price()
  2856. {
  2857. $post = $this->input->post(NULL, TRUE);
  2858. if(isset($post['data']))
  2859. {
  2860. $data = $this->input->post('data');
  2861. $data = explode('-',$data);
  2862. $number = '';$num = count($data);
  2863. //循环删除记录
  2864. for($i=0;$i<$num-1;$i++)
  2865. {
  2866. if($data[$i] != 0)
  2867. {
  2868. $number=$number.$data[$i];
  2869. if($i == 2)
  2870. {
  2871. $number=$number.$data[$num-1];
  2872. }
  2873. }
  2874. }
  2875. $list = $this->productdescribe->get_number($number);
  2876. if($list)
  2877. {
  2878. echo json_encode(array('msg'=>($list),'n'=>$data[$num-1],'number'=>$number,'success'=>true));
  2879. }
  2880. else
  2881. {
  2882. $list = array('purchase'=>0,'cost'=>0,'salesprice'=>0);
  2883. //echo json_encode(array('msg'=>'此信息没有配置价格!','n'=>$data[$num-1],'success'=>false));exit;
  2884. echo json_encode(array('msg'=>($list),'n'=>$data[$num-1],'number'=>$number,'success'=>true));exit;
  2885. }
  2886. }
  2887. }
  2888. public function _customs()
  2889. {
  2890. $post = $this->input->post(NULL, TRUE);
  2891. if(isset($post['e']))
  2892. {
  2893. $e = $this->input->post('e');//快递信息
  2894. $c = $this->input->post('c');//国家信息
  2895. $data = $this->customs->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2896. $list = $this->productdescription->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2897. $rows = array();
  2898. foreach ($data as $key=>$value)
  2899. {
  2900. $detailed = explode('|',trim($value['detailed'],'|'));
  2901. //此处未对比重量选择价值,暂直接选择第一条海关价值
  2902. $detailed = $this->detailed->read($detailed[0]);
  2903. $money = $detailed['customsval'];//找到海关价值
  2904. }
  2905. foreach ($list as $key=>$value)
  2906. {
  2907. $description = $this->typeclass->read($value['description']);
  2908. $list[$key]['title'] = $description['title'];//产品描述名称
  2909. }
  2910. if(!$data && !$list)
  2911. {
  2912. echo json_encode(array('msg'=>'无此快递配置信息!','success'=>false));exit;
  2913. }
  2914. else
  2915. {
  2916. //$list-title -description 取值
  2917. echo json_encode(array('money'=>sprintf("%.2f",$money),'msg'=>$list,'success'=>true));
  2918. }
  2919. }
  2920. }
  2921. public function _express()
  2922. {
  2923. $post = $this->input->post(NULL, TRUE);
  2924. if(isset($post['e']))
  2925. {
  2926. $e = $this->input->post('e');//快递信息
  2927. $c = $this->input->post('c');//国家信息
  2928. $data = $this->logistics->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2929. if(!$data)
  2930. {
  2931. echo json_encode(array('success'=>false));exit;
  2932. }
  2933. else
  2934. {
  2935. echo json_encode(array('money'=>sprintf("%.2f",$data[0]['firstmoney']),'success'=>true));
  2936. }
  2937. }
  2938. }
  2939. public function _hl()
  2940. {
  2941. $post = $this->input->post(NULL, TRUE);
  2942. if(isset($post['cy']))
  2943. {
  2944. $hl = 0;
  2945. $cy = $this->input->post('cy');//币种ID
  2946. $cy = $this->typeclass->read($cy);
  2947. $gethl = $this->hl->get_hl();
  2948. foreach ($gethl as $v)
  2949. {
  2950. $code = str_replace(" ","",$v['code']);
  2951. if($code == $cy['title'])
  2952. {
  2953. $hl = $v['refePrice']/100;
  2954. }
  2955. }
  2956. echo json_encode(array('msg'=>$hl,'success'=>true));
  2957. }
  2958. }
  2959. public function _operation()
  2960. {
  2961. $post = $this->input->post(NULL, TRUE);
  2962. if(isset($post['type']))
  2963. {
  2964. $type = $this->input->post('type');
  2965. $id = $this->input->post('id');
  2966. $msg = $this->input->post('msg');
  2967. $d = $this->fullorder->read($id);
  2968. $time = time();
  2969. if($type == 1)//禁止发货
  2970. {
  2971. if($d['library'] != 1)
  2972. {
  2973. echo json_encode(array('msg'=>'操作失败,订单非未出库状态!','success'=>false));exit;
  2974. }
  2975. if($msg == "")
  2976. {
  2977. echo json_encode(array('msg'=>'必须填写禁止原因!','success'=>false));exit;
  2978. }
  2979. if($d['print'] < 3)
  2980. {
  2981. $a = "订单未打印,";
  2982. }
  2983. else
  2984. {
  2985. $a = "";
  2986. }
  2987. if($this->fullorder->save(array('libraryconfirm'=>1,'librarynot'=>$a.$msg),$id))
  2988. {
  2989. echo json_encode(array('msg'=>'操作成功','l'=>1,'d'=>$id,'success'=>true));exit;
  2990. }
  2991. else
  2992. {
  2993. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2994. }
  2995. }
  2996. if($type == 6)//允许发货
  2997. {
  2998. if($d['library'] > 1)
  2999. {
  3000. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  3001. }
  3002. if($d['print'] < 3)
  3003. {
  3004. $a = "订单未打印,";
  3005. }
  3006. else
  3007. {
  3008. $a = "";
  3009. }
  3010. if($this->fullorder->save(array('libraryconfirm'=>2,'librarynot'=>$a.$msg),$id))
  3011. {
  3012. echo json_encode(array('msg'=>'操作成功','l'=>1,'d'=>$id,'success'=>true));exit;
  3013. }
  3014. else
  3015. {
  3016. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3017. }
  3018. }
  3019. if($type == 7)//禁止打印
  3020. {
  3021. if($d['printtime'] != 0)
  3022. {
  3023. echo json_encode(array('msg'=>'订单已打印,操作失败','success'=>false));exit;
  3024. }
  3025. if($d['library'] > 1)
  3026. {
  3027. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  3028. }
  3029. if($d['print'] < 3)
  3030. {
  3031. $a = "订单未打印,";
  3032. }
  3033. else
  3034. {
  3035. $a = "";
  3036. }
  3037. if($this->fullorder->save(array('print'=>1),$id))
  3038. {
  3039. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  3040. }
  3041. else
  3042. {
  3043. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3044. }
  3045. }
  3046. if($type == 8)//允许打印
  3047. {
  3048. /**
  3049. if($d['printtime'] != 0)
  3050. {
  3051. echo json_encode(array('msg'=>'订单已打印,操作失败','success'=>false));exit;
  3052. }
  3053. **/
  3054. if($d['library'] > 1)
  3055. {
  3056. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  3057. }
  3058. if($d['print'] < 3)
  3059. {
  3060. $a = "订单未打印,";
  3061. }
  3062. else
  3063. {
  3064. $a = "";
  3065. }
  3066. if($d['printtime'] == '0')
  3067. {
  3068. $bcprint = 2;
  3069. }
  3070. else
  3071. {
  3072. $bcprint = 3;
  3073. }
  3074. if($this->fullorder->save(array('print'=>$bcprint,'failed'=>''),$id))
  3075. {
  3076. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  3077. }
  3078. else
  3079. {
  3080. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3081. }
  3082. }
  3083. if($type == 9)//关闭
  3084. {
  3085. if($this->fullorder->save(array('failed'=>''),$id))
  3086. {
  3087. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  3088. }
  3089. else
  3090. {
  3091. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3092. }
  3093. }
  3094. if($type == 2)//填写运单、修改运单
  3095. {
  3096. if($d['express'] == 0)
  3097. {
  3098. echo json_encode(array('msg'=>'操作失败,未选择物流方式!','success'=>false));exit;
  3099. }
  3100. if($d['library'] == 3 || ($d['print'] == 3 && $d['libraryconfirm'] == 1))
  3101. {
  3102. echo json_encode(array('msg'=>'操作失败,不允许填写运单号!','success'=>false));exit;
  3103. }
  3104. if($msg == '')
  3105. {
  3106. echo json_encode(array('msg'=>'运单号不能为空!','success'=>false));exit;
  3107. }
  3108. $ckemail = '';
  3109. $d['waybill'] = $msg;
  3110. $xg = $this->fullorder->read($id);
  3111. $shop = $this->shop->read($xg['shop']);
  3112. $ex = $this->express->read($xg['express']);
  3113. $fs = $this->notice->find_all("shop = '".$d['shop']."' and message = '1' and state = '1' and type = '4' and ktime < '$time' and jtime > '$time'");
  3114. if(isset($fs[0]))
  3115. {
  3116. $fs = $fs[0];
  3117. $fs['email'] = $this->emaildata->read($fs['email']);
  3118. if(($xg['dlzemail'] == 1 && $msg != $xg['waybill']) || $xg['dlzemail'] == 0)
  3119. {
  3120. $warehouse = $this->warehouse->read($xg['type']);
  3121. $ck = $this->notice->get_god($d,$shop,$ex,$fs);
  3122. if($ck == 1)
  3123. {
  3124. $ckemail = '邮件发送成功,';
  3125. $this->fullorder->save(array('dlzemail'=>1,'dlzemailtime'=>time()),$id);
  3126. }
  3127. }
  3128. }
  3129. if( $msg )
  3130. {
  3131. if($xg['source'] != 1)
  3132. {
  3133. $ms = $this->message->find_all("express like '%,".$xg['express'].",%'");
  3134. if(!isset($ms[0]))
  3135. {
  3136. $ms = $this->message->read(2);
  3137. }
  3138. else
  3139. {
  3140. $ms = $ms[0];
  3141. }
  3142. if($xg['shop'] == 5){
  3143. $ddh = $xg['orderinfo'];
  3144. }else{
  3145. $ddh = substr($xg['orderinfo'],1);
  3146. }
  3147. $shopifyid = $xg['shopify'];
  3148. //独立站地址更新订单状态、物流信息
  3149. $shopname = $shop['brandname']; //店铺名
  3150. $buyername = $xg['bname']; //Bill Name
  3151. $email_call = $shop['shopid']; //发货人邮箱;
  3152. $phone = $shop['shopphone']; //发货人电话
  3153. $track_type = $ex['title']; //快递名称
  3154. $service = $ex['title']; //快递追踪名称
  3155. $track_link = $ex['url']; //快递查询网址
  3156. $logistics_number = $msg; //运单号
  3157. $t= array('%buyername%','%email_call%','%track_type%','%service%','%track_link%','%logistics_number%','%shop%','%phone%','%jtime%');
  3158. $h= array($buyername,$email_call,$track_type,$service,$track_link,$logistics_number,$shopname,$phone,$ex['yjtime']);
  3159. $remark = str_replace($t,$h,$ms['content']);
  3160. $gx = $this->api->get_gx($ddh,$msg,$xg,$shop,$ex,$remark,$shopifyid);
  3161. }
  3162. else if($xg['source'] == 1)
  3163. {
  3164. $gx['res'] = 3;
  3165. $gx['state'] = 216;
  3166. $gx['cw'] = 'a';
  3167. }
  3168. }
  3169. else
  3170. {
  3171. $gx['res'] = $xg['dlz'];
  3172. $gx['state'] = $xg['state'];
  3173. $gx['cw'] = 'b';
  3174. }
  3175. $xg['iscode'] = $ex['title'];
  3176. $xg['url'] = $shop['shopname'];
  3177. $xg['waybill'] = $msg;
  3178. @$chuanshu = $this->api->get_paypal($xg);
  3179. $this->afspaypal->insert(array('number'=>$xg['number'],'cs'=>$chuanshu));
  3180. $msg = preg_replace('/( | | | |\s)/','',$msg);
  3181. if($this->fullorder->save(array('waybill'=>$msg,'state'=>$gx['state'],'dlz'=>$gx['res']),$id))
  3182. {
  3183. if($gx['res'] == 2)
  3184. {
  3185. echo json_encode(array('msg'=>$ckemail.'传输独立站失败!','cs'=>$gx['state'].' - '.$gx['res'].' - '.$gx['cw'],'success'=>false));exit;
  3186. }
  3187. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  3188. }
  3189. else
  3190. {
  3191. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3192. }
  3193. }
  3194. }
  3195. }
  3196. public function _merge()
  3197. {
  3198. $post = $this->input->post(NULL, TRUE);
  3199. if(isset($post['s']))
  3200. {
  3201. $id_arr = $this->input->post('s');
  3202. $id_arr = explode(',',trim( $id_arr,','));
  3203. $id_arr = array_reverse($id_arr);
  3204. if(!$id_arr)
  3205. {
  3206. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  3207. }
  3208. if(count($id_arr) < 2)
  3209. {
  3210. echo json_encode(array('msg'=>'缺少可合并单!','success'=>false));exit;
  3211. }
  3212. $tmp_list = $this->db->from('fullorder')->where_in('id',$id_arr)->select('id,orderinfo,number,type,express')->get()->result_array();
  3213. $count_warehouse_list = [];
  3214. $count_express_list = [];
  3215. $flag = 0;
  3216. $flag_str = '';
  3217. foreach ($tmp_list as $k => $v) {
  3218. $count_warehouse_list[$v['type']] = $v['type'];
  3219. if(empty($v['express'])){
  3220. $flag = 1;
  3221. $flag_str.= $v['number'].'仓库未选,请先选快递;';
  3222. }
  3223. $count_express_list[$v['express']] = $v['express'];
  3224. }
  3225. if($flag == 1){
  3226. echo json_encode(array('msg'=>$flag_str,'success'=>false));exit;
  3227. }
  3228. if(count($count_warehouse_list) > 1){
  3229. echo json_encode(array('msg'=>'合并单的仓库不一致,无法合并!','success'=>false));exit;
  3230. }
  3231. if(count($count_express_list) > 1){
  3232. echo json_encode(array('msg'=>'合并单的快递不一致,无法合并!','success'=>false));exit;
  3233. }
  3234. $post = array();
  3235. $u = $this->fullorder->read($id_arr[0]);
  3236. unset($id_arr[0]);
  3237. $this->db->trans_begin();
  3238. $hd = $this->fullorderhb->get_orderinfo($u['orderinfo']);
  3239. if(!$hd)
  3240. {
  3241. $this->fullorderhb->insert($u);
  3242. }
  3243. //相加
  3244. $post['shouldmoney'] = $u['shouldmoney'];//购买应收金额
  3245. $post['budget'] = $u['budget'];//预估到帐金额
  3246. $post['expressmoney']= $u['expressmoney'];//物流金额
  3247. //$post['refundy'] = $u['refundy'];//补/退原额
  3248. //$post['refundj'] = $u['refundj'];//补/退净额
  3249. $post['cost'] = $u['cost'];//成本金额
  3250. //$post['zzl'] = $u['zzl'];//总重量
  3251. //$post['zsbjz'] = $u['zsbjz'];//总申报价值
  3252. $post['ts'] = $u['ts'];//条数
  3253. $post['cost'] = $u['cost'];//成本金额
  3254. //追加
  3255. $post['rpaypal'] = $u['rpaypal'];//补/退交易号
  3256. $post['rtext'] = $u['rtext'];//补/退原因
  3257. $post['pay'] = $u['pay'];//付款方式
  3258. $post['paypal'] = $u['paypal'];//交易号
  3259. $post['clientremarks'] = $u['clientremarks'];//客户留言
  3260. $post['product'] = $u['product'];//商品名称
  3261. //$post['issku'] = $u['issku'];//sku
  3262. //$post['orderremarks'] = $u['orderremarks'];//订单备注
  3263. $post['shipremarks'] = $u['shipremarks'];//仓库品名
  3264. //产品追加
  3265. $post['fpdata'] = $u['fpdata'];//产品内容
  3266. $post['whlabel'] = $u['whlabel'];//产品对应库存码
  3267. $merge = $u['id'];
  3268. $d = array($u['id']);$order = '';
  3269. $zsl = 0;$zccsl = 0;
  3270. foreach ($id_arr as $v)
  3271. {
  3272. $v = $this->fullorder->read($v);
  3273. if($u['type'] != $v['type'])
  3274. {
  3275. echo json_encode(array('msg'=>'仓库不一致,无法合并!','success'=>false));exit;
  3276. }
  3277. if($v['shop'] = $u['shop'])
  3278. {
  3279. $hd = $this->fullorderhb->get_orderinfo($v['orderinfo']);
  3280. if(!$hd)
  3281. {
  3282. $this->fullorderhb->insert($v);
  3283. }
  3284. //$post['shouldmoney'] += $v['shouldmoney'];//购买应收金额
  3285. // $post['budget'] += $v['budget'];//预估到帐金额
  3286. // $post['expressmoney'] += $v['expressmoney'];//物流金额
  3287. //$post['refundy'] += $v['refundy'];//补/退原额
  3288. //$post['refundj'] += $v['refundj'];//补/退净额
  3289. $post['cost'] += $v['cost'];//成本金额
  3290. //$post['zzl'] += $v['zzl'];//总重量
  3291. //$post['zsbjz'] += $v['zsbjz'];//总申报价值
  3292. $post['ts'] += $v['ts'];//条数
  3293. //$post['rpaypal'] .= $v['rpaypal'];//补/退交易号
  3294. //$post['rtext'] .= $v['rtext'];//补/退原因
  3295. //$post['pay'] .= (stripos($post['pay'],$v['pay']) !== false)?'':';'.$v['pay'];//付款方式
  3296. //$post['paypal'] .= $v['paypal'];//交易号
  3297. $post['clientremarks'] .= $v['clientremarks'];//客户留言
  3298. $post['product'] .= $v['product'];//商品名称
  3299. //$post['issku'] .= $v['issku'];//sku
  3300. //$post['orderremarks'] .= $v['orderremarks'];//订单备注
  3301. $post['shipremarks'] .= $v['shipremarks'];//仓库品名
  3302. $post['fpdata'] .= $v['fpdata'];//产品内容
  3303. $post['whlabel'] .= ltrim($v['whlabel'],'|');//产品对应库存码
  3304. $d[] = $v['id'];
  3305. $order .= $v['orderinfo'].'('.$v['number'].')、';
  3306. $wl = $this->whlabel->find_all("zd = '".$v['number']."'");//查找是否有占用库存情况
  3307. $i = 0;
  3308. if($wl)//如果有那么清除所有占用
  3309. {
  3310. foreach ($wl as $val)
  3311. {
  3312. if($val['sku'] == 'Preset' && $val['state'] == '9')
  3313. {
  3314. $this->whlabel->remove($val['id']);//删除预设
  3315. $i++;
  3316. }
  3317. else
  3318. {
  3319. $this->whlabel->save(array('zd'=>''),$val['id']);//专属
  3320. $i++;
  3321. }
  3322. }
  3323. }
  3324. $zsl += count($wl);
  3325. $zccsl += $i;
  3326. $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']);
  3327. }
  3328. }
  3329. //计算出单条价值
  3330. /**
  3331. if($post['zsbjz'] < 1 || $post['ts'] < 1)
  3332. {
  3333. //$post['dtsbjz'] = 0;
  3334. }
  3335. else
  3336. {
  3337. //$post['dtsbjz'] = $post['zsbjz']/$post['ts'];//单条申报价
  3338. }
  3339. **/
  3340. $post['orderremarks'] = ' 《合并信息》:由'.rtrim($order,'、').'合并而来; '.$u['orderremarks'];;
  3341. $post['merge'] = $u['id'];
  3342. //$post['mergeid'] = 1;
  3343. //合并重复项
  3344. $hbcfw = explode('|',trim($post['whlabel'],'|'));
  3345. $hbcff = explode(';',trim($post['fpdata'],';'));
  3346. $c = 0;
  3347. $hbw = array();
  3348. $hbf = array();
  3349. for($i=0;$i<count($hbcfw);$i++)
  3350. {
  3351. $w = explode('-',$hbcfw[$i]);
  3352. $f = explode('|',$hbcff[$i]);
  3353. if(isset($w[2]))
  3354. {
  3355. $w2 = ($w[2]==0)?0:'';
  3356. }
  3357. else
  3358. {
  3359. $w2 = '';
  3360. }
  3361. if(!isset($hbw[$w[0].$w2]))
  3362. {
  3363. $hbw[$w[0].$w2] = $hbcfw[$i];
  3364. $hbf[$w[0].$w2] = $hbcff[$i];
  3365. }
  3366. else
  3367. {
  3368. $c++;
  3369. $cw = explode('-',$hbw[$w[0].$w2]);
  3370. $cf = explode('|',$hbf[$w[0].$w2]);
  3371. if($cw[2] != 0 && $w[2] != 0)
  3372. {
  3373. $cf[2] += $f[2];
  3374. $cf[9] .= '~'.$f[9];
  3375. $hbf[$w[0].$w2] = implode("|",$cf);
  3376. $cw[1] += $f[2];
  3377. $cw[2] .= '~'.$f[9];
  3378. $hbw[$w[0].$w2] = implode("-",$cw);
  3379. }
  3380. else if($cw[2] == 0 && $w[2] == 0)
  3381. {
  3382. $cf[2] += $f[2];
  3383. $hbf[$w[0].$w2] = implode("|",$cf);
  3384. $cw[1] += $f[2];
  3385. $hbw[$w[0].$w2] = implode("-",$cw);
  3386. }
  3387. else
  3388. {
  3389. $hbw[] = $hbcfw[$i];
  3390. $hbf[] = $hbcff[$i];
  3391. }
  3392. }
  3393. }
  3394. if($c > 0)
  3395. {
  3396. $post['fpdata'] = implode(";",$hbf).';';
  3397. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  3398. }
  3399. //合并重复项结束
  3400. $this->fullorder->save($post,$u['id']);
  3401. if ($this->db->trans_status() === FALSE)
  3402. {
  3403. $this->db->trans_commit();
  3404. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3405. }
  3406. else
  3407. {
  3408. $this->db->trans_commit();
  3409. echo json_encode(array('msg'=>'操作成功','d'=>($d),'b'=>$u['id'],'success'=>true));
  3410. }
  3411. }
  3412. /**
  3413. $post = $this->input->post(NULL, TRUE);
  3414. if(isset($post['type']))
  3415. {
  3416. $type = $this->input->post('type');
  3417. $id = $this->input->post('id');
  3418. $u = $this->fullorder->read($id);
  3419. $rows = $this->fullorder->find_all('name = "'.$u['name'].'" or email = "'.$u['email'].'" or address = "'.$u['address'].'"','*','id desc');
  3420. if(count($rows)>1)
  3421. {
  3422. $this->db->trans_begin();
  3423. $fpdata=$rows[0]['fpdata'];//购买产品
  3424. $shouldmoney=$rows[0]['shouldmoney'];//购买应收金额
  3425. $budget=$rows[0]['budget'];//预估到帐金额
  3426. $cost=$rows[0]['cost'];//成本金额
  3427. $merge=$rows[0]['id'];
  3428. $d = array($rows[0]['id']);
  3429. for($i=1;$i<count($rows);$i++)
  3430. {
  3431. $fpdata=$fpdata.$rows[$i]['fpdata'];
  3432. $shouldmoney=$shouldmoney+$rows[$i]['shouldmoney'];
  3433. $budget=$budget+$rows[$i]['budget'];
  3434. $cost=$cost+$rows[$i]['cost'];
  3435. $d[] = $rows[$i]['id'];
  3436. $this->fullorder->save(array('merge'=>$rows[0]['id'],'mergeid'=>1),$rows[$i]['id']);
  3437. }
  3438. $this->fullorder->save(array('fpdata'=>$fpdata,'shouldmoney'=>$shouldmoney,'budget'=>$budget,'cost'=>$cost,'merge'=>$merge),$rows[0]['id']);
  3439. if ($this->db->trans_status() === FALSE)
  3440. {
  3441. $this->db->trans_commit();
  3442. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3443. }
  3444. else
  3445. {
  3446. $this->db->trans_commit();
  3447. echo json_encode(array('msg'=>'操作成功','d'=>($d),'b'=>$rows[0]['id'],'success'=>true));
  3448. }
  3449. }
  3450. }
  3451. **/
  3452. }
  3453. //评价管理
  3454. public function _evaluate()
  3455. {
  3456. $user = $this->user->get_api($_SESSION['api']);
  3457. if($user)
  3458. {
  3459. $fgshop = "";$sid = "";
  3460. $user = explode('|',trim($user['shop'],'|'));
  3461. foreach ($user as $value)
  3462. {
  3463. $fgshop .= " shop = ".$value." or";
  3464. $sid .= " id = ".$value." or";
  3465. }
  3466. }
  3467. $post = $this->input->post(NULL, TRUE);
  3468. if(isset($post['page']))
  3469. {
  3470. $page = $this->input->post('page',true);
  3471. $perpage = $this->input->post('perpage',true);
  3472. $shop = $this->input->post('shop',true);
  3473. $where = "1=1 and evaluate = 0 and (".rtrim($fgshop,'or').")";
  3474. if($shop)
  3475. {
  3476. $where .= " and shop = '$shop'";
  3477. }
  3478. //数据排序
  3479. $order_str = "id desc";
  3480. if(empty($page))
  3481. {
  3482. $start = 0;
  3483. $perpage = 1;
  3484. }
  3485. else
  3486. {
  3487. $start = ($page - 1)*$perpage;
  3488. }
  3489. //取得信息列表
  3490. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,operation',$order_str,$start,$perpage);
  3491. //格式化数据
  3492. foreach ($info_list as $key=>$value)
  3493. {
  3494. $shop = $this->shop->read($value['shop']);
  3495. $info_list[$key]['shop'] = $shop['shopname'];
  3496. $info_list[$key]['operation'] = "评价";
  3497. }
  3498. $total = $this->fullorder->find_count($where);
  3499. $pagenum = ceil($total/$perpage);
  3500. $over = $total-($start+$perpage);
  3501. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3502. echo json_encode($rows);exit;
  3503. }
  3504. $this->_Template('fullorder_evaluate',$this->data);
  3505. }
  3506. //订单消息
  3507. public function _state()
  3508. {
  3509. $user = $this->user->get_api($_SESSION['api']);
  3510. if($user)
  3511. {
  3512. $fgshop = "";$sid = "";
  3513. $user = explode('|',trim($user['shop'],'|'));
  3514. foreach ($user as $value)
  3515. {
  3516. $fgshop .= " shop = ".$value." or";
  3517. $sid .= " id = ".$value." or";
  3518. }
  3519. }
  3520. $post = $this->input->post(NULL, TRUE);
  3521. if(isset($post['page']))
  3522. {
  3523. $page = $this->input->post('page',true);
  3524. $perpage = $this->input->post('perpage',true);
  3525. $timetk = $this->input->post('timetk',true);
  3526. $timetj = $this->input->post('timetj',true);
  3527. $shop = $this->input->post('shop',true);
  3528. $expressstate = $this->input->post('expressstate',true);
  3529. $fs = $this->input->post('fs',true);
  3530. $state = $this->input->post('state',true);
  3531. $express = $this->input->post('express',true);
  3532. $review = $this->input->post('review',true);
  3533. $orderinfo = $this->input->post('orderinfo',true);
  3534. $number = $this->input->post('number',true);
  3535. $waybill = $this->input->post('waybill',true);
  3536. $xztime = $this->input->post('xztime',true);
  3537. $timetk = strtotime($timetk);
  3538. $timetj = strtotime($timetj);
  3539. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3540. if($timetk && $timetj)
  3541. {
  3542. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3543. }
  3544. if($xztime == 'librarytime')
  3545. {
  3546. $order_str = "librarytime desc";
  3547. }
  3548. else if($xztime == 'dtime')
  3549. {
  3550. $order_str = "dtime desc";
  3551. }
  3552. if($shop)
  3553. {
  3554. $where .= " and shop = '$shop'";
  3555. }
  3556. if($expressstate)
  3557. {
  3558. $where .= " and expressstate = '$expressstate'";
  3559. }
  3560. if($review)
  3561. {
  3562. $where .= " and review = '$review'";
  3563. }
  3564. if($fs)
  3565. {
  3566. if($fs == '2')
  3567. {
  3568. $where .= " and exstateerror != ''";
  3569. }
  3570. else
  3571. {
  3572. $where .= " and exstateerror = ''";
  3573. }
  3574. }
  3575. if($state)
  3576. {
  3577. $where .= " and state = '$state'";
  3578. }
  3579. if($express)
  3580. {
  3581. $where .= " and express = '$express'";
  3582. }
  3583. if($orderinfo)
  3584. {
  3585. $where .= " and orderinfo = '$orderinfo'";
  3586. }
  3587. if($number)
  3588. {
  3589. $where .= " and number = '$number'";
  3590. }
  3591. if($waybill)
  3592. {
  3593. $where .= " and waybill = '$waybill'";
  3594. }
  3595. if(empty($page))
  3596. {
  3597. $start = 0;
  3598. $perpage = 1;
  3599. }
  3600. else
  3601. {
  3602. $start = ($page - 1)*$perpage;
  3603. }
  3604. //取得信息列表
  3605. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,country,library,librarytime,express,waybill,content,orderremarks,exstateerror',$order_str,$start,$perpage);
  3606. //格式化数据
  3607. foreach ($info_list as $key=>$value)
  3608. {
  3609. $shop = $this->shop->read($value['shop']);
  3610. $info_list[$key]['shop'] = $shop['shopname'];
  3611. $country = $this->country->read($value['country']);
  3612. $info_list[$key]['country'] = $country['name'];
  3613. //$state = $this->typeclass->read($value['state']);
  3614. //$info_list[$key]['state'] = $state['title'];
  3615. if($value['library'] == 1)
  3616. {
  3617. $info_list[$key]['library'] = "未出库";
  3618. }
  3619. else if($value['library'] == 2)
  3620. {
  3621. $info_list[$key]['library'] = "已出库";
  3622. }
  3623. else if($value['library'] == 3)
  3624. {
  3625. $info_list[$key]['library'] = "已退库";
  3626. }
  3627. if($value['librarytime'] == '0')
  3628. {
  3629. $info_list[$key]['librarytime'] = '无';
  3630. }
  3631. else
  3632. {
  3633. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']);
  3634. }
  3635. $express = $this->express->read($value['express']);
  3636. $info_list[$key]['express'] = $express['servicename'];
  3637. }
  3638. $total = $this->fullorder->find_count($where);
  3639. $pagenum = ceil($total/$perpage);
  3640. $over = $total-($start+$perpage);
  3641. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3642. echo json_encode($rows);exit;
  3643. }
  3644. $notice = $this->notice->find_all("type = '1' and (".rtrim($fgshop,'or').")");
  3645. $this->data['notice'] = $notice;
  3646. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3647. $this->data['wlshop'] = $wlshop;
  3648. $this->data['express'] = $this->express->find_all();
  3649. $this->_Template('fullorder_state',$this->data);
  3650. }
  3651. //物流信息
  3652. public function _wl()
  3653. {
  3654. $user = $this->user->get_api($_SESSION['api']);
  3655. if($user)
  3656. {
  3657. $fgshop = "";$sid = "";
  3658. $user = explode('|',trim($user['shop'],'|'));
  3659. foreach ($user as $value)
  3660. {
  3661. $fgshop .= " shop = ".$value." or";
  3662. $sid .= " id = ".$value." or";
  3663. }
  3664. }
  3665. $post = $this->input->post(NULL, TRUE);
  3666. if(isset($post['page']))
  3667. {
  3668. $page = $this->input->post('page',true);
  3669. $perpage = $this->input->post('perpage',true);
  3670. $timetk = $this->input->post('timetk',true);
  3671. $timetj = $this->input->post('timetj',true);
  3672. $shop = $this->input->post('shop',true);
  3673. $expressstate = $this->input->post('expressstate',true);
  3674. $fs = $this->input->post('fs',true);
  3675. $state = $this->input->post('state',true);
  3676. $express = $this->input->post('express',true);
  3677. $orderinfo = $this->input->post('orderinfo',true);
  3678. $number = $this->input->post('number',true);
  3679. $waybill = $this->input->post('waybill',true);
  3680. $wlyc = $this->input->post('wlyc',true);
  3681. $wltype = $this->input->post('wltype',true);
  3682. $source = $this->input->post('source',true);
  3683. $xztime = $this->input->post('xztime',true);
  3684. $wlbz = $this->input->post('wlbz',true);
  3685. $timetk = strtotime($timetk);
  3686. $timetj = strtotime($timetj);
  3687. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3688. if($timetk && $timetj)
  3689. {
  3690. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3691. }
  3692. if($xztime == 'librarytime')
  3693. {
  3694. $order_str = "librarytime desc";
  3695. }
  3696. else if($xztime == 'dtime')
  3697. {
  3698. $order_str = "dtime desc";
  3699. }
  3700. else if ($xztime == 'wlfstime')
  3701. {
  3702. $order_str = "wlfstime desc";
  3703. }
  3704. if($shop)
  3705. {
  3706. $where .= " and shop = '$shop'";
  3707. }
  3708. if($fs)
  3709. {
  3710. if($fs == '1')
  3711. {
  3712. $where .= " and wlcontent != ''";
  3713. }
  3714. if($fs == '2')
  3715. {
  3716. $where .= " and wlerror != ''";
  3717. }
  3718. if($fs == '3')
  3719. {
  3720. $where .= " and wlcontent = '' and shouldmoney > 100";
  3721. }
  3722. else if($fs == '4')
  3723. {
  3724. $where .= " and wltype = '1'";
  3725. }
  3726. }
  3727. if($state)
  3728. {
  3729. $where .= " and state = '$state'";
  3730. }
  3731. if($express)
  3732. {
  3733. $where .= " and express = '$express'";
  3734. }
  3735. if($orderinfo)
  3736. {
  3737. $where .= " and orderinfo = '$orderinfo'";
  3738. }
  3739. if($number)
  3740. {
  3741. $where .= " and number = '$number'";
  3742. }
  3743. if($waybill)
  3744. {
  3745. $where .= " and waybill = '$waybill'";
  3746. }
  3747. if($wlbz)
  3748. {
  3749. $where .= " and wlbz like '%$wlbz%'";
  3750. }
  3751. if($wlyc!='')
  3752. {
  3753. $where .= " and wlyc = '$wlyc'";
  3754. }
  3755. if($wltype!='')
  3756. {
  3757. $where .= " and wltype = '$wltype'";
  3758. }
  3759. if($source)
  3760. {
  3761. if($source == 1)
  3762. {
  3763. $where .= " and source = '$source'";
  3764. }
  3765. else
  3766. {
  3767. $where .= " and source != '1'";
  3768. }
  3769. }
  3770. if($expressstate != '')
  3771. {
  3772. if($expressstate == 99)
  3773. {
  3774. $cxid = '';
  3775. $sjcc = $this->awlgx->find_all("time < '".(time()-3*24*3600)."' and exstate != 6",'number');
  3776. foreach ($sjcc as $v)
  3777. {
  3778. $cxid .= "number = '".$v['number']."' or ";
  3779. }
  3780. $where .= ' and ('.rtrim($cxid,'or ').')';
  3781. }
  3782. else
  3783. {
  3784. $where .= " and expressstate = '$expressstate'";
  3785. }
  3786. }
  3787. if(empty($page))
  3788. {
  3789. $start = 0;
  3790. $perpage = 1;
  3791. }
  3792. else
  3793. {
  3794. $start = ($page - 1)*$perpage;
  3795. }
  3796. //取得信息列表
  3797. $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);
  3798. //格式化数据
  3799. foreach ($info_list as $key=>$value)
  3800. {
  3801. $f = $this->fullorder->read($value['id']);
  3802. $info_list[$key]['number'] = "<p>".$value['number']."</p>"."<p>".$f['email']."</p>";
  3803. $country = $this->country->read($value['country']);
  3804. $info_list[$key]['country'] = "<p>".$country['name']."</p><p>".$f['phone']."</p>";
  3805. //$state = $this->typeclass->read($value['state']);
  3806. //$info_list[$key]['state'] = $state['title'];
  3807. if($value['library'] == 1)
  3808. {
  3809. $info_list[$key]['library'] = "未出库";
  3810. }
  3811. else if($value['library'] == 2)
  3812. {
  3813. $info_list[$key]['library'] = "已出库";
  3814. }
  3815. else if($value['library'] == 3)
  3816. {
  3817. $info_list[$key]['library'] = "已退库";
  3818. }
  3819. if($value['librarytime'] == '0')
  3820. {
  3821. $info_list[$key]['librarytime'] = '无';
  3822. }
  3823. else
  3824. {
  3825. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']).'<br>'.$f['shouldmoney'];
  3826. }
  3827. if($value['expressstate'] == 0)
  3828. {
  3829. $info_list[$key]['expressstate'] = "无信息";
  3830. }
  3831. else if($value['expressstate'] == 2)
  3832. {
  3833. $info_list[$key]['expressstate'] = "已取件";
  3834. }
  3835. else if($value['expressstate'] == 3)
  3836. {
  3837. $info_list[$key]['expressstate'] = "在途中";
  3838. }
  3839. /**
  3840. else if($value['expressstate'] == 4)
  3841. {
  3842. $info_list[$key]['expressstate'] = "到达目的地国".$value['expressstate'];
  3843. }
  3844. **/
  3845. else if($value['expressstate'] == 4 || $value['expressstate'] == 5)
  3846. {
  3847. $info_list[$key]['expressstate'] = "即将派送";
  3848. }
  3849. else if($value['expressstate'] == 6)
  3850. {
  3851. $info_list[$key]['expressstate'] = "已签收";
  3852. }
  3853. else if($value['expressstate'] == 1)
  3854. {
  3855. $info_list[$key]['expressstate'] = "派送异常";
  3856. }
  3857. $express = $this->express->read($value['express']);
  3858. $info_list[$key]['express'] = $express['servicename'];
  3859. if($value['wltype'] == '0')
  3860. {
  3861. $info_list[$key]['wltype'] = "<p class='ckn'><b class='wlfsxx' data-id='".$value['id']."' data-q='1'>禁止发送</b></p>";
  3862. }
  3863. else
  3864. {
  3865. $info_list[$key]['wltype'] = "<p class='ckn'><b class='wlfsxx' data-id='".$value['id']."' data-q='1'>允许发送</b></p>";
  3866. }
  3867. if($f['wlyc'] == '0')
  3868. {
  3869. $info_list[$key]['wltype'] .= "<p class='yc'><b class='wlyc' data-id='".$value['id']."' data-t='1'>加入异常处理中</b></p>";
  3870. }
  3871. else if($f['wlyc'] == '1')
  3872. {
  3873. $info_list[$key]['wltype'] .= "<p class='yc'><b class='wlyc' data-id='".$value['id']."' data-t='2'>移入异常已处理</b></p>";
  3874. $info_list[$key]['wltype'] .= "<p class='yc'><b class='ycyc' data-id='".$value['id']."' data-c='2'>移出异常处理中</b></p>";
  3875. }
  3876. else if($f['wlyc'] == '2')
  3877. {
  3878. $info_list[$key]['wltype'] .= "<p><b>异常已处理</b></p>";
  3879. }
  3880. if(stripos($value['excontent'],'<br />') !== false)
  3881. {
  3882. $excontent = explode('<br />',$value['excontent']);
  3883. $info_list[$key]['excontent'] = '<i class="method fa fa-list-ul" data-t="'.$value['excontent'].'"></i> '.$excontent[0];
  3884. }
  3885. }
  3886. $total = $this->fullorder->find_count($where);
  3887. $pagenum = ceil($total/$perpage);
  3888. $over = $total-($start+$perpage);
  3889. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$where);
  3890. echo json_encode($rows);exit;
  3891. }
  3892. if(isset($post['q']))
  3893. {
  3894. $id = $this->input->post('id',true);
  3895. $f = $this->fullorder->read($id);
  3896. $wl = ($f['wltype']=='0')?1:0;
  3897. $wltitle = ($f['wltype']=='0')?'已禁发送':'已允发送';
  3898. if($this->fullorder->save(array('wltype'=>$wl),$id))
  3899. {
  3900. echo json_encode(array('msg'=>'ckn','id'=>$id,'wltitle'=>$wltitle,'success'=>true));exit;
  3901. }
  3902. else
  3903. {
  3904. echo json_encode(array('msg'=>'失败,请重试','id'=>$id,'wltitle'=>$wltitle,'success'=>false));exit;
  3905. }
  3906. }
  3907. if(isset($post['t']))
  3908. {
  3909. $id = $this->input->post('id',true);
  3910. $f = $this->fullorder->read($id);
  3911. $t = $this->input->post('t',true);
  3912. $yc = ($f['wlyc']=='0')?1:2;
  3913. $yctitle = ($f['wlyc']=='0')?'移入成功':'异常已处理';
  3914. if($this->fullorder->save(array('wlyc'=>$yc),$id))
  3915. {
  3916. echo json_encode(array('msg'=>'yc','id'=>$id,'wltitle'=>$yctitle,'success'=>true));exit;
  3917. }
  3918. else
  3919. {
  3920. echo json_encode(array('msg'=>'失败,请重试','id'=>$id,'wltitle'=>$yctitle,'success'=>false));exit;
  3921. }
  3922. }
  3923. if(isset($post['c']))
  3924. {
  3925. $id = $this->input->post('id',true);
  3926. $f = $this->fullorder->read($id);
  3927. $t = $this->input->post('t',true);
  3928. $yc = 0;
  3929. $yctitle = '移出成功';
  3930. if($this->fullorder->save(array('wlyc'=>$yc),$id))
  3931. {
  3932. echo json_encode(array('msg'=>'yc','id'=>$id,'wltitle'=>$yctitle,'success'=>true));exit;
  3933. }
  3934. else
  3935. {
  3936. echo json_encode(array('msg'=>'失败,请重试','id'=>$id,'wltitle'=>$yctitle,'success'=>false));exit;
  3937. }
  3938. }
  3939. $notice = $this->notice->find_all("type = '2' and (".rtrim($fgshop,'or').")");
  3940. $this->data['notice'] = $notice;
  3941. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3942. $this->data['wlshop'] = $wlshop;
  3943. $this->data['express'] = $this->express->find_all();
  3944. $this->_Template('fullorder_wl',$this->data);
  3945. }
  3946. //审核订单
  3947. public function _review()
  3948. {
  3949. $user = $this->user->get_api($_SESSION['api']);
  3950. if($user)
  3951. {
  3952. $fgshop = "";$sid = "";
  3953. $user = explode('|',trim($user['shop'],'|'));
  3954. foreach ($user as $value)
  3955. {
  3956. $sid .= " id = ".$value." or";
  3957. $fgshop .= " shop = ".$value." or";
  3958. }
  3959. $fgshop = " and (".rtrim($fgshop,'or').")";
  3960. }
  3961. $post = $this->input->post(NULL, TRUE);
  3962. if(isset($post['page']))
  3963. {
  3964. $page = $this->input->post('page',true);
  3965. $perpage = $this->input->post('perpage',true);
  3966. $source = $this->input->post('source',true);
  3967. $warehouse = $this->input->post('warehouse',true);
  3968. $express = $this->input->post('express',true);
  3969. $orderremarks = $this->input->post('orderremarks',true);
  3970. $shop = $this->input->post('shop',true);
  3971. $review = $this->input->post('review',true);
  3972. $orderinfo = $this->input->post('orderinfo',true);
  3973. $shipremarks = $this->input->post('shipremarks',true);
  3974. $number = $this->input->post('number',true);
  3975. $timetk = $this->input->post('timetk',true);
  3976. $timetj = $this->input->post('timetj',true);
  3977. $timetk = strtotime($timetk);
  3978. $timetj = strtotime($timetj);
  3979. $where = "mergeid = 0 and state = '207'".$fgshop;
  3980. if($timetk && $timetj)
  3981. {
  3982. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3983. }
  3984. if($source)
  3985. {
  3986. if($source == '2d')
  3987. {
  3988. $where .= " and source >= '2'";
  3989. }
  3990. else
  3991. {
  3992. $where .= " and source = '$source'";
  3993. }
  3994. }
  3995. if($review)
  3996. {
  3997. $where .= " and review = '$review'";
  3998. }
  3999. else
  4000. {
  4001. $where .= "and review <= '2'";
  4002. // $where .= " and ((review = '2' and source = '1') or (review = '1' and source >= '2'))";
  4003. }
  4004. if($shop)
  4005. {
  4006. $where .= " and shop = '$shop'";
  4007. }
  4008. if($warehouse)
  4009. {
  4010. $where .= " and type = '$warehouse'";
  4011. }
  4012. if($express)
  4013. {
  4014. $where .= " and express = '$express'";
  4015. }
  4016. if($orderremarks)
  4017. {
  4018. $where .= " and orderremarks like '%$orderremarks%'";
  4019. }
  4020. if($orderinfo)
  4021. {
  4022. $where .= " and orderinfo = '$orderinfo'";
  4023. }
  4024. if($number)
  4025. {
  4026. $where .= " and number = '$number'";
  4027. }
  4028. if($shipremarks)
  4029. {
  4030. $where .= " and shipremarks like '%$shipremarks%'";
  4031. }
  4032. //数据排序
  4033. $order_str = "id desc";
  4034. if(empty($page))
  4035. {
  4036. $start = 0;
  4037. $perpage = 1;
  4038. }
  4039. else
  4040. {
  4041. $start = ($page - 1)*$perpage;
  4042. }
  4043. //取得信息列表
  4044. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,client,express,buytime,shouldmoney,review,orderremarks');
  4045. //格式化数据
  4046. foreach ($info_list as $key=>$value)
  4047. {
  4048. $lr = $this->fullorder->read($value['id']);
  4049. $shop = $this->shop->read($value['shop']);
  4050. $info_list[$key]['shop'] = $shop['shopname'];
  4051. $warehouse = $this->warehouse->read($value['type']);
  4052. $info_list[$key]['type'] = $warehouse['title'];
  4053. $express = $this->express->read($value['express']);
  4054. $info_list[$key]['express'] = $express['servicename'];
  4055. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  4056. if($value['review'] == 1)
  4057. {
  4058. $info_list[$key]['review'] = "未送审";
  4059. }
  4060. else if($value['review'] == 2)
  4061. {
  4062. $info_list[$key]['review'] = "待审核";
  4063. }
  4064. else if($value['review'] == 3)
  4065. {
  4066. $info_list[$key]['review'] = "不通过";
  4067. }
  4068. else if($value['review'] == 4)
  4069. {
  4070. $info_list[$key]['review'] = "取消重审";
  4071. }
  4072. else if($value['review'] == 5)
  4073. {
  4074. $info_list[$key]['review'] = "审核通过";
  4075. }
  4076. else if($value['review'] == 6)
  4077. {
  4078. $info_list[$key]['review'] = "自动通过";
  4079. }
  4080. /**
  4081. $info_list[$key]['library'] = "";
  4082. if($value['review'] == 1)
  4083. {
  4084. $info_list[$key]['library'] = "<p><b class='focz' data-type='6' data-id='".$value['id']."'>审核通过</b></p>";
  4085. }
  4086. if($value['review'] == 2)
  4087. {
  4088. $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>";
  4089. }
  4090. else if($value['review'] == 3)
  4091. {
  4092. $info_list[$key]['library'] = "<p><b class='fullorderreview' data-type='5' data-id='".$value['id']."'>审核通过</b></p>";
  4093. }
  4094. else if($value['review'] == 5)
  4095. {
  4096. $info_list[$key]['library'] = "<p><b class='fullorderreview' data-type='3' data-id='".$value['id']."'>不通过</b></p>";
  4097. }
  4098. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$lr['currencytitle'];
  4099. $lr['hl'] = $lr['hl']==0?6.71:$lr['hl'];
  4100. $cost = $lr['cost']/$lr['hl'];
  4101. $currencytitle = $lr['budget']-$lr['refundj']-$cost-$lr['expressmoney'];
  4102. $info_list[$key]['currencytitle'] = sprintf("%.2f",$currencytitle).' '.$lr['currencytitle'];
  4103. **/
  4104. }
  4105. $total = $this->fullorder->find_count($where);
  4106. $pagenum = ceil($total/$perpage);
  4107. $over = $total-($start+$perpage);
  4108. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4109. echo json_encode($rows);exit;
  4110. }
  4111. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4112. $this->data['shop'] = $wlshop;
  4113. $this->_Template('fullorder_review',$this->data);
  4114. }
  4115. public function _wlbz($arg_array)
  4116. {
  4117. $post = $this->input->post(NULL, TRUE);
  4118. if(isset($post['id']))
  4119. {
  4120. $id = $this->input->post('id',true);
  4121. $post['wlbz'] = $this->input->post('wlbz',true);
  4122. if($post['wlbz'] == '')
  4123. {
  4124. echo json_encode(array('msg'=>'备注不能为空','success'=>false));exit;
  4125. }
  4126. if($this->fullorder->save($post,$id))
  4127. {
  4128. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  4129. }
  4130. else
  4131. {
  4132. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  4133. }
  4134. }
  4135. $arg_array = $arg_array[0];
  4136. $fullorder = $this->fullorder->read($arg_array);
  4137. $this->data['fullorder'] = $fullorder;
  4138. $this->_Template('fullorder_wlbz',$this->data);
  4139. }
  4140. //导出资金统计excel
  4141. public function _fmexcel()
  4142. {
  4143. $user = $this->user->get_api($_SESSION['api']);
  4144. if($user)
  4145. {
  4146. $fgshop = "";$sid = "";
  4147. $user = explode('|',trim($user['shop'],'|'));
  4148. foreach ($user as $value)
  4149. {
  4150. $fgshop .= " shop = ".$value." or";
  4151. $sid .= " id = ".$value." or";
  4152. }
  4153. }
  4154. if(isset($_GET['excel']))
  4155. {
  4156. $timetk = $this->input->get('timetk',true);
  4157. $timetj = $this->input->get('timetj',true);
  4158. $shop = $this->input->get('shop',true);
  4159. $source = $this->input->get('source',true);
  4160. $state = $this->input->get('state',true);
  4161. $type = $this->input->get('type',true);
  4162. $orderinfo = $this->input->get('orderinfo',true);
  4163. $user = $this->input->get('user',true);
  4164. $name = $this->input->get('name',true);
  4165. $timetk = strtotime($timetk);
  4166. $timetj = strtotime($timetj);
  4167. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  4168. if($timetk && $timetj)
  4169. {
  4170. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  4171. }
  4172. if($shop)
  4173. {
  4174. $where .= " and shop = '$shop'";
  4175. }
  4176. if($source)
  4177. {
  4178. $where .= " and source = '$source'";
  4179. }
  4180. if($state)
  4181. {
  4182. if($state == 1)
  4183. {
  4184. $where .= " and state = '$state'";
  4185. }
  4186. }
  4187. if($type)
  4188. {
  4189. $where .= " and type = '$type'";
  4190. }
  4191. if($orderinfo)
  4192. {
  4193. $where .= " and orderinfo = '$orderinfo'";
  4194. }
  4195. if($user)
  4196. {
  4197. $where .= " and user = '$user'";
  4198. }
  4199. if($name)
  4200. {
  4201. $where .= " and name = '$name'";
  4202. }
  4203. //取得信息列表
  4204. $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');
  4205. //格式化数据
  4206. $i = 1;$shouldmoney = 0;$refund = 0;$budget = 0;$currency = 0;$hl=1;
  4207. foreach ($info_list as $key=>$value)
  4208. {
  4209. $info_list[$key]['id'] = $i;
  4210. if($value['currencytitle'] != "CNY")
  4211. {
  4212. $hl=$value['hl'];
  4213. }
  4214. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  4215. $budget=$budget+($value['budget']*$hl);
  4216. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  4217. $refund=$refund+($value['refund']*$hl);
  4218. $shop = $this->shop->read($value['shop']);
  4219. $info_list[$key]['shop'] = $shop['shopname'];
  4220. $info_list[$key]['user'] = $shop['shopuser'];
  4221. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  4222. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  4223. $country = $this->country->read($value['country']);
  4224. $info_list[$key]['country'] = $country['name'];
  4225. $express = $this->express->read($value['express']);
  4226. $info_list[$key]['express'] = $express['servicename'];
  4227. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  4228. $info_list[$key]['refund'] = $value['refund'].' '.$value['currencytitle'];
  4229. $info_list[$key]['budget'] = $value['budget'].' '.$value['currencytitle'];
  4230. $info_list[$key]['currency'] = sprintf("%.2f",$value['shouldmoney']-$value['budget']).' '.$value['currencytitle'];
  4231. $fpdata = array();
  4232. if(stripos($value['fpdata'],';') !== false)
  4233. {
  4234. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  4235. foreach ($fpdata as $ke=>$va)
  4236. {
  4237. $v = explode('|',rtrim($va,'|'));
  4238. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  4239. }
  4240. }
  4241. $info_list[$key]['fpdata'] = $fpdata;
  4242. $i++;
  4243. }
  4244. $data = array($shouldmoney.' CNY',$refund.' CNY',$currency.' CNY',$budget.' CNY');
  4245. $title = "订单资金信息";
  4246. $titlename = "<table border=1>
  4247. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  4248. <tr>
  4249. <td>NO.</td>
  4250. <td>店铺</td>
  4251. <td>负责人</td>
  4252. <td>编号</td>
  4253. <td>订单号</td>
  4254. <td>客户姓名</td>
  4255. <td>国家</td>
  4256. <td>订单日期</td>
  4257. <td>发货日期</td>
  4258. <td>快递公司</td>
  4259. <td>运单号</td>
  4260. <td>订单金额</td>
  4261. <td>退款金额</td>
  4262. <td>手续费</td>
  4263. <td>预估金额</td>
  4264. <td>
  4265. <table border=1>
  4266. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  4267. <tr>
  4268. <td>产品</td>
  4269. <td>条数</td>
  4270. <td>数量</td>
  4271. </tr>
  4272. </table>
  4273. </td>
  4274. <td>总条数</td>
  4275. </tr>
  4276. </table>";
  4277. $filename = $title.".xls";
  4278. $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";
  4279. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  4280. }
  4281. }
  4282. //导出订单excel
  4283. public function _fdexcel()
  4284. {
  4285. if(isset($_GET['excel']))
  4286. {
  4287. $page = $this->input->post('page',true);
  4288. $perpage = $this->input->post('perpage',true);
  4289. $timetk = $this->input->post('timetk',true);
  4290. $timetj = $this->input->post('timetj',true);
  4291. $shop = $this->input->post('shop',true);
  4292. $source = $this->input->post('source',true);
  4293. $state = $this->input->post('state',true);
  4294. $review = $this->input->post('review',true);
  4295. $express = $this->input->post('express',true);
  4296. $orderinfo = $this->input->post('orderinfo',true);
  4297. $user = $this->input->post('user',true);
  4298. $name = $this->input->post('name',true);
  4299. $waybill = $this->input->post('waybill',true);
  4300. $timetk = strtotime($timetk);
  4301. $timetj = strtotime($timetj);
  4302. $where = "1=1 and mergeid = 0";
  4303. if($timetk && $timetj)
  4304. {
  4305. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  4306. }
  4307. if($shop)
  4308. {
  4309. $where .= " and shop = '$shop'";
  4310. }
  4311. if($source)
  4312. {
  4313. $where .= " and source = '$source'";
  4314. }
  4315. if($state)
  4316. {
  4317. $where .= " and state = '$state'";
  4318. }
  4319. if($review)
  4320. {
  4321. $where .= " and review = '$review'";
  4322. }
  4323. if($express)
  4324. {
  4325. $where .= " and express = '$express'";
  4326. }
  4327. if($orderinfo)
  4328. {
  4329. $where .= " and orderinfo = '$orderinfo'";
  4330. }
  4331. if($user)
  4332. {
  4333. $where .= " and user = '$user'";
  4334. }
  4335. if($name)
  4336. {
  4337. $where .= " and name = '$name'";
  4338. }
  4339. if($waybill)
  4340. {
  4341. $where .= " and waybill = '$waybill'";
  4342. }
  4343. //取得信息列表
  4344. $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');
  4345. //格式化数据
  4346. $i = 1;$shouldmoney = 0;$hl=1;
  4347. foreach ($info_list as $key=>$value)
  4348. {
  4349. $info_list[$key]['id'] = $i;
  4350. if($value['source'] == 1)
  4351. {
  4352. $info_list[$key]['source'] = "线下订单";
  4353. }
  4354. else if($value['source'] == 2)
  4355. {
  4356. $info_list[$key]['source'] = "PC订单";
  4357. }
  4358. else if($value['source'] == 3)
  4359. {
  4360. $info_list[$key]['source'] = "手机订单";
  4361. }
  4362. if($value['currencytitle'] != "CNY")
  4363. {
  4364. $hl=$value['hl'];
  4365. }
  4366. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  4367. $shop = $this->shop->read($value['shop']);
  4368. $info_list[$key]['shop'] = $shop['shopname'];
  4369. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  4370. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  4371. $state = $this->typeclass->read($value['state']);
  4372. $info_list[$key]['state'] = $state['title'];
  4373. $country = $this->country->read($value['country']);
  4374. $info_list[$key]['country'] = $country['name'];
  4375. $express = $this->express->read($value['express']);
  4376. $info_list[$key]['express'] = $express['servicename'];
  4377. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  4378. $fpdata = array();
  4379. if(stripos($value['fpdata'],';') !== false)
  4380. {
  4381. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  4382. foreach ($fpdata as $ke=>$va)
  4383. {
  4384. $v = explode('|',rtrim($va,'|'));
  4385. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  4386. }
  4387. }
  4388. $info_list[$key]['fpdata'] = $fpdata;
  4389. $i++;
  4390. }
  4391. $data = array($shouldmoney.' CNY');
  4392. $title = "订单信息表";
  4393. $titlename = "<table border=1>
  4394. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  4395. <tr>
  4396. <td>NO.</td>
  4397. <td>店铺</td>
  4398. <td>编号</td>
  4399. <td>订单号</td>
  4400. <td>订单类型</td>
  4401. <td>客户姓名</td>
  4402. <td>收件人名称</td>
  4403. <td>收货人地址</td>
  4404. <td>城市</td>
  4405. <td>邮编</td>
  4406. <td>州</td>
  4407. <td>国家</td>
  4408. <td>收件电话</td>
  4409. <td>订单日期</td>
  4410. <td>发货日期</td>
  4411. <td>订单状态</td>
  4412. <td>订单金额</td>
  4413. <td>快递公司</td>
  4414. <td>运单号</td>
  4415. <td>订单备注</td>
  4416. <td>客户备注</td>
  4417. <td>
  4418. <table border=1>
  4419. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  4420. <tr>
  4421. <td>产品</td>
  4422. <td>条数</td>
  4423. <td>数量</td>
  4424. </tr>
  4425. </table>
  4426. </td>
  4427. <td>总条数</td>
  4428. </tr>
  4429. </table>";
  4430. $filename = $title.".xls";
  4431. $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";
  4432. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  4433. }
  4434. }
  4435. public function _black()
  4436. {
  4437. $post = $this->input->post(NULL, TRUE);
  4438. if(isset($post['bd']))
  4439. {
  4440. $bd = $this->input->post('bd',true);
  4441. $rows = $this->fullorder->read($bd);
  4442. $post['shop'] = $rows['shop'];
  4443. $post['source'] = 1;
  4444. $post['name'] = $rows['client'];
  4445. $post['email'] = $rows['email'];
  4446. $post['phone'] = $rows['phone'];
  4447. $post['country'] = $rows['country'];
  4448. $post['money'] = $rows['shouldmoney'];
  4449. $post['num'] = 1;
  4450. $post['time'] = $rows['dtime'];
  4451. $post['province'] = $rows['province'];
  4452. $post['city'] = $rows['city'];
  4453. $post['street'] = $rows['street'];
  4454. $post['address'] = $rows['address'];
  4455. $post['address2'] = $rows['address2'];
  4456. $post['zipcode'] = $rows['zipcode'];
  4457. $post['type'] = 2;
  4458. if($this->customer->insert($post))
  4459. {
  4460. $this->fullorder->save(array('black'=>1),$bd);
  4461. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  4462. }
  4463. else
  4464. {
  4465. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4466. }
  4467. }
  4468. }
  4469. public function _ryf()
  4470. {
  4471. $post = $this->input->post(NULL, TRUE);
  4472. if(isset($post['bd']))
  4473. {
  4474. $bd = $this->input->post('bd',true);
  4475. $d = $this->fullorder->read($bd);
  4476. if($d['state'] == 207 || $d['state'] == 207)//订单状态为等待发货或等待部分发货才可更改为允许发货
  4477. {
  4478. if($d['print'] < 3)//打印状态为未打印
  4479. {
  4480. $print = 1;//未打印
  4481. $libraryconfirm = 1;//不允许出库
  4482. $a = "订单未打印,";
  4483. }
  4484. else//已打印订单
  4485. {
  4486. $libraryconfirm = 2;//允许出库
  4487. $a = "";
  4488. }
  4489. if($this->fullorder->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  4490. {
  4491. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  4492. }
  4493. else
  4494. {
  4495. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4496. }
  4497. }
  4498. if($this->fullorder->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  4499. {
  4500. echo json_encode(array('msg'=>'操作失败!订单未非发货状态','success'=>false));exit;
  4501. }
  4502. else
  4503. {
  4504. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4505. }
  4506. }
  4507. }
  4508. public function _fsstate()
  4509. {
  4510. $post = $this->input->post(NULL, TRUE);
  4511. if(isset($post['s']))
  4512. {
  4513. $id_arr = $this->input->post('s');
  4514. $id_arr = explode(',',$id_arr);
  4515. if(!$id_arr)
  4516. {
  4517. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  4518. }
  4519. foreach ($id_arr as $v)
  4520. {
  4521. $data = $this->fullorder->read($v);
  4522. $warehouse = $this->warehouse->read($data['type']);
  4523. $fs = $this->notice->get_ordertatus($data['state']);
  4524. if($fs)
  4525. {
  4526. $ck = $this->_email($fs['content'],$data,$warehouse['company']);
  4527. if($ck == 1)
  4528. {
  4529. $this->fullorder->save(array('fscontent'=>date('Y-m-d H:i:s',time()).'已发送:'.$fs['title'].' - '),$v);
  4530. }
  4531. }
  4532. }
  4533. echo json_encode(array('msg'=>'发送完成!','success'=>true));exit;
  4534. }
  4535. }
  4536. public function _power()
  4537. {
  4538. $user = $this->user->get_api($_SESSION['api']);
  4539. $post = $this->input->post(NULL, TRUE);
  4540. if(isset($post['id']))
  4541. {
  4542. $id = $this->input->post('id',true);
  4543. $fullorder = $this->fullorder->read($id);
  4544. $express = $this->express->read($fullorder['express']);
  4545. $warehouse = $this->warehouse->read($fullorder['type']);
  4546. if(($warehouse['zd'] == '1' || stripos($fullorder['whlabel'],'z|') !== false) && $fullorder['library'] == '2')
  4547. {
  4548. echo json_encode(array('msg'=>'需要先退库释放库存后才可重置!','success'=>false));exit;
  4549. }
  4550. /**
  4551. if($fullorder['print'] == '3' && isset($express['iscode']) && ($express['iscode'] == 'ARAMEX' || $express['iscode'] == 'TOLL' || $express['iscode'] == 'FEDEX'))
  4552. {
  4553. $lj = $this->ali->get_lj($fullorder['number'],2,'订单修改');
  4554. if($lj != '1' && $lj != '订单不存在')
  4555. {
  4556. echo json_encode(array('msg'=>$lj,'success'=>false));exit;
  4557. }
  4558. }
  4559. **/
  4560. $warehouse = $this->warehouse->read($fullorder['warehouse']);
  4561. $typeclass = $this->typeclass->read($fullorder['state']);
  4562. $express = $this->express->read($fullorder['express']);
  4563. $printtype = array(1=>'运单',2=>'发货单',3=>'不打印单据');
  4564. $teset['number']=$fullorder['number'];
  4565. $teset['orderinfo']=$fullorder['orderinfo'];
  4566. $teset['shop']=$fullorder['shop'];
  4567. $teset['user']=$user['userid'];
  4568. $teset['ip']=$this->input->ip_address();
  4569. $teset['time']=time();
  4570. $teset['warehouse']=(isset($warehouse['title']))?$warehouse['title']:'未选择';
  4571. $teset['state']=(isset($typeclass['title']))?$typeclass['spare']:'未选择';
  4572. $teset['express']=(isset($express['title']))?$express['servicename']:'未选择';
  4573. $teset['printtype']=(isset($printtype[$fullorder['printtype']]))?$printtype[$fullorder['printtype']]:'未选择';
  4574. $teset['reviewtime']=($fullorder['reviewtime'] > '0')?date('Y-m-d H:i:s',$fullorder['reviewtime']):'无';
  4575. $teset['printtime']=($fullorder['printtime'] > '0')?date('Y-m-d H:i:s',$fullorder['printtime']):'无';
  4576. $teset['librarytime']=($fullorder['librarytime'] > '0')?date('Y-m-d H:i:s',$fullorder['librarytime']):'无';
  4577. $teset['shipremarks']=$fullorder['shipremarks'];
  4578. $teset['fpdata']=$fullorder['fpdata'];
  4579. $teset['oldwaybill']=$fullorder['oldwaybill'];
  4580. $teset['oldprinttime']=$fullorder['oldprinttime'];
  4581. if($fullorder['printtype'] == 1)
  4582. {
  4583. if($fullorder['waybill'] != '' && stripos($fullorder['oldwaybill'],$fullorder['waybill']) === false)
  4584. {
  4585. $teset['oldwaybill'] .= '-'.date('Ymd',$fullorder['printtime']).'/'.$fullorder['waybill'];
  4586. $teset['oldprinttime'] .= '-'.$fullorder['printtime'];
  4587. }
  4588. }
  4589. $review = ($fullorder['source']==1)?2:1;//线下单审核状态直接为待审核
  4590. if(!$this->fullreset->insert($teset))
  4591. {
  4592. echo json_encode(array('msg'=>'重置失败,请重试','success'=>true));exit;
  4593. }
  4594. 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))
  4595. {
  4596. $th_info = $this->retreatlogs->getInfoByNumber($fullorder['number']);
  4597. if(!empty($th_info)){
  4598. $this->retreatlogs->save(array('cz_time'=>time()),$th_info['id']);
  4599. }
  4600. echo json_encode(array('msg'=>'重置成功!如需再次提交,请先保存、再提交','success'=>true));exit;
  4601. }
  4602. else
  4603. {
  4604. echo json_encode(array('msg'=>'重置失败,请重试','success'=>false));exit;
  4605. }
  4606. }
  4607. }
  4608. public function _expresstype()
  4609. {
  4610. $post = $this->input->post(NULL, TRUE);
  4611. if(isset($post['id']))
  4612. {
  4613. $id = $this->input->post('id',true);
  4614. $data = $this->express->read($id);
  4615. echo json_encode(array('msg'=>$data['type'],'success'=>true));exit;
  4616. }
  4617. }
  4618. public function _email($content,$data,$shopname)
  4619. {
  4620. $express = $this->express->read($data['express']);
  4621. $t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
  4622. $h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['servicename'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
  4623. $content = str_replace($t,$h,$content);
  4624. $this->load->library('email');
  4625. $config['protocol'] = 'smtp';
  4626. $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
  4627. $config['smtp_port'] = 465;
  4628. $config['smtp_user'] = 'service@email.supernovahair.com';
  4629. $config['smtp_pass'] = 'LONGyihair374';
  4630. $config['smtp_crypto'] = 'ssl';
  4631. $config['crlf'] = "\r\n";
  4632. $config['newline'] = "\r\n";
  4633. $this->email->initialize($config);
  4634. $this->email->from('service@email.supernovahair.com',$shopname);
  4635. $this->email->to($data['email']);//收件
  4636. $this->email->subject('The product you purchased has a new progress');//标题
  4637. $this->email->message($content);//内容
  4638. if ( ! $this->email->send())
  4639. {
  4640. return 2;
  4641. }
  4642. else
  4643. {
  4644. return 1;
  4645. }
  4646. }
  4647. public function _error()
  4648. {
  4649. if(isset($_SESSION['api']))
  4650. {
  4651. $user = $this->user->get_api($_SESSION['api']);
  4652. $usp = $user;
  4653. $fgshop = "";$sid = "";
  4654. $user = explode('|',trim($user['shop'],'|'));
  4655. foreach ($user as $value)
  4656. {
  4657. $fgshop .= " shop = ".$value." or";
  4658. $sid .= " id = ".$value." or";
  4659. }
  4660. }
  4661. $post = $this->input->post(NULL, TRUE);
  4662. if(isset($post['page']))
  4663. {
  4664. $page = $this->input->post('page',true);
  4665. $perpage = $this->input->post('perpage',true);
  4666. $orderinfo = $this->input->post('orderinfo',true);
  4667. $waybill = $this->input->post('waybill',true);
  4668. $number = $this->input->post('number',true);
  4669. $timetk = $this->input->post('timetk',true);
  4670. $timetj = $this->input->post('timetj',true);
  4671. $timetk = strtotime($timetk);
  4672. $timetj = strtotime($timetj);
  4673. $where = "failed !='' and mergeid = 0 and print != 3 and (".rtrim($fgshop,'or').")";
  4674. if($orderinfo)
  4675. {
  4676. $where .= " and orderinfo = '$orderinfo'";
  4677. }
  4678. if($waybill)
  4679. {
  4680. $where .= " and waybill = '$waybill'";
  4681. }
  4682. if($number)
  4683. {
  4684. $where .= " and number = '$number'";
  4685. }
  4686. if($timetk && $timetj)
  4687. {
  4688. $timetj = $timetj+24*3600;
  4689. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4690. }
  4691. //数据排序
  4692. $order_str = "dtime desc";
  4693. if(empty($page))
  4694. {
  4695. $start = 0;
  4696. $perpage = 1;
  4697. }
  4698. else
  4699. {
  4700. $start = ($page - 1)*$perpage;
  4701. }
  4702. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,express,failed,operation',$order_str,$start,$perpage);
  4703. //格式化数据
  4704. foreach ($info_list as $key=>$value)
  4705. {
  4706. $ud = $this->fullorder->read($value['id']);
  4707. $shop = $this->shop->read($value['shop']);
  4708. $info_list[$key]['shop'] = $shop['shopname'];
  4709. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullorder/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'>".$value['orderinfo']."<p>";
  4710. $warehouse = $this->warehouse->read($value['type']);
  4711. $warehousetitle = $warehouse['title'];
  4712. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  4713. $info_list[$key]['type'] = $warehousetitle;
  4714. if($value['express'] != 0)
  4715. {
  4716. $express = $this->express->read($value['express']);
  4717. $expressservicename = $express['servicename'];
  4718. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  4719. $info_list[$key]['express'] = $expressservicename;
  4720. }
  4721. else
  4722. {
  4723. $info_list[$key]['express'] = "无";
  4724. }
  4725. $x = "";
  4726. if($ud['review'] >4 && $ud['print'] == 1)
  4727. {
  4728. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  4729. }
  4730. else
  4731. {
  4732. $x = "<p class='ckn'><b class='fojzof' data-type='9' data-id='".$value['id']."'>关闭</b></p>";
  4733. }
  4734. $info_list[$key]['operation'] = $x;
  4735. }
  4736. $total = $this->fullorder->find_count($where);
  4737. $pagenum = ceil($total/$perpage);
  4738. $over = $total-($start+$perpage);
  4739. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4740. echo json_encode($rows);exit;
  4741. }
  4742. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4743. $this->data['wlshop'] = $wlshop;
  4744. $this->data['express'] = $this->express->find_all();
  4745. $user = $this->user->get_api($_SESSION['api']);
  4746. $powerid = $this->power->read($user['power']);
  4747. $powertext = explode('|',trim($powerid['excelid'],'|'));
  4748. $pid = '';
  4749. foreach ($powertext as $v)
  4750. {
  4751. $pid .= " id = ".$v." or";
  4752. }
  4753. $fullorderexcel = $this->fullorderexcel->find_all("type = '100001' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  4754. $this->data['fullorderexcel'] = $fullorderexcel;
  4755. $this->_Template('fullorder_error',$this->data);
  4756. }
  4757. //验证地址
  4758. public function _yzaddress()
  4759. {
  4760. $post = $this->input->post(NULL, TRUE);
  4761. if(isset($post['address']))
  4762. {
  4763. $address = $this->input->post('address',true);
  4764. $address2 = $this->input->post('address2',true);
  4765. $city = $this->input->post('city',true);
  4766. $province = $this->input->post('province',true);
  4767. $zipcode = $this->input->post('zipcode',true);
  4768. $barcode = $this->usps->get_address(array('address'=>$address,'address2'=>$address2,'city'=>$city,'province'=>$province,'zipcode'=>$zipcode));
  4769. //$this->logic_ding->sendToDing("usps地址验证返回数据".$barcode);
  4770. echo $barcode;
  4771. }
  4772. }
  4773. //清除退货信息
  4774. public function _clearreturn()
  4775. {
  4776. $post = $this->input->post(NULL, TRUE);
  4777. if(isset($post['orderinfo']))
  4778. {
  4779. $orderinfo = $this->input->post('orderinfo',true);
  4780. $data = $this->fullorder->get_orderinfo($orderinfo);
  4781. $fu = 'fullorder';
  4782. if(!$data)
  4783. {
  4784. $data = $this->fullorder_smt->get_orderinfo($orderinfo);
  4785. $fu = 'fullorder_smt';
  4786. }
  4787. $this->$fu->save(array('library'=>'2','retreattime'=>'0','returndata'=>''),$data['id']);
  4788. echo json_encode(array('msg'=>'清除成功!','success'=>true));exit;
  4789. }
  4790. }
  4791. //订单退货
  4792. public function _return()
  4793. {
  4794. $post = $this->input->post(NULL, TRUE);
  4795. if(isset($post['orderinfo']))
  4796. {
  4797. $orderinfo = $this->input->post('orderinfo',true);
  4798. $data = $this->fullorder->get_orderinfo($orderinfo);
  4799. $fu = 'fullorder';
  4800. if(!$data)
  4801. {
  4802. $data = $this->fullorder_smt->get_orderinfo($orderinfo);
  4803. $fu = 'fullorder_smt';
  4804. }
  4805. $bctime = date('Ymd',time());
  4806. if($data['library'] != 2){
  4807. echo json_encode(array('msg'=>'此单不是出库状态,不允许退货','success'=>false));exit;
  4808. }
  4809. if($data['returndata'] != "")
  4810. {
  4811. echo json_encode(array('msg'=>'请求失败,已有Return Label信息!','success'=>false));exit;
  4812. }
  4813. $barcode = $this->usps->get_return($data);
  4814. // if(isset($barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription']))
  4815. // {
  4816. // echo json_encode(array('msg'=>$barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription'],'success'=>false));exit;
  4817. // }
  4818. // else if(isset($barcode['TrackingNumber']))
  4819. // {
  4820. // $pdf = $this->_pdf($barcode['ReturnLabel'],'t-'.$barcode['TrackingNumber'],$bctime);
  4821. // $read = 'PostalRouting:'.$barcode['PostalRouting'].' - TrackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['TrackingNumber'].'.pdf" target="_blank">'.$barcode['TrackingNumber'].'</a>';
  4822. // $this->$fu->save(array('returndata'=>$read),$data['id']);
  4823. // echo json_encode(array('msg'=>'生成Return Label成功!','data'=>$read,'success'=>true));exit;
  4824. // }
  4825. // else
  4826. // {
  4827. // echo json_encode(array('msg'=>'请求失败,请稍后重试!','cs'=>$barcode,'success'=>false));exit;
  4828. // }
  4829. if(isset($barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription']))
  4830. {
  4831. echo json_encode(array('msg'=>$barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription'],'success'=>false));exit;
  4832. }
  4833. else if(isset($barcode['trackingNumber']))
  4834. {
  4835. $pdf = $this->_pdf($barcode['returnLabelImage'],'t-'.$barcode['trackingNumber'],$bctime);
  4836. $read = 'PostalRouting:'.$barcode['routingInformation'].' - TrackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['trackingNumber'].'.pdf" target="_blank">'.$barcode['trackingNumber'].'</a>';
  4837. $this->$fu->save(array('returndata'=>$read),$data['id']);
  4838. echo json_encode(array('msg'=>'生成Return Label成功!','data'=>$read,'success'=>true));exit;
  4839. }
  4840. else
  4841. {
  4842. echo json_encode(array('msg'=>'请求失败,请稍后重试!'.json_encode($barcode),'cs'=>$barcode,'success'=>false));exit;
  4843. }
  4844. }
  4845. /**
  4846. $post = $this->input->post(NULL, TRUE);
  4847. if(isset($post['orderinfo']))
  4848. {
  4849. $orderinfo = $this->input->post('orderinfo',true);
  4850. $data = $this->fullorder->get_orderinfo($orderinfo);
  4851. $fu = 'fullorder';
  4852. if(!$data)
  4853. {
  4854. $data = $this->fullorder_smt->get_orderinfo($orderinfo);
  4855. $fu = 'fullorder_smt';
  4856. }
  4857. $bctime = date('Ymd',time());
  4858. if($data['returndata'] != "")
  4859. {
  4860. echo json_encode(array('msg'=>'请求失败,已有Return Label信息!','success'=>false));exit;
  4861. }
  4862. $barcode = $this->usps->get_return($data);
  4863. if(isset($barcode['error']['message']))
  4864. {
  4865. echo json_encode(array('msg'=>$barcode['error']['message'],'success'=>false));exit;
  4866. }
  4867. else if(isset($barcode['trackingNumber']))
  4868. {
  4869. $pdf = $this->_pdf($barcode['returnLabelImage'],'t-'.$barcode['trackingNumber'],$bctime);
  4870. $read = 'trackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['trackingNumber'].'.pdf" target="_blank">'.$barcode['trackingNumber'].'</a>';
  4871. $this->$fu->save(array('returndata'=>$read),$data['id']);
  4872. echo json_encode(array('msg'=>'生成Return Label成功!','data'=>$read,'success'=>true));exit;
  4873. }
  4874. else
  4875. {
  4876. echo json_encode(array('msg'=>'请求失败,请稍后重试!','cs'=>$barcode,'success'=>false));exit;
  4877. }
  4878. }**/
  4879. }
  4880. public function _pdf($pdf,$title,$bctime)
  4881. {
  4882. $pdf_path = './data/pdf/'.$bctime.'/';
  4883. $file_base64 = $pdf;
  4884. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4885. $file_base64 = base64_decode($file_base64);
  4886. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  4887. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  4888. return $bctime;
  4889. }
  4890. public function _find($find)
  4891. {
  4892. preg_match_all('/\d+/',$find,$n);
  4893. $a = '';
  4894. foreach($n[0] as $v)
  4895. {
  4896. $a .= $v;
  4897. }
  4898. return $a;
  4899. }
  4900. public function _dqpm()
  4901. {
  4902. if(isset($_SESSION['api']))
  4903. {
  4904. $user = $this->user->get_api($_SESSION['api']);
  4905. $usp = $user;
  4906. $fgshop = "";$sid = "";
  4907. $usersp = explode('|',trim($user['shop'],'|'));
  4908. foreach ($usersp as $value)
  4909. {
  4910. $fgshop .= " shop = ".$value." or";
  4911. $sid .= " id = ".$value." or";
  4912. }
  4913. }
  4914. $post = $this->input->post(NULL, TRUE);
  4915. if(isset($post['page']))
  4916. {
  4917. $timetk = $this->input->post('timetk',true);
  4918. $timetj = $this->input->post('timetj',true);
  4919. $timetk = strtotime($timetk);
  4920. $timetj = strtotime($timetj);
  4921. $where = "mergeid = 0 and (".rtrim($fgshop,'or').")";
  4922. if($timetk && $timetj)
  4923. {
  4924. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4925. }
  4926. //数据排序
  4927. $order_str = "dtime desc";
  4928. if(empty($page))
  4929. {
  4930. $start = 0;
  4931. $perpage = 1;
  4932. }
  4933. else
  4934. {
  4935. $start = ($page - 1)*$perpage;
  4936. }
  4937. $continentdata = '';
  4938. $continent = array();//陆地板块
  4939. $num = $this->fullorder->find_count($where);//订单总数量
  4940. $country = $this->country->find_all('1=1','id,continent,ename,zname');
  4941. foreach ($country as $k=>$v)
  4942. {
  4943. $tc = $this->typeclass->read($v['continent']);
  4944. $continent[$v['continent']] = array(0=>$tc['title'],1=>0,2=>'');
  4945. }
  4946. foreach ($country as $k=>$v)
  4947. {
  4948. $n = $this->fullorder->find_count($where.' and country = "'.$v['id'].'"');
  4949. $country[$k]['continent'] = $continent[$v['continent']][0];//此国家数量
  4950. $country[$k]['zname'] = '<a href="/fullorder/dqpmprovince/'.$v['id'].'/'.$timetk.'/'.$timetj.'">'.$v['zname'].'</a>';//此国家数量
  4951. $country[$k]['num'] = $n;//此国家数量
  4952. $country[$k]['zb'] = (sprintf("%.4f",$n/$num)*100).'%';//此国家占比
  4953. $continent[$v['continent']]['1'] += $n;//此洲数量增加;
  4954. }
  4955. array_multisort(array_column($continent, '1'), SORT_DESC, $continent);
  4956. array_multisort(array_column($country, 'num'), SORT_DESC, $country);
  4957. foreach ($continent as $k=>$v)
  4958. {
  4959. $continentdata .= $v['0'].' 总量:'.$v['1'].' 占比:'.(sprintf("%.4f",$v['1']/$num)*100).'%&nbsp;&nbsp; - &nbsp;&nbsp;';
  4960. }
  4961. echo json_encode(array('ewnr'=>$continentdata,'rows'=>$country,'total'=>count($country),'over'=>0,'pagenum'=>1,'success'=>true));exit;
  4962. }
  4963. $this->_Template('fullorder_dqpm',$this->data);
  4964. }
  4965. public function _dqpmprovince($arg_array)
  4966. {
  4967. if(isset($_SESSION['api']))
  4968. {
  4969. $user = $this->user->get_api($_SESSION['api']);
  4970. $usp = $user;
  4971. $fgshop = "";$sid = "";
  4972. $usersp = explode('|',trim($user['shop'],'|'));
  4973. foreach ($usersp as $value)
  4974. {
  4975. $fgshop .= " shop = ".$value." or";
  4976. $sid .= " id = ".$value." or";
  4977. }
  4978. }
  4979. $post = $this->input->post(NULL, TRUE);
  4980. if(isset($post['page']))
  4981. {
  4982. $country = $this->input->post('country',true);
  4983. $timetk = $this->input->post('timetk',true);
  4984. $timetj = $this->input->post('timetj',true);
  4985. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  4986. $province = array();
  4987. $city_list = $this->fullorder->find_all($where,'id,province');
  4988. $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');
  4989. foreach ($city_list as $k=>$v)
  4990. {
  4991. $v['province'] = strtoupper(trim($v['province'],' '));
  4992. if(isset($ToState[$v['province']]))
  4993. {
  4994. $v['province'] = $ToState[$v['province']];
  4995. }
  4996. if(!isset($province[$v['province']]))
  4997. {
  4998. $province[$v['province']] = array('id'=>$v['id'],'province'=>'<a href="/fullorder/ddpmdata/'.$country.'/'.$timetk.'/'.$timetj.'/'.strtoupper($v['province']).'">'.$v['province'].'</a>','num'=>0,'zb'=>'');
  4999. }
  5000. $province[$v['province']]['num'] += 1;
  5001. }
  5002. array_multisort(array_column($province, 'num'), SORT_DESC, $province);
  5003. $province = array_values($province);
  5004. foreach ($province as $k=>$v)
  5005. {
  5006. $province[$k]['zb'] = (sprintf("%.4f",$v['num']/count($city_list))*100).'%';
  5007. }
  5008. echo json_encode(array('rows'=>($province),'total'=>count($province),'over'=>0,'pagenum'=>1,'success'=>true));exit;
  5009. }
  5010. $this->data['arg_array'] = $arg_array;
  5011. $this->_Template('fullorder_dqpmprovince',$this->data);
  5012. }
  5013. public function _ddpmdata($arg_array)
  5014. {
  5015. $arg_array[3] = str_replace('%20',' ',$arg_array[3]);
  5016. if(isset($_SESSION['api']))
  5017. {
  5018. $user = $this->user->get_api($_SESSION['api']);
  5019. $usp = $user;
  5020. $fgshop = "";$sid = "";
  5021. $usersp = explode('|',trim($user['shop'],'|'));
  5022. foreach ($usersp as $value)
  5023. {
  5024. $fgshop .= " shop = ".$value." or";
  5025. $sid .= " id = ".$value." or";
  5026. }
  5027. }
  5028. $post = $this->input->post(NULL, TRUE);
  5029. if(isset($post['page']))
  5030. {
  5031. $page = $this->input->post('page',true);
  5032. $perpage = $this->input->post('perpage',true);
  5033. $province = $this->input->post('province',true);
  5034. $timetk = $this->input->post('timetk',true);;
  5035. $timetj = $this->input->post('timetj',true);;
  5036. $country = $this->input->post('country',true);;
  5037. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  5038. if($province)
  5039. {
  5040. $where .= " and province = '$province'";
  5041. }
  5042. $order_str = "dtime desc";
  5043. if(empty($page))
  5044. {
  5045. $start = 0;
  5046. $perpage = 1;
  5047. }
  5048. else
  5049. {
  5050. $start = ($page - 1)*$perpage;
  5051. }
  5052. $info_list = $this->fullorder->find_all($where,'id,orderinfo,number,shipremarks,shouldmoney',$order_str,$start,$perpage);
  5053. $total = $this->fullorder->find_count($where);
  5054. $pagenum = ceil($total/$perpage);
  5055. $over = $total-($start+$perpage);
  5056. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5057. echo json_encode($rows);exit;
  5058. }
  5059. $province = array();
  5060. $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');
  5061. $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');
  5062. foreach ($city_list as $k=>$v)
  5063. {
  5064. $v['province'] = strtoupper(trim($v['province'],' '));
  5065. if(isset($ToState[$v['province']]))
  5066. {
  5067. $v['province'] = $ToState[$v['province']];
  5068. }
  5069. $province[$v['province']] = array('province'=>$v['province']);
  5070. }
  5071. $this->data['province'] = $province;
  5072. $this->data['arg_array'] = $arg_array;
  5073. $this->_Template('fullorder_ddpmdata',$this->data);
  5074. }
  5075. public function _ddpmexcel($arg_array)
  5076. {
  5077. if(isset($_SESSION['api']))
  5078. {
  5079. $user = $this->user->get_api($_SESSION['api']);
  5080. $usp = $user;
  5081. $fgshop = "";$sid = "";
  5082. $usersp = explode('|',trim($user['shop'],'|'));
  5083. foreach ($usersp as $value)
  5084. {
  5085. $fgshop .= " shop = ".$value." or";
  5086. $sid .= " id = ".$value." or";
  5087. }
  5088. }
  5089. $province = $this->input->get('province',true);
  5090. $timetk = $arg_array[1];
  5091. $timetj = $arg_array[2];
  5092. $country = $arg_array[0];
  5093. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  5094. if($province)
  5095. {
  5096. $where .= " and province = '$province'";
  5097. }
  5098. $order_str = "dtime desc";
  5099. $info_list = $this->fullorder->find_all($where,'orderinfo,number,shipremarks,shouldmoney',$order_str);
  5100. $country = $this->country->read($arg_array[0]);
  5101. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5102. $titlename = "<table border=1>
  5103. <tr><th colspan='4' align='left'><h3>".$title."<h3></th></tr>
  5104. <tr>
  5105. <td>订单号</td>
  5106. <td>订单编号</td>
  5107. <td>仓库品名</td>
  5108. <td>订单金额</td>
  5109. </tr>
  5110. </table>";
  5111. $filename = $title.".xls";
  5112. $tail = "\n";
  5113. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5114. }
  5115. public function _statedc()
  5116. {
  5117. $user = $this->user->get_api($_SESSION['api']);
  5118. if($user)
  5119. {
  5120. $fgshop = "";$sid = "";
  5121. $user = explode('|',trim($user['shop'],'|'));
  5122. foreach ($user as $value)
  5123. {
  5124. $fgshop .= " shop = ".$value." or";
  5125. $sid .= " id = ".$value." or";
  5126. }
  5127. }
  5128. $post = $this->input->get(NULL, TRUE);
  5129. if(isset($post['timetk']))
  5130. {
  5131. $page = $this->input->get('page',true);
  5132. $perpage = $this->input->get('perpage',true);
  5133. $timetk = $this->input->get('timetk',true);
  5134. $timetj = $this->input->get('timetj',true);
  5135. $shop = $this->input->get('shop',true);
  5136. $source = $this->input->get('source',true);
  5137. $state = $this->input->get('state',true);
  5138. $review = $this->input->get('review',true);
  5139. $express = $this->input->get('express',true);
  5140. $fs = $this->input->get('fs',true);
  5141. $orderinfo = $this->input->get('orderinfo',true);
  5142. $number = $this->input->get('number',true);
  5143. $user = $this->input->get('user',true);
  5144. $name = $this->input->get('name',true);
  5145. $waybill = $this->input->get('waybill',true);
  5146. $expressstate = $this->input->get('expressstate',true);
  5147. $wltype = $this->input->get('wltype',true);
  5148. $wlyc = $this->input->get('wlyc',true);
  5149. $xztime = $this->input->get('xztime',true);
  5150. $timetk = strtotime($timetk);
  5151. $timetj = strtotime($timetj);
  5152. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5153. if($timetk && $timetj)
  5154. {
  5155. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5156. }
  5157. if($xztime == 'librarytime')
  5158. {
  5159. $order_str = "librarytime desc";
  5160. }
  5161. else if($xztime == 'dtime')
  5162. {
  5163. $order_str = "dtime desc";
  5164. }
  5165. if($shop)
  5166. {
  5167. $where .= " and shop = '$shop'";
  5168. }
  5169. if($source)
  5170. {
  5171. if($source == 11)
  5172. {
  5173. $where .= " and source != '1'";
  5174. }
  5175. else
  5176. {
  5177. $where .= " and source = '$source'";
  5178. }
  5179. }
  5180. if($fs)
  5181. {
  5182. if($fs == '2')
  5183. {
  5184. $where .= " and exstateerror != ''";
  5185. }
  5186. else
  5187. {
  5188. $where .= " and exstateerror = ''";
  5189. }
  5190. }
  5191. if($state)
  5192. {
  5193. $where .= " and state = '$state'";
  5194. }
  5195. if($review)
  5196. {
  5197. $where .= " and review = '$review'";
  5198. }
  5199. if($expressstate != "")
  5200. {
  5201. $where .= " and expressstate = '$expressstate'";
  5202. }
  5203. if($wltype != "")
  5204. {
  5205. $where .= " and wltype = '$wltype'";
  5206. }
  5207. if($wlyc != "")
  5208. {
  5209. $where .= " and wlyc = '$wlyc'";
  5210. }
  5211. if($express)
  5212. {
  5213. $where .= " and express = '$express'";
  5214. }
  5215. if($orderinfo)
  5216. {
  5217. $where .= " and orderinfo = '$orderinfo'";
  5218. }
  5219. if($number)
  5220. {
  5221. $where .= " and number = '$number'";
  5222. }
  5223. if($user)
  5224. {
  5225. $where .= " and user = '$user'";
  5226. }
  5227. if($name)
  5228. {
  5229. $where .= " and name = '$name'";
  5230. }
  5231. if($waybill)
  5232. {
  5233. $where .= " and waybill = '$waybill'";
  5234. }
  5235. if(empty($page))
  5236. {
  5237. $start = 0;
  5238. $perpage = 1;
  5239. }
  5240. else
  5241. {
  5242. $start = ($page - 1)*$perpage;
  5243. }
  5244. //取得信息列表
  5245. $info_list = $this->fullorder->find_all($where,'shop,number,country,library,librarytime,expressstate,express,waybill,content,exstateerror,excontent',$order_str);
  5246. //格式化数据
  5247. foreach ($info_list as $key=>$value)
  5248. {
  5249. $shop = $this->shop->read($value['shop']);
  5250. $info_list[$key]['shop'] = $shop['shopname'];
  5251. $country = $this->country->read($value['country']);
  5252. $info_list[$key]['country'] = $country['name'];
  5253. //$state = $this->typeclass->read($value['state']);
  5254. //$info_list[$key]['state'] = $state['title'];
  5255. if($value['library'] == 1)
  5256. {
  5257. $info_list[$key]['library'] = "未出库";
  5258. }
  5259. else if($value['library'] == 2)
  5260. {
  5261. $info_list[$key]['library'] = "已出库";
  5262. }
  5263. else if($value['library'] == 3)
  5264. {
  5265. $info_list[$key]['library'] = "已退库";
  5266. }
  5267. if($value['librarytime'] == '0')
  5268. {
  5269. $info_list[$key]['librarytime'] = '无';
  5270. }
  5271. else
  5272. {
  5273. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  5274. }
  5275. if($value['expressstate'] == 0)
  5276. {
  5277. $info_list[$key]['expressstate'] = "无信息";
  5278. }
  5279. else if($value['expressstate'] == 2)
  5280. {
  5281. $info_list[$key]['expressstate'] = "已取件";
  5282. }
  5283. else if($value['expressstate'] == 3)
  5284. {
  5285. $info_list[$key]['expressstate'] = "在途中";
  5286. }
  5287. /**
  5288. else if($value['expressstate'] == 4)
  5289. {
  5290. $info_list[$key]['expressstate'] = "到达目的地国";
  5291. }
  5292. **/
  5293. else if($value['expressstate'] == 4 || $value['expressstate'] == 5)
  5294. {
  5295. $info_list[$key]['expressstate'] = "即将派送";
  5296. }
  5297. else if($value['expressstate'] == 6)
  5298. {
  5299. $info_list[$key]['expressstate'] = "已签收";
  5300. }
  5301. else if($value['expressstate'] == 1)
  5302. {
  5303. $info_list[$key]['expressstate'] = "派送异常";
  5304. }
  5305. $express = $this->express->read($value['express']);
  5306. $info_list[$key]['express'] = $express['servicename'];
  5307. }
  5308. }
  5309. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5310. $titlename = "<table border=1>
  5311. <tr>
  5312. <td>店铺名称</td>
  5313. <td>编号</td>
  5314. <td>收件人国家</td>
  5315. <td>出库状态</td>
  5316. <td>发货时间</td>
  5317. <td>物流状态</td>
  5318. <td>快递公司</td>
  5319. <td>运单号</td>
  5320. <td>消息状态</td>
  5321. <td>错误提示</td>
  5322. <td>物流信息</td>
  5323. </tr>
  5324. </table>";
  5325. $filename = $title.".xls";
  5326. $tail = "\n";
  5327. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5328. }
  5329. public function _statedcwl()
  5330. {
  5331. $user = $this->user->get_api($_SESSION['api']);
  5332. if($user)
  5333. {
  5334. $fgshop = "";$sid = "";
  5335. $user = explode('|',trim($user['shop'],'|'));
  5336. foreach ($user as $value)
  5337. {
  5338. $fgshop .= " shop = ".$value." or";
  5339. $sid .= " id = ".$value." or";
  5340. }
  5341. }
  5342. $post = $this->input->get(NULL, TRUE);
  5343. if(isset($post['timetk']))
  5344. {
  5345. $dowid = $this->input->get('a');
  5346. $wid = "";
  5347. if($dowid != "")
  5348. {
  5349. $id_arr = explode(',',rtrim($dowid,','));
  5350. $wid .= " id = 0 or";
  5351. foreach ($id_arr as $v)
  5352. {
  5353. $wid .= " id = '$v' or";
  5354. }
  5355. $wid = " and".rtrim($wid,'or');
  5356. }
  5357. $page = $this->input->get('page',true);
  5358. $perpage = $this->input->get('perpage',true);
  5359. $timetk = $this->input->get('timetk',true);
  5360. $timetj = $this->input->get('timetj',true);
  5361. $shop = $this->input->get('shop',true);
  5362. $expressstate = $this->input->get('expressstate',true);
  5363. $fs = $this->input->get('fs',true);
  5364. $state = $this->input->get('state',true);
  5365. $express = $this->input->get('express',true);
  5366. $orderinfo = $this->input->get('orderinfo',true);
  5367. $number = $this->input->get('number',true);
  5368. $waybill = $this->input->get('waybill',true);
  5369. $wlyc = $this->input->get('wlyc',true);
  5370. $wltype = $this->input->get('wltype',true);
  5371. $source = $this->input->get('source',true);
  5372. $xztime = $this->input->get('xztime',true);
  5373. $timetk = strtotime($timetk);
  5374. $timetj = strtotime($timetj);
  5375. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5376. if($timetk && $timetj)
  5377. {
  5378. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5379. }
  5380. if($xztime == 'librarytime')
  5381. {
  5382. $order_str = "librarytime desc";
  5383. }
  5384. else if($xztime == 'dtime')
  5385. {
  5386. $order_str = "dtime desc";
  5387. }else if($xztime == 'wlfstime'){
  5388. $order_str = "wlfstime desc";
  5389. }
  5390. if($shop)
  5391. {
  5392. $where .= " and shop = '$shop'";
  5393. }
  5394. if($expressstate)
  5395. {
  5396. $where .= " and expressstate = '$expressstate'";
  5397. }
  5398. if($fs)
  5399. {
  5400. if($fs == '1')
  5401. {
  5402. $where .= " and wlcontent != ''";
  5403. }
  5404. if($fs == '2')
  5405. {
  5406. $where .= " and wlerror != ''";
  5407. }
  5408. if($fs == '3')
  5409. {
  5410. $where .= " and wlcontent = '' and shouldmoney > 100";
  5411. }
  5412. else if($fs == '4')
  5413. {
  5414. $where .= " and wltype = '1'";
  5415. }
  5416. }
  5417. if($state)
  5418. {
  5419. $where .= " and state = '$state'";
  5420. }
  5421. if($express)
  5422. {
  5423. $where .= " and express = '$express'";
  5424. }
  5425. if($orderinfo)
  5426. {
  5427. $where .= " and orderinfo = '$orderinfo'";
  5428. }
  5429. if($number)
  5430. {
  5431. $where .= " and number = '$number'";
  5432. }
  5433. if($waybill)
  5434. {
  5435. $where .= " and waybill = '$waybill'";
  5436. }
  5437. if($wlyc!='')
  5438. {
  5439. $where .= " and wlyc = '$wlyc'";
  5440. }
  5441. if($wltype!='')
  5442. {
  5443. $where .= " and wltype = '$wltype'";
  5444. }
  5445. if($source)
  5446. {
  5447. if($source == 1)
  5448. {
  5449. $where .= " and source = '$source'";
  5450. }
  5451. else
  5452. {
  5453. $where .= " and source != '1'";
  5454. }
  5455. }
  5456. $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);
  5457. //格式化数据
  5458. foreach ($info_list as $key=>$value)
  5459. {
  5460. $country = $this->country->read($value['country']);
  5461. $info_list[$key]['country'] = $country['name'];
  5462. //$state = $this->typeclass->read($value['state']);
  5463. //$info_list[$key]['state'] = $state['title'];
  5464. if($value['library'] == 1)
  5465. {
  5466. $info_list[$key]['library'] = "未出库";
  5467. }
  5468. else if($value['library'] == 2)
  5469. {
  5470. $info_list[$key]['library'] = "已出库";
  5471. }
  5472. else if($value['library'] == 3)
  5473. {
  5474. $info_list[$key]['library'] = "已退库";
  5475. }
  5476. if($value['librarytime'] == '0')
  5477. {
  5478. $info_list[$key]['librarytime'] = '无';
  5479. }
  5480. else
  5481. {
  5482. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  5483. }
  5484. if($value['expressstate'] == 0)
  5485. {
  5486. $info_list[$key]['expressstate'] = "无信息";
  5487. }
  5488. else if($value['expressstate'] == 2)
  5489. {
  5490. $info_list[$key]['expressstate'] = "已取件";
  5491. }
  5492. else if($value['expressstate'] == 3)
  5493. {
  5494. $info_list[$key]['expressstate'] = "在途中";
  5495. }
  5496. /**
  5497. else if($value['expressstate'] == 4)
  5498. {
  5499. $info_list[$key]['expressstate'] = "到达目的地国";
  5500. }
  5501. **/
  5502. else if($value['expressstate'] == 4 || $value['expressstate'] == 5)
  5503. {
  5504. $info_list[$key]['expressstate'] = "即将派送";
  5505. }
  5506. else if($value['expressstate'] == 6)
  5507. {
  5508. $info_list[$key]['expressstate'] = "已签收";
  5509. }
  5510. else if($value['expressstate'] == 1)
  5511. {
  5512. $info_list[$key]['expressstate'] = "派送异常";
  5513. }
  5514. $info_list[$key]['wlfstime'] = date('Y-m-d H:i:s',$value['wlfstime']);
  5515. $express = $this->express->read($value['express']);
  5516. $info_list[$key]['express'] = $express['servicename'];
  5517. $info_list[$key]['excontent'] = str_replace('<br />','',$value['excontent']);
  5518. }
  5519. }
  5520. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5521. $titlename = "<table border=1>
  5522. <tr>
  5523. <td>订单号</td>
  5524. <td>编号</td>
  5525. <td>收件人国家</td>
  5526. <td>出库状态</td>
  5527. <td>出库时间</td>
  5528. <td>物流状态</td>
  5529. <td>快递公司</td>
  5530. <td>运单号</td>
  5531. <td>物流备注</td>
  5532. <td>订单备注</td>
  5533. <td>仓库品名</td>
  5534. <td>发送时间</td>
  5535. <td>邮箱</td>
  5536. <td>电话</td>
  5537. <td>邮件发送</td>
  5538. <td>错误提示</td>
  5539. <td>物流信息</td>
  5540. </tr>
  5541. </table>";
  5542. $filename = $title.".xls";
  5543. $tail = "\n";
  5544. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5545. }
  5546. public function _waybillemail()
  5547. {
  5548. $user = $this->user->get_api($_SESSION['api']);
  5549. if($user)
  5550. {
  5551. $fgshop = "";$sid = "";
  5552. $user = explode('|',trim($user['shop'],'|'));
  5553. foreach ($user as $value)
  5554. {
  5555. $fgshop .= " shop = ".$value." or";
  5556. $sid .= " id = ".$value." or";
  5557. }
  5558. }
  5559. $post = $this->input->post(NULL, TRUE);
  5560. if(isset($post['page']))
  5561. {
  5562. $page = $this->input->post('page',true);
  5563. $perpage = $this->input->post('perpage',true);
  5564. $timetk = $this->input->post('timetk',true);
  5565. $timetj = $this->input->post('timetj',true);
  5566. $shop = $this->input->post('shop',true);
  5567. $source = $this->input->post('source',true);
  5568. $expressstate = $this->input->post('expressstate',true);
  5569. $fs = $this->input->post('fs',true);
  5570. $state = $this->input->post('state',true);
  5571. $express = $this->input->post('express',true);
  5572. $orderinfo = $this->input->post('orderinfo',true);
  5573. $number = $this->input->post('number',true);
  5574. $waybill = $this->input->post('waybill',true);
  5575. $dlzemail = $this->input->post('dlzemail',true);
  5576. $xztime = $this->input->post('xztime',true);
  5577. $timetk = strtotime($timetk);
  5578. $timetj = strtotime($timetj);
  5579. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5580. if($timetk && $timetj)
  5581. {
  5582. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5583. }
  5584. $order_str = $xztime." desc";
  5585. if($source)
  5586. {
  5587. if($source == '2d')
  5588. {
  5589. $where .= " and source >= '2' and shop != 19";
  5590. }
  5591. else
  5592. {
  5593. $where .= " and source = '$source'";
  5594. }
  5595. }
  5596. if($shop)
  5597. {
  5598. $where .= " and shop = '$shop'";
  5599. }
  5600. if($expressstate)
  5601. {
  5602. $where .= " and expressstate = '$expressstate'";
  5603. }
  5604. if($state)
  5605. {
  5606. $where .= " and state = '$state'";
  5607. }
  5608. if($express)
  5609. {
  5610. $where .= " and express = '$express'";
  5611. }
  5612. if($orderinfo)
  5613. {
  5614. $where .= " and orderinfo = '$orderinfo'";
  5615. }
  5616. if($number)
  5617. {
  5618. $where .= " and number = '$number'";
  5619. }
  5620. if($waybill)
  5621. {
  5622. $where .= " and waybill = '$waybill'";
  5623. }
  5624. if($dlzemail != '')
  5625. {
  5626. $where .= " and dlzemail = '$dlzemail'";
  5627. }
  5628. if(empty($page))
  5629. {
  5630. $start = 0;
  5631. $perpage = 1;
  5632. }
  5633. else
  5634. {
  5635. $start = ($page - 1)*$perpage;
  5636. }
  5637. //取得信息列表
  5638. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,country,library,librarytime,express,waybill,dlzemail,dlzemailtime',$order_str,$start,$perpage);
  5639. //格式化数据
  5640. foreach ($info_list as $key=>$value)
  5641. {
  5642. $shop = $this->shop->read($value['shop']);
  5643. $info_list[$key]['shop'] = $shop['shopname'];
  5644. $country = $this->country->read($value['country']);
  5645. $info_list[$key]['country'] = $country['name'];
  5646. //$state = $this->typeclass->read($value['state']);
  5647. //$info_list[$key]['state'] = $state['title'];
  5648. if($value['library'] == 1)
  5649. {
  5650. $info_list[$key]['library'] = "未出库";
  5651. }
  5652. else if($value['library'] == 2)
  5653. {
  5654. $info_list[$key]['library'] = "已出库";
  5655. }
  5656. else if($value['library'] == 3)
  5657. {
  5658. $info_list[$key]['library'] = "已退库";
  5659. }
  5660. if($value['librarytime'] == '0')
  5661. {
  5662. $info_list[$key]['librarytime'] = '无';
  5663. }
  5664. else
  5665. {
  5666. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']);
  5667. }
  5668. $express = $this->express->read($value['express']);
  5669. $info_list[$key]['express'] = $express['servicename'];
  5670. if($value['dlzemail'] == '1')
  5671. {
  5672. $info_list[$key]['dlzemail'] = '发送成功';
  5673. }
  5674. else if ($value['dlzemail'] == '2')
  5675. {
  5676. $info_list[$key]['dlzemail'] = '发送失败';
  5677. }
  5678. else
  5679. {
  5680. $info_list[$key]['dlzemail'] = '';
  5681. }
  5682. $info_list[$key]['dlzemailtime'] = ($value['dlzemailtime']>0)?date('Y-m-d H:i:s',$value['dlzemailtime']):'';
  5683. }
  5684. $total = $this->fullorder->find_count($where);
  5685. $pagenum = ceil($total/$perpage);
  5686. $over = $total-($start+$perpage);
  5687. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5688. echo json_encode($rows);exit;
  5689. }
  5690. $notice = $this->notice->find_all("type = '2' and (".rtrim($fgshop,'or').")");
  5691. $this->data['notice'] = $notice;
  5692. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  5693. $this->data['wlshop'] = $wlshop;
  5694. $this->data['express'] = $this->express->find_all();
  5695. $this->_Template('fullorder_waybillemail',$this->data);
  5696. }
  5697. public function _khdd()
  5698. {
  5699. $dt = 0;$fgshop = "shop = 0";$sid = 'id = 0';
  5700. if(isset($_SESSION['api']))
  5701. {
  5702. $user = $this->user->get_api($_SESSION['api']);
  5703. $usp = $user;
  5704. $fgshop = "";$sid = "";
  5705. $usersp = explode('|',trim($user['shop'],'|'));
  5706. foreach ($usersp as $value)
  5707. {
  5708. $fgshop .= " shop = ".$value." or";
  5709. $sid .= " id = ".$value." or";
  5710. }
  5711. if($user['vip'] == 1)
  5712. {
  5713. $vip = 1;
  5714. }
  5715. else
  5716. {
  5717. $vip = 0;
  5718. }
  5719. }
  5720. $post = $this->input->post(NULL, TRUE);
  5721. if(isset($_GET['excel']))
  5722. {
  5723. $page = $this->input->get('page',true);
  5724. $perpage = $this->input->get('perpage',true);
  5725. $warehouse = $this->input->get('warehouse',true);
  5726. $timetk = $this->input->get('timetk',true);
  5727. $timetj = $this->input->get('timetj',true);
  5728. $shop = $this->input->get('shop',true);
  5729. $source = $this->input->get('source',true);
  5730. $state = $this->input->get('state',true);
  5731. $review = $this->input->get('review',true);
  5732. $type = $this->input->get('type',true);
  5733. $express = $this->input->get('express',true);
  5734. $orderinfo = $this->input->get('orderinfo',true);
  5735. $user = $this->input->get('user',true);
  5736. $client = $this->input->get('name',true);
  5737. $waybill = $this->input->get('waybill',true);
  5738. $number = $this->input->get('number',true);
  5739. $email = $this->input->get('email',true);
  5740. $phone = $this->input->get('phone',true);
  5741. $dlz = $this->input->get('dlz',true);
  5742. $print = $this->input->get('print',true);
  5743. $library = $this->input->get('library',true);
  5744. $js = $this->input->get('js',true);
  5745. $exstate = $this->input->get('exstate',true);
  5746. $xztime = $this->input->get('xztime',true);
  5747. $libraryconfirm = $this->input->get('libraryconfirm',true);
  5748. $timetk = strtotime($timetk);
  5749. $timetj = strtotime($timetj);
  5750. $plorder = $this->input->get('pl',true);
  5751. $paypal = $this->input->get('paypal',true);
  5752. $zf = $this->input->get('zf',true);
  5753. $pay = $this->input->get('pay',true);
  5754. $excel = $this->input->get('excel',true);
  5755. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5756. if($warehouse)
  5757. {
  5758. $where .= " and type = '$warehouse'";
  5759. }
  5760. if($timetk && $timetj)
  5761. {
  5762. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5763. }
  5764. if($shop)
  5765. {
  5766. $where .= " and shop = '$shop'";
  5767. }
  5768. if($source)
  5769. {
  5770. if($source == '2d')
  5771. {
  5772. $where .= " and source >= '2'";
  5773. }
  5774. else
  5775. {
  5776. $where .= " and source = '$source'";
  5777. }
  5778. }
  5779. if($state)
  5780. {
  5781. $where .= " and state = '$state'";
  5782. }
  5783. if($review)
  5784. {
  5785. $where .= " and review = '$review'";
  5786. }
  5787. if($type)
  5788. {
  5789. $where .= " and type = '$type'";
  5790. }
  5791. if($express)
  5792. {
  5793. $where .= " and express = '$express'";
  5794. }
  5795. if($orderinfo)
  5796. {
  5797. $where .= " and orderinfo = '$orderinfo'";
  5798. }
  5799. if($user)
  5800. {
  5801. $where .= " and user = '$user'";
  5802. }
  5803. if($client)
  5804. {
  5805. $where .= " and client like '%$client%'";
  5806. }
  5807. if($waybill)
  5808. {
  5809. $where .= " and waybill = '$waybill'";
  5810. }
  5811. if($number)
  5812. {
  5813. $where .= " and number = '$number'";
  5814. }
  5815. if($email)
  5816. {
  5817. $where .= " and email = '$email'";
  5818. }
  5819. if($phone)
  5820. {
  5821. $where .= " and phone like '%$phone%'";
  5822. }
  5823. if($library)
  5824. {
  5825. $where .= " and library = '$library'";
  5826. }
  5827. if($print)
  5828. {
  5829. $where .= " and print = '$print'";
  5830. }
  5831. if($dlz != '')
  5832. {
  5833. $where .= " and dlz = '$dlz'";
  5834. }
  5835. if($js)
  5836. {
  5837. $where .= " and js = '$js'";
  5838. }
  5839. if($exstate)
  5840. {
  5841. $where .= " and exstate = '$exstate'";
  5842. }
  5843. if($libraryconfirm)
  5844. {
  5845. $where .= " and libraryconfirm = '$libraryconfirm'";
  5846. }
  5847. if($paypal)
  5848. {
  5849. $where .= " and paypal = '$paypal'";
  5850. }
  5851. if($pay)
  5852. {
  5853. $where .= " and pay = '$pay'";
  5854. }
  5855. if($zf)
  5856. {
  5857. if($zf == 1)
  5858. {
  5859. $where .= " and paypal not like '%-%-%-%'";
  5860. }
  5861. else
  5862. {
  5863. $where .= " and paypal like '%-%-%-%'";
  5864. }
  5865. }
  5866. if($plorder)
  5867. {
  5868. $plorderinfo = '';$plnumber = '';$pln = 0;
  5869. $plorder = explode(',',trim($plorder,','));
  5870. foreach ($plorder as $value)
  5871. {
  5872. if(is_numeric($value))
  5873. {
  5874. $plorderinfo .= " orderinfo = ".$value." or";
  5875. }
  5876. else if($value != '')
  5877. {
  5878. $plorderinfo .= " number = '".$value."' or";
  5879. }
  5880. }
  5881. if($pln > 0)
  5882. {
  5883. $where .= " and (".rtrim($plorderinfo,'or').") and (".rtrim($plnumber,'or').")";
  5884. }
  5885. else
  5886. {
  5887. $where .= " and (".rtrim($plorderinfo,'or').")";
  5888. }
  5889. }
  5890. //数据排序
  5891. $order_str = "dtime desc";
  5892. if(empty($page))
  5893. {
  5894. $start = 0;
  5895. $perpage = 1;
  5896. }
  5897. else
  5898. {
  5899. $start = ($page - 1)*$perpage;
  5900. }
  5901. if($excel == '1')
  5902. {
  5903. $shop = array();
  5904. $shopdata = $this->shop->find_all("type = '269'");
  5905. foreach ($shopdata as $v)
  5906. {
  5907. $shop[$v['id']] = array('t'=>$v['brandname'],'z'=>0,'l'=>0,'x'=>0);//店铺名称,总客户,老客户,新客户
  5908. }
  5909. $oldnumber = 0;$newnumber = 0;
  5910. $info_list = $this->db->query('select distinct shop,email from crowd_fullorder where '.$where)->result_array();
  5911. foreach ($info_list as $key=>$v)
  5912. {
  5913. $shop[$v['shop']]['z'] += 1;
  5914. $num = $this->fullorder->find_count("email = '".$v['email']."' and shop = '".$v['shop']."' and ".$xztime." < '$timetj'");
  5915. if($num > 1)
  5916. {
  5917. $shop[$v['shop']]['l'] += 1;
  5918. }
  5919. else
  5920. {
  5921. $shop[$v['shop']]['x'] += 1;
  5922. }
  5923. if(isset($v['email']) && $usp['excelpass'] == '1')
  5924. {
  5925. $emailpass = $this->setting->get_excelpass($v['email']);
  5926. $info_list[$key]['email'] = $emailpass;
  5927. }
  5928. }
  5929. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5930. $titlename = "<table border=1>
  5931. <tr>
  5932. <td>店铺</td>
  5933. <td>客户数</td>
  5934. <td>老客户数</td>
  5935. <td>新客户数</td>
  5936. </tr>
  5937. </table>";
  5938. $filename = $title.".xls";
  5939. $tail = "\n";
  5940. $this->excel->get_fz2($shop,$titlename,$filename,$tail);
  5941. }
  5942. else if($excel == '2' || $excel == '3')
  5943. {
  5944. $kh = array();
  5945. $info_list = $this->db->query('select distinct shop,email from crowd_fullorder where email != "" and '.$where)->result_array();
  5946. foreach ($info_list as $key=>$v)
  5947. {
  5948. $k = $this->fullorder->find_all("shop = '".$v['shop']."' and email = '".$v['email']."' and ".$xztime." < '$timetj'",'name,email,dtime,shouldmoney','dtime desc');
  5949. if($excel == 2 && count($k) > 1)
  5950. {
  5951. $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')));
  5952. }
  5953. if($excel == 3 && count($k) < 2)
  5954. {
  5955. $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')));
  5956. }
  5957. if(isset($v['email']) && $usp['excelpass'] == '1')
  5958. {
  5959. $emailpass = $this->setting->get_excelpass($v['email']);
  5960. $info_list[$key]['email'] = $emailpass;
  5961. }
  5962. }
  5963. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5964. $titlename = "<table border=1>
  5965. <tr>
  5966. <td>名称</td>
  5967. <td>邮箱</td>
  5968. <td>最后购买时间</td>
  5969. <td>购买次数</td>
  5970. <td>购买总额</td>
  5971. </tr>
  5972. </table>";
  5973. $filename = $title.".xls";
  5974. $tail = "\n";
  5975. $this->excel->get_fz2($kh,$titlename,$filename,$tail);
  5976. }
  5977. else if($excel == '4' || $excel == '5')
  5978. {
  5979. $kh = array();
  5980. $info_list = $this->db->query('select distinct shop,email from crowd_fullorder where email != "" and '.$where)->result_array();
  5981. foreach ($info_list as $key=>$value)
  5982. {
  5983. $k = $this->fullorder->find_all("shop = '".$value['shop']."' and email = '".$value['email']."' and ".$xztime." < '$timetj'",'orderinfo,state,product,name,email,dtime,shouldmoney','dtime desc');
  5984. if($excel == 4 && count($k) > 1)
  5985. {
  5986. foreach ($k as $v)
  5987. {
  5988. $typeclass = $this->typeclass->read($v['state']);
  5989. $kh[] = array($v['orderinfo'],$typeclass['spare'],$v['product'],$v['name'],$v['email'],date("Y-m-d H:i:s",$v['dtime']),$v['shouldmoney']);
  5990. }
  5991. }
  5992. if($excel == 5 && count($k) < 2)
  5993. {
  5994. if(!isset($k[0]['state']))
  5995. {
  5996. $typeclass = $k[0]['state'].'-数据字典无此信息';
  5997. }
  5998. else
  5999. {
  6000. $typeclass = $this->typeclass->read($k[0]['state']);
  6001. }
  6002. $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']);
  6003. }
  6004. if(isset($value['email']) && $usp['excelpass'] == '1')
  6005. {
  6006. $emailpass = $this->setting->get_excelpass($value['email']);
  6007. $info_list[$key]['email'] = $emailpass;
  6008. }
  6009. }
  6010. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  6011. $titlename = "<table border=1>
  6012. <tr>
  6013. <td>订单号</td>
  6014. <td>订单状态</td>
  6015. <td>产品名</td>
  6016. <td>客户名</td>
  6017. <td>客户邮箱</td>
  6018. <td>下单时间</td>
  6019. <td>订单金额</td>
  6020. </tr>
  6021. </table>";
  6022. $filename = $title.".xls";
  6023. $tail = "\n";
  6024. $this->excel->get_fz2($kh,$titlename,$filename,$tail);
  6025. }
  6026. }
  6027. }
  6028. public function _klarnadata()
  6029. {
  6030. $post = $this->input->post(NULL, TRUE);
  6031. if(isset($post['number']))
  6032. {
  6033. $number = $this->input->post('number',true);
  6034. $data = $this->fullorder->get_number($number);
  6035. $shop = $this->shop->read($data['shop']);
  6036. $f = '';
  6037. if($data['pay'] == '23')
  6038. {
  6039. $url = 'https://api-na.klarna.com/ordermanagement/v1/orders/'.$data['paypal'];
  6040. $header[] = "Content-Type:application/json";
  6041. $header[] = "Authorization: Basic ".base64_encode($shop['klarnaname'].":".$shop['klarnapass']);
  6042. $ch = curl_init();
  6043. curl_setopt($ch, CURLOPT_URL, $url);
  6044. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6045. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  6046. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6047. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  6048. $res = curl_exec($ch);
  6049. curl_close($ch);
  6050. $res = json_decode($res,true);
  6051. if(isset($res['fraud_status']) && $shop['klarnaname'] != '')
  6052. {
  6053. $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'];
  6054. }
  6055. }
  6056. else if(($data['pay'] == '22' || $data['pay'] == '7') && $shop['paypalname'] != '')
  6057. {
  6058. $f = $this->paypal->data($data['paypal'],$shop);
  6059. }
  6060. else if(($data['pay'] == '26') && $shop['afterpayname'] != '')
  6061. {
  6062. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$data['paypal'];
  6063. $header[] = "Accept:application/json";
  6064. $header[] = "User-Agent: Readme.io API Simulator'";
  6065. $header[] = "Authorization: Basic ".base64_encode($shop['afterpayname'].":".$shop['afterpaypass']);
  6066. $ch = curl_init();
  6067. curl_setopt($ch, CURLOPT_URL, $url);
  6068. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6069. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  6070. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6071. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  6072. $res = curl_exec($ch);
  6073. curl_close($ch);
  6074. $res = json_decode($res,true);
  6075. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  6076. {
  6077. $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'];
  6078. $f = str_replace(',,',',',$f);
  6079. }
  6080. }
  6081. else if(($data['pay'] == '27') && $shop['clearpayname'] != '')
  6082. {
  6083. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$data['paypal'];
  6084. $header[] = "Accept:application/json";
  6085. $header[] = "User-Agent: Readme.io API Simulator'";
  6086. $header[] = "Authorization: Basic ".base64_encode($shop['clearpayname'].":".$shop['clearpaypass']);
  6087. $ch = curl_init();
  6088. curl_setopt($ch, CURLOPT_URL, $url);
  6089. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6090. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  6091. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6092. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  6093. $res = curl_exec($ch);
  6094. curl_close($ch);
  6095. $res = json_decode($res,true);
  6096. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  6097. {
  6098. $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'];
  6099. $f = str_replace(',,',',',$f);
  6100. }
  6101. }
  6102. else if($data['pay'] == '1211')
  6103. {
  6104. $url = 'https://api.stripe.com/v1/payment_intents/'.$data['paypal'];
  6105. $header[] = "Authorization:Bearer ".$shop['stripe'];
  6106. $ch = curl_init();
  6107. curl_setopt($ch, CURLOPT_URL, $url);
  6108. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6109. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  6110. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6111. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  6112. $res = curl_exec($ch);
  6113. curl_close($ch);
  6114. $res = json_decode($res,true);
  6115. $f = '';
  6116. if(isset($res['shipping']['name']))
  6117. {
  6118. $line = ($res['shipping']['address']['line2'] != '')?$res['shipping']['address']['line1'].' '.$res['shipping']['address']['line2']:$res['shipping']['address']['line1'];
  6119. $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));
  6120. }
  6121. }
  6122. else
  6123. {
  6124. echo json_encode(array('msg'=>'此店铺没有对接信息','success'=>false));exit;
  6125. }
  6126. if($f != '')
  6127. {
  6128. if($this->fullorder->save(array('klarnadata'=>$f),$data['id']))
  6129. {
  6130. echo json_encode(array('msg'=>'获取成功,请关闭此页重新打开','success'=>true));exit;
  6131. }
  6132. else
  6133. {
  6134. echo json_encode(array('msg'=>'写入失败,请重试','success'=>false));exit;
  6135. }
  6136. }
  6137. else
  6138. {
  6139. echo json_encode(array('msg'=>'获取失败,请稍后重试','cl'=>base64_encode($shop['afterpayname'].":".$shop['afterpaypass']),'a'=>$data['paypal'],'success'=>false));exit;
  6140. }
  6141. }
  6142. }
  6143. public function _kcyz($warehouse,$whlabel,$id,$shop,$number)
  6144. {
  6145. if(!$whlabel || $whlabel == '|')
  6146. {
  6147. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  6148. }
  6149. $w = $this->warehouse->read($warehouse);
  6150. if($w['zd'] != 1)
  6151. {
  6152. return 1;
  6153. }
  6154. $pp = explode('|',trim($whlabel,'|'));
  6155. $x = 0;$save = array();
  6156. foreach ($pp as $va)
  6157. {
  6158. $num = explode('-',$va);
  6159. if($number)
  6160. {
  6161. $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 = '')");//通用
  6162. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  6163. }
  6164. else
  6165. {
  6166. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  6167. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  6168. }
  6169. $x++;
  6170. if(count($whlabel)+count($shopwhlabel) < $num[1])
  6171. {
  6172. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  6173. }
  6174. }
  6175. return $save;
  6176. }
  6177. public function _epod()
  6178. {
  6179. $post = $this->input->post(NULL, TRUE);
  6180. if(isset($post['number']))
  6181. {
  6182. $number = $this->input->post('number',true);
  6183. $data = $this->fullorder->get_number($number);
  6184. if(is_file('./data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf'))
  6185. {
  6186. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].'/data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf','success'=>true));exit;
  6187. }
  6188. else
  6189. {
  6190. $epod = $this->dhl->get_epod($data);
  6191. if($epod['c'] == 1)
  6192. {
  6193. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].$epod['d'],'success'=>true));exit;
  6194. }
  6195. else
  6196. {
  6197. echo json_encode(array('msg'=>$epod['d'],'success'=>false));exit;
  6198. }
  6199. }
  6200. }
  6201. }
  6202. public function _zw($arg_array)
  6203. {
  6204. $arg_array = $arg_array[0];$fpdata = array();
  6205. $fullorder = $this->fullorder->read($arg_array);
  6206. $fullorder['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$fullorder['shipremarks']);
  6207. $fullorder['parameter'] = str_replace(",","---",$fullorder['parameter']);
  6208. $this->data['fullorder'] = $fullorder;
  6209. $this->data['countrys'] = $this->country->find_all();
  6210. $this->data['express'] = $this->express->find_all();
  6211. $warehouse = $this->warehouse->read($fullorder['type']);
  6212. if(stripos($fullorder['fpdata'],';') !== false)
  6213. {
  6214. $fpdata = explode(';',rtrim($fullorder['fpdata'],';'));
  6215. foreach ($fpdata as $k=>$v)
  6216. {
  6217. $xxv = explode('|',$v);
  6218. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  6219. {
  6220. $xxv['zd'] = "<p>已占单</p>";
  6221. $bdck = $warehouse['bdck'];
  6222. if(stripos($xxv[9],'~') !== false)
  6223. {
  6224. $dxxv = explode('~',trim($xxv[9],'~'));
  6225. foreach ($dxxv as $val)
  6226. {
  6227. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  6228. if($wzid['details'] != '')
  6229. {
  6230. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  6231. }
  6232. }
  6233. }
  6234. else
  6235. {
  6236. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  6237. if($wzid['details'] != '')
  6238. {
  6239. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  6240. }
  6241. }
  6242. }
  6243. $fpdata[$k] = $xxv;
  6244. }
  6245. }
  6246. $this->data['fpdata'] = $fpdata;
  6247. $this->data['fpdata'] = $fpdata;
  6248. $thfpdataxs = array();
  6249. if($fullorder['thfpdata'] != '')
  6250. {
  6251. $thfpdata = explode(';',trim($fullorder['thfpdata'],';'));
  6252. foreach ($thfpdata as $k=>$v)
  6253. {
  6254. $thxs = explode('~',trim($v,'~'));
  6255. $thxs[0] = explode('|',trim($thxs[0],'|'));
  6256. $thxs[1] = explode('|',trim($thxs[1],'|'));
  6257. $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]);
  6258. }
  6259. }
  6260. $this->data['thfpdata'] = $thfpdataxs;
  6261. $shop = $this->shop->read($fullorder['shop']);
  6262. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  6263. $is = 0;
  6264. if($shop['type'] == 269 || $shop['type'] == 2678)//判断是否独立站,269是独立站
  6265. {
  6266. $is = 1;
  6267. }
  6268. $this->data['is'] = $is;
  6269. //单项开始
  6270. $warehouse = $this->warehouse->read($fullorder['warehouse']);//发货仓库
  6271. $state = $this->typeclass->read($fullorder['state']);//订单状态
  6272. $country = $this->country->read($fullorder['country']);//国家
  6273. if($fullorder['capital'] == 1)
  6274. {
  6275. $capital = '暂未支付';
  6276. }
  6277. else if($fullorder['capital'] == 2)
  6278. {
  6279. $capital = '部分支付';
  6280. }
  6281. else if($fullorder['capital'] == 3)
  6282. {
  6283. $capital = '全部支付';
  6284. }
  6285. if($fullorder['printtype'] == 1)
  6286. {
  6287. $printtype = '运单';
  6288. }
  6289. else if($fullorder['printtype'] == 2)
  6290. {
  6291. $printtype = '发货单';
  6292. }
  6293. else if($fullorder['printtype'] == 3)
  6294. {
  6295. $printtype = '不打印单据';
  6296. }
  6297. else
  6298. {
  6299. $printtype = '未选择';
  6300. }
  6301. $this->data['warehouse'] = $warehouse['title'];
  6302. $this->data['state'] = $state['title'];
  6303. $this->data['capital'] = $capital;
  6304. $this->data['country'] = $country['name'];
  6305. $this->data['printtype'] = $printtype;
  6306. //单项结束
  6307. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  6308. $downwaybill = '';$dwls = array();
  6309. $oldwaybill = explode('-',ltrim($fullorder['oldwaybill'],'-'));
  6310. if(isset($oldwaybill[0][1]))
  6311. {
  6312. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  6313. foreach ($oldwaybill as $v)
  6314. {
  6315. $dw = explode('/',$v);
  6316. if(isset($dw[1]))
  6317. {
  6318. if(stripos($downwaybill,$dw[1]) === false)
  6319. {
  6320. $dwls[$dw[1]] = 1;
  6321. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  6322. }
  6323. }
  6324. }
  6325. }
  6326. if($fullorder['printtype'] == 1)
  6327. {
  6328. if($fullorder['waybill'] != '' && !isset($dwls[$fullorder['waybill']]))
  6329. {
  6330. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullorder['printtime']).'/y-'.$fullorder['waybill'].'.pdf" target="_blank">'.$fullorder['waybill'].'</a>、'.$downwaybill;
  6331. }
  6332. }
  6333. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  6334. /** 历史打印时间 **/
  6335. $printtime = '';
  6336. if($fullorder['oldprinttime'])
  6337. {
  6338. $pte = explode('-',rtrim($fullorder['oldprinttime'],'-'));
  6339. foreach ($pte as $v)
  6340. {
  6341. $printtime .= date('Y-m-d H:i:s',$v).'、';
  6342. }
  6343. }
  6344. $this->data['printtime'] = rtrim($printtime,'、');
  6345. $product = '';
  6346. $fullorder['product'] = str_replace("'","",$fullorder['product']);
  6347. if($fullorder['link'] != '' && $fullorder['source'] != '1')
  6348. {
  6349. $pt = explode(',',$fullorder['product']);
  6350. $lk = explode(',',$fullorder['link']);
  6351. for($i=0;$i<count($pt);$i++)
  6352. {
  6353. if(isset($lk[$i]))
  6354. {
  6355. $octs = $this->colourorderts->get_texturl($pt[$i],$lk[$i]);
  6356. }
  6357. else
  6358. {
  6359. $octs = '';
  6360. }
  6361. $a = $octs?'<font style="color:#'.$octs['colour'].'">'.$pt[$i].'</font>':$pt[$i];
  6362. //$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];
  6363. if(isset($lk[$i]))
  6364. {
  6365. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  6366. }
  6367. else
  6368. {
  6369. $product .= ($product != '')?' , '.$a:$a;
  6370. }
  6371. }
  6372. }
  6373. else
  6374. {
  6375. $octs = $this->colourorderts->get_text($fullorder['product']);
  6376. $a = $octs?'<font style="color:#F39">'.$fullorder['product'].'</font>':$fullorder['product'];
  6377. //$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'];
  6378. $product = $a;
  6379. }
  6380. $this->data['product'] = $product;
  6381. $out = $this->systemtransfer->find_all("number = '".$fullorder['number']."'");
  6382. $outread = '';
  6383. if($out)
  6384. {
  6385. foreach ($out as $val)
  6386. {
  6387. $list = '';
  6388. $rk = explode('|',trim($val['rk'],'|'));
  6389. $rktime = explode('|',trim($val['rktime'],'|'));
  6390. $zw = array();
  6391. $t = $this->transfer->find_all("1=1");
  6392. foreach ($t as $v)
  6393. {
  6394. $zw[$v['id']] = $v['title'];
  6395. }
  6396. if($val['rk'] != '' && count($rk) > 0)
  6397. {
  6398. for($i=0;$i<count($rk);$i++)
  6399. {
  6400. if(!isset($rktime[$i]))
  6401. {
  6402. $list .= $zw[$cz[$i]];
  6403. }
  6404. else
  6405. {
  6406. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  6407. }
  6408. }
  6409. }
  6410. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  6411. }
  6412. }
  6413. else
  6414. {
  6415. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullorder['number']."'");
  6416. $outread = array();
  6417. if($systemwigsout)
  6418. {
  6419. foreach ($systemwigsout as $v)
  6420. {
  6421. if($v['czwarehouse'] == 37)
  6422. {
  6423. $outread[] = '华荣厂';
  6424. }
  6425. else if($v['czwarehouse'] == 0)
  6426. {
  6427. $outread[] = '龙盈厂';
  6428. }
  6429. $cz = explode('|',trim($v['cz'],'|'));
  6430. $cztime = explode('|',trim($v['cztime'],'|'));
  6431. $zw = $this->transfer->get_list();
  6432. if($v['cz'] != '' && count($cz) > 0)
  6433. {
  6434. for($i=0;$i<count($cz);$i++)
  6435. {
  6436. if(!isset($cztime[$i]))
  6437. {
  6438. $outread[] = $zw[$cz[$i]].' -&gt; ';
  6439. }
  6440. else
  6441. {
  6442. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  6443. }
  6444. }
  6445. $outread[] = '<br>';
  6446. }
  6447. }
  6448. }
  6449. }
  6450. $klarnacolor = '';
  6451. if($fullorder['klarnadata'] !='')
  6452. {
  6453. $klarnadata = explode('|',$fullorder['klarnadata']);
  6454. if($klarnadata[0] == 'paypal' || $klarnadata[0] == 'stripe')
  6455. {
  6456. $klarnadata[1] = json_decode($klarnadata[1],true);
  6457. if($klarnadata[0] == 'stripe' && $klarnadata[1]['shouldmoney'] != $fullorder['shouldmoney'] && $fullorder['pay'] == 1211)
  6458. {
  6459. $klarnacolor = 'style="color:#F00"';
  6460. }
  6461. }
  6462. else if($klarnadata[0]!=1 && $fullorder['pay']!=26 && $fullorder['pay']!=27 && $fullorder['pay']!=1211)
  6463. {
  6464. $klarnacolor = 'style="color:#F00"';
  6465. }
  6466. if($fullorder['pay'] == 23)//klarna
  6467. {
  6468. $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');
  6469. $ToState = array_flip($ToState);
  6470. $klarnadata3 = str_replace(' ','',$klarnadata[3]);
  6471. $city = str_replace(' ','',$fullorder['city']);
  6472. $klarnadataaddress = explode($city,$klarnadata3);
  6473. if(isset($klarnadataaddress[1]))
  6474. {
  6475. $klarnadata3 = $city.$klarnadataaddress[1];
  6476. $klarnadatacolor = explode(',',$klarnadata3);
  6477. unset($klarnadatacolor[4]);
  6478. unset($klarnadatacolor[6]);
  6479. if(isset($ToState[$klarnadatacolor[1]]))
  6480. {
  6481. $klarnadatacolor[1] = ucwords($ToState[$klarnadatacolor[1]]);
  6482. }
  6483. $klarnadata['color'] = $klarnadataaddress[0].implode(",",$klarnadatacolor);
  6484. }
  6485. else
  6486. {
  6487. $klarnadata['color'] = $klarnadata3;
  6488. }
  6489. }
  6490. }
  6491. else
  6492. {
  6493. $klarnadata = '';
  6494. }
  6495. $p = explode('-',$fullorder['paypal']);
  6496. $this->data['klarnacolor'] = $klarnacolor;
  6497. $this->data['klarnadata'] = $klarnadata;
  6498. $this->data['systemwigsout'] = $outread;
  6499. $this->_Template('fullorder_zw',$this->data);
  6500. }
  6501. public function _dcdxyz()
  6502. {
  6503. $post = $this->input->get(NULL, TRUE);
  6504. if(isset($post['timetk']))
  6505. {
  6506. $timetk = $this->input->get('timetk',true);
  6507. $timetj = $this->input->get('timetj',true);
  6508. $timetk = strtotime($timetk);
  6509. $timetj = strtotime($timetj);
  6510. $where = "oldwaybill != ''";
  6511. if($timetk && $timetj)
  6512. {
  6513. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  6514. }
  6515. //数据排序
  6516. $order_str = "dtime desc";
  6517. //取得信息列表
  6518. $info_list = $this->fullorder->find_all($where,'orderinfo,number,oldwaybill',$order_str);
  6519. $data = array();
  6520. foreach ($info_list as $key=>$value)
  6521. {
  6522. $ob = '';
  6523. $oldwaybill = explode('-',trim($value['oldwaybill'],'-'));
  6524. if(count($oldwaybill) < 2)
  6525. {
  6526. continue;
  6527. }
  6528. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  6529. foreach ($oldwaybill as $v)
  6530. {
  6531. $dw = explode('/',$v);
  6532. if(isset($dw[1]))
  6533. {
  6534. $dwls[$dw[1]] = 1;
  6535. $ob .= $dw[1].'、';
  6536. }
  6537. }
  6538. $info_list[$key]['oldwaybill'] = trim($ob,'、');
  6539. $data[] = $info_list[$key];
  6540. }
  6541. $title = "多运单信息 ".date("Y-m-d");
  6542. $titlename = "<table border=1>
  6543. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  6544. <tr>
  6545. <td>订单号</td>
  6546. <td>编号</td>
  6547. <td>运单号</td>
  6548. </tr>
  6549. </table>";
  6550. $filename = $title.".xls";
  6551. $tail = "\n";
  6552. $this->excel->get_fz2($data,$titlename,$filename,$tail);
  6553. }
  6554. }
  6555. public function _thxz()
  6556. {
  6557. $post = $this->input->get(NULL, TRUE);
  6558. if(isset($post['timetk']))
  6559. {
  6560. $timetk = $this->input->get('timetk',true);
  6561. $timetj = $this->input->get('timetj',true);
  6562. $timetk = strtotime($timetk);
  6563. $timetj = strtotime($timetj);
  6564. $where = "returndata != ''";
  6565. if($timetk && $timetj)
  6566. {
  6567. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  6568. }
  6569. //数据排序
  6570. $order_str = "dtime desc";
  6571. //取得信息列表
  6572. $info_list = $this->fullorder->find_all($where,'orderinfo,number,returndata',$order_str);
  6573. foreach ($info_list as $key=>$value)
  6574. {
  6575. $ydh = explode('">',$value['returndata']);
  6576. $ydh = explode('</a>',$ydh[1]);
  6577. $info_list[$key]['returndata'] = $ydh[0];
  6578. $time = explode('pdf/',$value['returndata']);
  6579. $time = explode('/',$time[1]);
  6580. $info_list[$key]['time'] = $time[0];
  6581. }
  6582. $title = "退货订单信息 ".date("Y-m-d");
  6583. $titlename = "<table border=1>
  6584. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  6585. <tr>
  6586. <td>订单号</td>
  6587. <td>编号</td>
  6588. <td>退货运单号</td>
  6589. <td>退货时间</td>
  6590. </tr>
  6591. </table>";
  6592. $filename = $title.".xls";
  6593. $tail = "\n";
  6594. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  6595. }
  6596. }
  6597. public function _ddcf()
  6598. {
  6599. $post = $this->input->post(NULL, TRUE);
  6600. if(isset($post['number']))
  6601. {
  6602. $number = $this->input->post('number',true);
  6603. $data = $this->fullorder->get_number($number);
  6604. if(!$data)
  6605. {
  6606. echo json_encode(array('msg'=>'没有找到此订单','success'=>false));exit;
  6607. }
  6608. if($data['review'] != 1 && $data['review'] != 2)
  6609. {
  6610. echo json_encode(array('msg'=>'必须是 待审核 状态才能拆分','success'=>false));exit;
  6611. }
  6612. if($data['merge'] != 0)
  6613. {
  6614. echo json_encode(array('msg'=>'已合并的订单无法使用此拆分功能','success'=>false));exit;
  6615. }
  6616. $cfnum = explode('-',trim($number,'-'));
  6617. // if((count($cfnum) > 3 && stripos($number,'-PF-') === false))
  6618. // {
  6619. // echo json_encode(array('msg'=>'只能在原单操作拆分','success'=>false));exit;
  6620. // }
  6621. if(count($cfnum) > 4 && stripos($number,'-PF-') !== false)
  6622. {
  6623. echo json_encode(array('msg'=>'只能在原单操作拆分','success'=>false));exit;
  6624. }
  6625. $num = $this->fullorder->find_count("number like '".$number."%'");
  6626. $data['number'] = $data['number'].'-'.$num;
  6627. $data['orderinfo'] = $data['shop'].date('ymdHis',time()).rand(0,1);;
  6628. $data['shouldmoney'] = 0;
  6629. $data['budget'] = 0;
  6630. $data['shipremarks'] = '';
  6631. $data['source'] = 1;
  6632. //$data['review'] = 2;
  6633. $data['extra_status'] = 1;//拆分的订单
  6634. unset($data['id']);
  6635. unset($data['jweight']);
  6636. unset($data['fpcount']);
  6637. unset($data['returndata']);
  6638. unset($data['waybill']);
  6639. unset($data['oldwaybill']);
  6640. unset($data['printtime']);
  6641. if($this->fullorder->insert($data))
  6642. {
  6643. echo json_encode(array('msg'=>'拆分成功!新订单编号:'.$data['number'],'success'=>true));exit;
  6644. }
  6645. else
  6646. {
  6647. echo json_encode(array('msg'=>'拆分失败,请重试','success'=>false));exit;
  6648. }
  6649. }
  6650. }
  6651. public function _cf() //合并订单拆分
  6652. {
  6653. $post = $this->input->post(NULL, TRUE);
  6654. if(isset($post['id']))
  6655. {
  6656. $id = $this->input->post('id',true);
  6657. $b = $this->fullorder->read($id);
  6658. $order = array();
  6659. if($b['merge'] == $b['id'])
  6660. {
  6661. $data = $this->fullorder->find_all("merge = '".$b['merge']."'");
  6662. foreach ($data as $v)
  6663. {
  6664. $a = $this->fullorderhb->get_orderinfo($v['orderinfo']);
  6665. if($a)
  6666. {
  6667. $this->fullorder->save($a,$v['id']);
  6668. }
  6669. $order[] = $v['id'];
  6670. }
  6671. echo json_encode(array('msg'=>'拆分成功!','d'=>$order,'success'=>true));exit;
  6672. }
  6673. else
  6674. {
  6675. echo json_encode(array('msg'=>'拆分条件错误!','success'=>false));exit;
  6676. }
  6677. }
  6678. }
  6679. }