Fullorder.php 233 KB

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