Fullorder.php 236 KB

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