Fullorder.php 233 KB

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