Fullorder.php 239 KB

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