Fullorder.php 234 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672
  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') or (send_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. $tmp_list = $this->db->from('fullorder')->where_in('id',$id_arr)->select('id,orderinfo,number,type,express')->get()->result_array();
  3111. $count_warehouse_list = [];
  3112. $count_express_list = [];
  3113. $flag = 0;
  3114. $flag_str = '';
  3115. foreach ($tmp_list as $k => $v) {
  3116. $count_warehouse_list[$v['type']] = $v['type'];
  3117. if(empty($v['express'])){
  3118. $flag = 1;
  3119. $flag_str.= $v['number'].'仓库未选,请先选快递;';
  3120. }
  3121. $count_express_list[$v['express']] = $v['express'];
  3122. }
  3123. if($flag == 1){
  3124. echo json_encode(array('msg'=>$flag_str,'success'=>false));exit;
  3125. }
  3126. if(count($count_warehouse_list) > 1){
  3127. echo json_encode(array('msg'=>'合并单的仓库不一致,无法合并!','success'=>false));exit;
  3128. }
  3129. if(count($count_express_list) > 1){
  3130. echo json_encode(array('msg'=>'合并单的快递不一致,无法合并!','success'=>false));exit;
  3131. }
  3132. $post = array();
  3133. $u = $this->fullorder->read($id_arr[0]);
  3134. unset($id_arr[0]);
  3135. $this->db->trans_begin();
  3136. $hd = $this->fullorderhb->get_orderinfo($u['orderinfo']);
  3137. if(!$hd)
  3138. {
  3139. $this->fullorderhb->insert($u);
  3140. }
  3141. //相加
  3142. $post['shouldmoney'] = $u['shouldmoney'];//购买应收金额
  3143. $post['budget'] = $u['budget'];//预估到帐金额
  3144. $post['expressmoney']= $u['expressmoney'];//物流金额
  3145. //$post['refundy'] = $u['refundy'];//补/退原额
  3146. //$post['refundj'] = $u['refundj'];//补/退净额
  3147. $post['cost'] = $u['cost'];//成本金额
  3148. //$post['zzl'] = $u['zzl'];//总重量
  3149. //$post['zsbjz'] = $u['zsbjz'];//总申报价值
  3150. $post['ts'] = $u['ts'];//条数
  3151. $post['cost'] = $u['cost'];//成本金额
  3152. //追加
  3153. $post['rpaypal'] = $u['rpaypal'];//补/退交易号
  3154. $post['rtext'] = $u['rtext'];//补/退原因
  3155. $post['pay'] = $u['pay'];//付款方式
  3156. $post['paypal'] = $u['paypal'];//交易号
  3157. $post['clientremarks'] = $u['clientremarks'];//客户留言
  3158. $post['product'] = $u['product'];//商品名称
  3159. //$post['issku'] = $u['issku'];//sku
  3160. //$post['orderremarks'] = $u['orderremarks'];//订单备注
  3161. $post['shipremarks'] = $u['shipremarks'];//仓库品名
  3162. //产品追加
  3163. $post['fpdata'] = $u['fpdata'];//产品内容
  3164. $post['whlabel'] = $u['whlabel'];//产品对应库存码
  3165. $merge = $u['id'];
  3166. $d = array($u['id']);$order = '';
  3167. $zsl = 0;$zccsl = 0;
  3168. foreach ($id_arr as $v)
  3169. {
  3170. $v = $this->fullorder->read($v);
  3171. if($u['type'] != $v['type'])
  3172. {
  3173. echo json_encode(array('msg'=>'仓库不一致,无法合并!','success'=>false));exit;
  3174. }
  3175. if($v['shop'] = $u['shop'])
  3176. {
  3177. $hd = $this->fullorderhb->get_orderinfo($v['orderinfo']);
  3178. if(!$hd)
  3179. {
  3180. $this->fullorderhb->insert($v);
  3181. }
  3182. //$post['shouldmoney'] += $v['shouldmoney'];//购买应收金额
  3183. // $post['budget'] += $v['budget'];//预估到帐金额
  3184. // $post['expressmoney'] += $v['expressmoney'];//物流金额
  3185. //$post['refundy'] += $v['refundy'];//补/退原额
  3186. //$post['refundj'] += $v['refundj'];//补/退净额
  3187. $post['cost'] += $v['cost'];//成本金额
  3188. //$post['zzl'] += $v['zzl'];//总重量
  3189. //$post['zsbjz'] += $v['zsbjz'];//总申报价值
  3190. $post['ts'] += $v['ts'];//条数
  3191. //$post['rpaypal'] .= $v['rpaypal'];//补/退交易号
  3192. //$post['rtext'] .= $v['rtext'];//补/退原因
  3193. //$post['pay'] .= (stripos($post['pay'],$v['pay']) !== false)?'':';'.$v['pay'];//付款方式
  3194. //$post['paypal'] .= $v['paypal'];//交易号
  3195. $post['clientremarks'] .= $v['clientremarks'];//客户留言
  3196. $post['product'] .= $v['product'];//商品名称
  3197. //$post['issku'] .= $v['issku'];//sku
  3198. //$post['orderremarks'] .= $v['orderremarks'];//订单备注
  3199. $post['shipremarks'] .= $v['shipremarks'];//仓库品名
  3200. $post['fpdata'] .= $v['fpdata'];//产品内容
  3201. $post['whlabel'] .= ltrim($v['whlabel'],'|');//产品对应库存码
  3202. $d[] = $v['id'];
  3203. $order .= $v['orderinfo'].'('.$v['number'].')、';
  3204. $wl = $this->whlabel->find_all("zd = '".$v['number']."'");//查找是否有占用库存情况
  3205. $i = 0;
  3206. if($wl)//如果有那么清除所有占用
  3207. {
  3208. foreach ($wl as $val)
  3209. {
  3210. if($val['sku'] == 'Preset' && $val['state'] == '9')
  3211. {
  3212. $this->whlabel->remove($val['id']);//删除预设
  3213. $i++;
  3214. }
  3215. else
  3216. {
  3217. $this->whlabel->save(array('zd'=>''),$val['id']);//专属
  3218. $i++;
  3219. }
  3220. }
  3221. }
  3222. $zsl += count($wl);
  3223. $zccsl += $i;
  3224. $this->fullorder->save(array('merge'=>$u['id'],'mergeid'=>1,'orderremarks'=>' 《合并信息》:'.'已合并到'.$u['orderinfo'].'('.$u['number'].')中; '.$v['orderremarks'],'print'=>1,'libraryconfirm'=>1,'whlabel'=>'','fpdata'=>'','shipremarks'=>''),$v['id']);
  3225. }
  3226. }
  3227. //计算出单条价值
  3228. /**
  3229. if($post['zsbjz'] < 1 || $post['ts'] < 1)
  3230. {
  3231. //$post['dtsbjz'] = 0;
  3232. }
  3233. else
  3234. {
  3235. //$post['dtsbjz'] = $post['zsbjz']/$post['ts'];//单条申报价
  3236. }
  3237. **/
  3238. $post['orderremarks'] = ' 《合并信息》:由'.rtrim($order,'、').'合并而来; '.$u['orderremarks'];;
  3239. $post['merge'] = $u['id'];
  3240. //$post['mergeid'] = 1;
  3241. //合并重复项
  3242. $hbcfw = explode('|',trim($post['whlabel'],'|'));
  3243. $hbcff = explode(';',trim($post['fpdata'],';'));
  3244. $c = 0;
  3245. $hbw = array();
  3246. $hbf = array();
  3247. for($i=0;$i<count($hbcfw);$i++)
  3248. {
  3249. $w = explode('-',$hbcfw[$i]);
  3250. $f = explode('|',$hbcff[$i]);
  3251. if(isset($w[2]))
  3252. {
  3253. $w2 = ($w[2]==0)?0:'';
  3254. }
  3255. else
  3256. {
  3257. $w2 = '';
  3258. }
  3259. if(!isset($hbw[$w[0].$w2]))
  3260. {
  3261. $hbw[$w[0].$w2] = $hbcfw[$i];
  3262. $hbf[$w[0].$w2] = $hbcff[$i];
  3263. }
  3264. else
  3265. {
  3266. $c++;
  3267. $cw = explode('-',$hbw[$w[0].$w2]);
  3268. $cf = explode('|',$hbf[$w[0].$w2]);
  3269. if($cw[2] != 0 && $w[2] != 0)
  3270. {
  3271. $cf[2] += $f[2];
  3272. $cf[9] .= '~'.$f[9];
  3273. $hbf[$w[0].$w2] = implode("|",$cf);
  3274. $cw[1] += $f[2];
  3275. $cw[2] .= '~'.$f[9];
  3276. $hbw[$w[0].$w2] = implode("-",$cw);
  3277. }
  3278. else if($cw[2] == 0 && $w[2] == 0)
  3279. {
  3280. $cf[2] += $f[2];
  3281. $hbf[$w[0].$w2] = implode("|",$cf);
  3282. $cw[1] += $f[2];
  3283. $hbw[$w[0].$w2] = implode("-",$cw);
  3284. }
  3285. else
  3286. {
  3287. $hbw[] = $hbcfw[$i];
  3288. $hbf[] = $hbcff[$i];
  3289. }
  3290. }
  3291. }
  3292. if($c > 0)
  3293. {
  3294. $post['fpdata'] = implode(";",$hbf).';';
  3295. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  3296. }
  3297. //合并重复项结束
  3298. $this->fullorder->save($post,$u['id']);
  3299. if ($this->db->trans_status() === FALSE)
  3300. {
  3301. $this->db->trans_commit();
  3302. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3303. }
  3304. else
  3305. {
  3306. $this->db->trans_commit();
  3307. echo json_encode(array('msg'=>'操作成功','d'=>($d),'b'=>$u['id'],'success'=>true));
  3308. }
  3309. }
  3310. /**
  3311. $post = $this->input->post(NULL, TRUE);
  3312. if(isset($post['type']))
  3313. {
  3314. $type = $this->input->post('type');
  3315. $id = $this->input->post('id');
  3316. $u = $this->fullorder->read($id);
  3317. $rows = $this->fullorder->find_all('name = "'.$u['name'].'" or email = "'.$u['email'].'" or address = "'.$u['address'].'"','*','id desc');
  3318. if(count($rows)>1)
  3319. {
  3320. $this->db->trans_begin();
  3321. $fpdata=$rows[0]['fpdata'];//购买产品
  3322. $shouldmoney=$rows[0]['shouldmoney'];//购买应收金额
  3323. $budget=$rows[0]['budget'];//预估到帐金额
  3324. $cost=$rows[0]['cost'];//成本金额
  3325. $merge=$rows[0]['id'];
  3326. $d = array($rows[0]['id']);
  3327. for($i=1;$i<count($rows);$i++)
  3328. {
  3329. $fpdata=$fpdata.$rows[$i]['fpdata'];
  3330. $shouldmoney=$shouldmoney+$rows[$i]['shouldmoney'];
  3331. $budget=$budget+$rows[$i]['budget'];
  3332. $cost=$cost+$rows[$i]['cost'];
  3333. $d[] = $rows[$i]['id'];
  3334. $this->fullorder->save(array('merge'=>$rows[0]['id'],'mergeid'=>1),$rows[$i]['id']);
  3335. }
  3336. $this->fullorder->save(array('fpdata'=>$fpdata,'shouldmoney'=>$shouldmoney,'budget'=>$budget,'cost'=>$cost,'merge'=>$merge),$rows[0]['id']);
  3337. if ($this->db->trans_status() === FALSE)
  3338. {
  3339. $this->db->trans_commit();
  3340. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3341. }
  3342. else
  3343. {
  3344. $this->db->trans_commit();
  3345. echo json_encode(array('msg'=>'操作成功','d'=>($d),'b'=>$rows[0]['id'],'success'=>true));
  3346. }
  3347. }
  3348. }
  3349. **/
  3350. }
  3351. //评价管理
  3352. public function _evaluate()
  3353. {
  3354. $user = $this->user->get_api($_SESSION['api']);
  3355. if($user)
  3356. {
  3357. $fgshop = "";$sid = "";
  3358. $user = explode('|',trim($user['shop'],'|'));
  3359. foreach ($user as $value)
  3360. {
  3361. $fgshop .= " shop = ".$value." or";
  3362. $sid .= " id = ".$value." or";
  3363. }
  3364. }
  3365. $post = $this->input->post(NULL, TRUE);
  3366. if(isset($post['page']))
  3367. {
  3368. $page = $this->input->post('page',true);
  3369. $perpage = $this->input->post('perpage',true);
  3370. $shop = $this->input->post('shop',true);
  3371. $where = "1=1 and evaluate = 0 and (".rtrim($fgshop,'or').")";
  3372. if($shop)
  3373. {
  3374. $where .= " and shop = '$shop'";
  3375. }
  3376. //数据排序
  3377. $order_str = "id desc";
  3378. if(empty($page))
  3379. {
  3380. $start = 0;
  3381. $perpage = 1;
  3382. }
  3383. else
  3384. {
  3385. $start = ($page - 1)*$perpage;
  3386. }
  3387. //取得信息列表
  3388. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,operation',$order_str,$start,$perpage);
  3389. //格式化数据
  3390. foreach ($info_list as $key=>$value)
  3391. {
  3392. $shop = $this->shop->read($value['shop']);
  3393. $info_list[$key]['shop'] = $shop['shopname'];
  3394. $info_list[$key]['operation'] = "评价";
  3395. }
  3396. $total = $this->fullorder->find_count($where);
  3397. $pagenum = ceil($total/$perpage);
  3398. $over = $total-($start+$perpage);
  3399. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3400. echo json_encode($rows);exit;
  3401. }
  3402. $this->_Template('fullorder_evaluate',$this->data);
  3403. }
  3404. //订单消息
  3405. public function _state()
  3406. {
  3407. $user = $this->user->get_api($_SESSION['api']);
  3408. if($user)
  3409. {
  3410. $fgshop = "";$sid = "";
  3411. $user = explode('|',trim($user['shop'],'|'));
  3412. foreach ($user as $value)
  3413. {
  3414. $fgshop .= " shop = ".$value." or";
  3415. $sid .= " id = ".$value." or";
  3416. }
  3417. }
  3418. $post = $this->input->post(NULL, TRUE);
  3419. if(isset($post['page']))
  3420. {
  3421. $page = $this->input->post('page',true);
  3422. $perpage = $this->input->post('perpage',true);
  3423. $timetk = $this->input->post('timetk',true);
  3424. $timetj = $this->input->post('timetj',true);
  3425. $shop = $this->input->post('shop',true);
  3426. $expressstate = $this->input->post('expressstate',true);
  3427. $fs = $this->input->post('fs',true);
  3428. $state = $this->input->post('state',true);
  3429. $express = $this->input->post('express',true);
  3430. $review = $this->input->post('review',true);
  3431. $orderinfo = $this->input->post('orderinfo',true);
  3432. $number = $this->input->post('number',true);
  3433. $waybill = $this->input->post('waybill',true);
  3434. $xztime = $this->input->post('xztime',true);
  3435. $timetk = strtotime($timetk);
  3436. $timetj = strtotime($timetj);
  3437. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3438. if($timetk && $timetj)
  3439. {
  3440. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3441. }
  3442. if($xztime == 'librarytime')
  3443. {
  3444. $order_str = "librarytime desc";
  3445. }
  3446. else if($xztime == 'dtime')
  3447. {
  3448. $order_str = "dtime desc";
  3449. }
  3450. if($shop)
  3451. {
  3452. $where .= " and shop = '$shop'";
  3453. }
  3454. if($expressstate)
  3455. {
  3456. $where .= " and expressstate = '$expressstate'";
  3457. }
  3458. if($review)
  3459. {
  3460. $where .= " and review = '$review'";
  3461. }
  3462. if($fs)
  3463. {
  3464. if($fs == '2')
  3465. {
  3466. $where .= " and exstateerror != ''";
  3467. }
  3468. else
  3469. {
  3470. $where .= " and exstateerror = ''";
  3471. }
  3472. }
  3473. if($state)
  3474. {
  3475. $where .= " and state = '$state'";
  3476. }
  3477. if($express)
  3478. {
  3479. $where .= " and express = '$express'";
  3480. }
  3481. if($orderinfo)
  3482. {
  3483. $where .= " and orderinfo = '$orderinfo'";
  3484. }
  3485. if($number)
  3486. {
  3487. $where .= " and number = '$number'";
  3488. }
  3489. if($waybill)
  3490. {
  3491. $where .= " and waybill = '$waybill'";
  3492. }
  3493. if(empty($page))
  3494. {
  3495. $start = 0;
  3496. $perpage = 1;
  3497. }
  3498. else
  3499. {
  3500. $start = ($page - 1)*$perpage;
  3501. }
  3502. //取得信息列表
  3503. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,country,library,librarytime,express,waybill,content,orderremarks,exstateerror',$order_str,$start,$perpage);
  3504. //格式化数据
  3505. foreach ($info_list as $key=>$value)
  3506. {
  3507. $shop = $this->shop->read($value['shop']);
  3508. $info_list[$key]['shop'] = $shop['shopname'];
  3509. $country = $this->country->read($value['country']);
  3510. $info_list[$key]['country'] = $country['name'];
  3511. //$state = $this->typeclass->read($value['state']);
  3512. //$info_list[$key]['state'] = $state['title'];
  3513. if($value['library'] == 1)
  3514. {
  3515. $info_list[$key]['library'] = "未出库";
  3516. }
  3517. else if($value['library'] == 2)
  3518. {
  3519. $info_list[$key]['library'] = "已出库";
  3520. }
  3521. else if($value['library'] == 3)
  3522. {
  3523. $info_list[$key]['library'] = "已退库";
  3524. }
  3525. if($value['librarytime'] == '0')
  3526. {
  3527. $info_list[$key]['librarytime'] = '无';
  3528. }
  3529. else
  3530. {
  3531. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']);
  3532. }
  3533. $express = $this->express->read($value['express']);
  3534. $info_list[$key]['express'] = $express['servicename'];
  3535. }
  3536. $total = $this->fullorder->find_count($where);
  3537. $pagenum = ceil($total/$perpage);
  3538. $over = $total-($start+$perpage);
  3539. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3540. echo json_encode($rows);exit;
  3541. }
  3542. $notice = $this->notice->find_all("type = '1' and (".rtrim($fgshop,'or').")");
  3543. $this->data['notice'] = $notice;
  3544. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3545. $this->data['wlshop'] = $wlshop;
  3546. $this->data['express'] = $this->express->find_all();
  3547. $this->_Template('fullorder_state',$this->data);
  3548. }
  3549. //物流信息
  3550. public function _wl()
  3551. {
  3552. $user = $this->user->get_api($_SESSION['api']);
  3553. if($user)
  3554. {
  3555. $fgshop = "";$sid = "";
  3556. $user = explode('|',trim($user['shop'],'|'));
  3557. foreach ($user as $value)
  3558. {
  3559. $fgshop .= " shop = ".$value." or";
  3560. $sid .= " id = ".$value." or";
  3561. }
  3562. }
  3563. $post = $this->input->post(NULL, TRUE);
  3564. if(isset($post['page']))
  3565. {
  3566. $page = $this->input->post('page',true);
  3567. $perpage = $this->input->post('perpage',true);
  3568. $timetk = $this->input->post('timetk',true);
  3569. $timetj = $this->input->post('timetj',true);
  3570. $shop = $this->input->post('shop',true);
  3571. $expressstate = $this->input->post('expressstate',true);
  3572. $fs = $this->input->post('fs',true);
  3573. $state = $this->input->post('state',true);
  3574. $express = $this->input->post('express',true);
  3575. $orderinfo = $this->input->post('orderinfo',true);
  3576. $number = $this->input->post('number',true);
  3577. $waybill = $this->input->post('waybill',true);
  3578. $wlyc = $this->input->post('wlyc',true);
  3579. $wltype = $this->input->post('wltype',true);
  3580. $source = $this->input->post('source',true);
  3581. $xztime = $this->input->post('xztime',true);
  3582. $wlbz = $this->input->post('wlbz',true);
  3583. $timetk = strtotime($timetk);
  3584. $timetj = strtotime($timetj);
  3585. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3586. if($timetk && $timetj)
  3587. {
  3588. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3589. }
  3590. if($xztime == 'librarytime')
  3591. {
  3592. $order_str = "librarytime desc";
  3593. }
  3594. else if($xztime == 'dtime')
  3595. {
  3596. $order_str = "dtime desc";
  3597. }
  3598. else if ($xztime == 'wlfstime')
  3599. {
  3600. $order_str = "wlfstime desc";
  3601. }
  3602. if($shop)
  3603. {
  3604. $where .= " and shop = '$shop'";
  3605. }
  3606. if($fs)
  3607. {
  3608. if($fs == '1')
  3609. {
  3610. $where .= " and wlcontent != ''";
  3611. }
  3612. if($fs == '2')
  3613. {
  3614. $where .= " and wlerror != ''";
  3615. }
  3616. if($fs == '3')
  3617. {
  3618. $where .= " and wlcontent = '' and shouldmoney > 100";
  3619. }
  3620. else if($fs == '4')
  3621. {
  3622. $where .= " and wltype = '1'";
  3623. }
  3624. }
  3625. if($state)
  3626. {
  3627. $where .= " and state = '$state'";
  3628. }
  3629. if($express)
  3630. {
  3631. $where .= " and express = '$express'";
  3632. }
  3633. if($orderinfo)
  3634. {
  3635. $where .= " and orderinfo = '$orderinfo'";
  3636. }
  3637. if($number)
  3638. {
  3639. $where .= " and number = '$number'";
  3640. }
  3641. if($waybill)
  3642. {
  3643. $where .= " and waybill = '$waybill'";
  3644. }
  3645. if($wlbz)
  3646. {
  3647. $where .= " and wlbz like '%$wlbz%'";
  3648. }
  3649. if($wlyc!='')
  3650. {
  3651. $where .= " and wlyc = '$wlyc'";
  3652. }
  3653. if($wltype!='')
  3654. {
  3655. $where .= " and wltype = '$wltype'";
  3656. }
  3657. if($source)
  3658. {
  3659. if($source == 1)
  3660. {
  3661. $where .= " and source = '$source'";
  3662. }
  3663. else
  3664. {
  3665. $where .= " and source != '1'";
  3666. }
  3667. }
  3668. if($expressstate != '')
  3669. {
  3670. if($expressstate == 99)
  3671. {
  3672. $cxid = '';
  3673. $sjcc = $this->awlgx->find_all("time < '".(time()-3*24*3600)."' and exstate != 6",'number');
  3674. foreach ($sjcc as $v)
  3675. {
  3676. $cxid .= "number = '".$v['number']."' or ";
  3677. }
  3678. $where .= ' and ('.rtrim($cxid,'or ').')';
  3679. }
  3680. else
  3681. {
  3682. $where .= " and expressstate = '$expressstate'";
  3683. }
  3684. }
  3685. if(empty($page))
  3686. {
  3687. $start = 0;
  3688. $perpage = 1;
  3689. }
  3690. else
  3691. {
  3692. $start = ($page - 1)*$perpage;
  3693. }
  3694. //取得信息列表
  3695. $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);
  3696. //格式化数据
  3697. foreach ($info_list as $key=>$value)
  3698. {
  3699. $f = $this->fullorder->read($value['id']);
  3700. $info_list[$key]['number'] = "<p>".$value['number']."</p>"."<p>".$f['email']."</p>";
  3701. $country = $this->country->read($value['country']);
  3702. $info_list[$key]['country'] = "<p>".$country['name']."</p><p>".$f['phone']."</p>";
  3703. //$state = $this->typeclass->read($value['state']);
  3704. //$info_list[$key]['state'] = $state['title'];
  3705. if($value['library'] == 1)
  3706. {
  3707. $info_list[$key]['library'] = "未出库";
  3708. }
  3709. else if($value['library'] == 2)
  3710. {
  3711. $info_list[$key]['library'] = "已出库";
  3712. }
  3713. else if($value['library'] == 3)
  3714. {
  3715. $info_list[$key]['library'] = "已退库";
  3716. }
  3717. if($value['librarytime'] == '0')
  3718. {
  3719. $info_list[$key]['librarytime'] = '无';
  3720. }
  3721. else
  3722. {
  3723. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']).'<br>'.$f['shouldmoney'];
  3724. }
  3725. if($value['expressstate'] == 0)
  3726. {
  3727. $info_list[$key]['expressstate'] = "无信息";
  3728. }
  3729. else if($value['expressstate'] == 2)
  3730. {
  3731. $info_list[$key]['expressstate'] = "已取件";
  3732. }
  3733. else if($value['expressstate'] == 3)
  3734. {
  3735. $info_list[$key]['expressstate'] = "在途中";
  3736. }
  3737. /**
  3738. else if($value['expressstate'] == 4)
  3739. {
  3740. $info_list[$key]['expressstate'] = "到达目的地国".$value['expressstate'];
  3741. }
  3742. **/
  3743. else if($value['expressstate'] == 4 || $value['expressstate'] == 5)
  3744. {
  3745. $info_list[$key]['expressstate'] = "即将派送";
  3746. }
  3747. else if($value['expressstate'] == 6)
  3748. {
  3749. $info_list[$key]['expressstate'] = "已签收";
  3750. }
  3751. else if($value['expressstate'] == 1)
  3752. {
  3753. $info_list[$key]['expressstate'] = "派送异常";
  3754. }
  3755. $express = $this->express->read($value['express']);
  3756. $info_list[$key]['express'] = $express['servicename'];
  3757. if($value['wltype'] == '0')
  3758. {
  3759. $info_list[$key]['wltype'] = "<p class='ckn'><b class='wlfsxx' data-id='".$value['id']."' data-q='1'>禁止发送</b></p>";
  3760. }
  3761. else
  3762. {
  3763. $info_list[$key]['wltype'] = "<p class='ckn'><b class='wlfsxx' data-id='".$value['id']."' data-q='1'>允许发送</b></p>";
  3764. }
  3765. if($f['wlyc'] == '0')
  3766. {
  3767. $info_list[$key]['wltype'] .= "<p class='yc'><b class='wlyc' data-id='".$value['id']."' data-t='1'>加入异常处理中</b></p>";
  3768. }
  3769. else if($f['wlyc'] == '1')
  3770. {
  3771. $info_list[$key]['wltype'] .= "<p class='yc'><b class='wlyc' data-id='".$value['id']."' data-t='2'>移入异常已处理</b></p>";
  3772. $info_list[$key]['wltype'] .= "<p class='yc'><b class='ycyc' data-id='".$value['id']."' data-c='2'>移出异常处理中</b></p>";
  3773. }
  3774. else if($f['wlyc'] == '2')
  3775. {
  3776. $info_list[$key]['wltype'] .= "<p><b>异常已处理</b></p>";
  3777. }
  3778. if(stripos($value['excontent'],'<br />') !== false)
  3779. {
  3780. $excontent = explode('<br />',$value['excontent']);
  3781. $info_list[$key]['excontent'] = '<i class="method fa fa-list-ul" data-t="'.$value['excontent'].'"></i> '.$excontent[0];
  3782. }
  3783. }
  3784. $total = $this->fullorder->find_count($where);
  3785. $pagenum = ceil($total/$perpage);
  3786. $over = $total-($start+$perpage);
  3787. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$where);
  3788. echo json_encode($rows);exit;
  3789. }
  3790. if(isset($post['q']))
  3791. {
  3792. $id = $this->input->post('id',true);
  3793. $f = $this->fullorder->read($id);
  3794. $wl = ($f['wltype']=='0')?1:0;
  3795. $wltitle = ($f['wltype']=='0')?'已禁发送':'已允发送';
  3796. if($this->fullorder->save(array('wltype'=>$wl),$id))
  3797. {
  3798. echo json_encode(array('msg'=>'ckn','id'=>$id,'wltitle'=>$wltitle,'success'=>true));exit;
  3799. }
  3800. else
  3801. {
  3802. echo json_encode(array('msg'=>'失败,请重试','id'=>$id,'wltitle'=>$wltitle,'success'=>false));exit;
  3803. }
  3804. }
  3805. if(isset($post['t']))
  3806. {
  3807. $id = $this->input->post('id',true);
  3808. $f = $this->fullorder->read($id);
  3809. $t = $this->input->post('t',true);
  3810. $yc = ($f['wlyc']=='0')?1:2;
  3811. $yctitle = ($f['wlyc']=='0')?'移入成功':'异常已处理';
  3812. if($this->fullorder->save(array('wlyc'=>$yc),$id))
  3813. {
  3814. echo json_encode(array('msg'=>'yc','id'=>$id,'wltitle'=>$yctitle,'success'=>true));exit;
  3815. }
  3816. else
  3817. {
  3818. echo json_encode(array('msg'=>'失败,请重试','id'=>$id,'wltitle'=>$yctitle,'success'=>false));exit;
  3819. }
  3820. }
  3821. if(isset($post['c']))
  3822. {
  3823. $id = $this->input->post('id',true);
  3824. $f = $this->fullorder->read($id);
  3825. $t = $this->input->post('t',true);
  3826. $yc = 0;
  3827. $yctitle = '移出成功';
  3828. if($this->fullorder->save(array('wlyc'=>$yc),$id))
  3829. {
  3830. echo json_encode(array('msg'=>'yc','id'=>$id,'wltitle'=>$yctitle,'success'=>true));exit;
  3831. }
  3832. else
  3833. {
  3834. echo json_encode(array('msg'=>'失败,请重试','id'=>$id,'wltitle'=>$yctitle,'success'=>false));exit;
  3835. }
  3836. }
  3837. $notice = $this->notice->find_all("type = '2' and (".rtrim($fgshop,'or').")");
  3838. $this->data['notice'] = $notice;
  3839. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3840. $this->data['wlshop'] = $wlshop;
  3841. $this->data['express'] = $this->express->find_all();
  3842. $this->_Template('fullorder_wl',$this->data);
  3843. }
  3844. //审核订单
  3845. public function _review()
  3846. {
  3847. $user = $this->user->get_api($_SESSION['api']);
  3848. if($user)
  3849. {
  3850. $fgshop = "";$sid = "";
  3851. $user = explode('|',trim($user['shop'],'|'));
  3852. foreach ($user as $value)
  3853. {
  3854. $sid .= " id = ".$value." or";
  3855. $fgshop .= " shop = ".$value." or";
  3856. }
  3857. $fgshop = " and (".rtrim($fgshop,'or').")";
  3858. }
  3859. $post = $this->input->post(NULL, TRUE);
  3860. if(isset($post['page']))
  3861. {
  3862. $page = $this->input->post('page',true);
  3863. $perpage = $this->input->post('perpage',true);
  3864. $source = $this->input->post('source',true);
  3865. $warehouse = $this->input->post('warehouse',true);
  3866. $express = $this->input->post('express',true);
  3867. $orderremarks = $this->input->post('orderremarks',true);
  3868. $shop = $this->input->post('shop',true);
  3869. $review = $this->input->post('review',true);
  3870. $orderinfo = $this->input->post('orderinfo',true);
  3871. $shipremarks = $this->input->post('shipremarks',true);
  3872. $number = $this->input->post('number',true);
  3873. $timetk = $this->input->post('timetk',true);
  3874. $timetj = $this->input->post('timetj',true);
  3875. $timetk = strtotime($timetk);
  3876. $timetj = strtotime($timetj);
  3877. $where = "mergeid = 0 and state = '207'".$fgshop;
  3878. if($timetk && $timetj)
  3879. {
  3880. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3881. }
  3882. if($source)
  3883. {
  3884. if($source == '2d')
  3885. {
  3886. $where .= " and source >= '2'";
  3887. }
  3888. else
  3889. {
  3890. $where .= " and source = '$source'";
  3891. }
  3892. }
  3893. if($review)
  3894. {
  3895. $where .= " and review = '$review'";
  3896. }
  3897. else
  3898. {
  3899. $where .= " and ((review = '2' and source = '1') or (review = '1' and source >= '2'))";
  3900. }
  3901. if($shop)
  3902. {
  3903. $where .= " and shop = '$shop'";
  3904. }
  3905. if($warehouse)
  3906. {
  3907. $where .= " and type = '$warehouse'";
  3908. }
  3909. if($express)
  3910. {
  3911. $where .= " and express = '$express'";
  3912. }
  3913. if($orderremarks)
  3914. {
  3915. $where .= " and orderremarks like '%$orderremarks%'";
  3916. }
  3917. if($orderinfo)
  3918. {
  3919. $where .= " and orderinfo = '$orderinfo'";
  3920. }
  3921. if($number)
  3922. {
  3923. $where .= " and number = '$number'";
  3924. }
  3925. if($shipremarks)
  3926. {
  3927. $where .= " and shipremarks like '%$shipremarks%'";
  3928. }
  3929. //数据排序
  3930. $order_str = "id desc";
  3931. if(empty($page))
  3932. {
  3933. $start = 0;
  3934. $perpage = 1;
  3935. }
  3936. else
  3937. {
  3938. $start = ($page - 1)*$perpage;
  3939. }
  3940. //取得信息列表
  3941. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,client,express,buytime,shouldmoney,review,orderremarks');
  3942. //格式化数据
  3943. foreach ($info_list as $key=>$value)
  3944. {
  3945. $lr = $this->fullorder->read($value['id']);
  3946. $shop = $this->shop->read($value['shop']);
  3947. $info_list[$key]['shop'] = $shop['shopname'];
  3948. $warehouse = $this->warehouse->read($value['type']);
  3949. $info_list[$key]['type'] = $warehouse['title'];
  3950. $express = $this->express->read($value['express']);
  3951. $info_list[$key]['express'] = $express['servicename'];
  3952. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  3953. if($value['review'] == 1)
  3954. {
  3955. $info_list[$key]['review'] = "未送审";
  3956. }
  3957. else if($value['review'] == 2)
  3958. {
  3959. $info_list[$key]['review'] = "待审核";
  3960. }
  3961. else if($value['review'] == 3)
  3962. {
  3963. $info_list[$key]['review'] = "不通过";
  3964. }
  3965. else if($value['review'] == 4)
  3966. {
  3967. $info_list[$key]['review'] = "取消重审";
  3968. }
  3969. else if($value['review'] == 5)
  3970. {
  3971. $info_list[$key]['review'] = "审核通过";
  3972. }
  3973. else if($value['review'] == 6)
  3974. {
  3975. $info_list[$key]['review'] = "自动通过";
  3976. }
  3977. /**
  3978. $info_list[$key]['library'] = "";
  3979. if($value['review'] == 1)
  3980. {
  3981. $info_list[$key]['library'] = "<p><b class='focz' data-type='6' data-id='".$value['id']."'>审核通过</b></p>";
  3982. }
  3983. if($value['review'] == 2)
  3984. {
  3985. $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>";
  3986. }
  3987. else if($value['review'] == 3)
  3988. {
  3989. $info_list[$key]['library'] = "<p><b class='fullorderreview' data-type='5' data-id='".$value['id']."'>审核通过</b></p>";
  3990. }
  3991. else if($value['review'] == 5)
  3992. {
  3993. $info_list[$key]['library'] = "<p><b class='fullorderreview' data-type='3' data-id='".$value['id']."'>不通过</b></p>";
  3994. }
  3995. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$lr['currencytitle'];
  3996. $lr['hl'] = $lr['hl']==0?6.71:$lr['hl'];
  3997. $cost = $lr['cost']/$lr['hl'];
  3998. $currencytitle = $lr['budget']-$lr['refundj']-$cost-$lr['expressmoney'];
  3999. $info_list[$key]['currencytitle'] = sprintf("%.2f",$currencytitle).' '.$lr['currencytitle'];
  4000. **/
  4001. }
  4002. $total = $this->fullorder->find_count($where);
  4003. $pagenum = ceil($total/$perpage);
  4004. $over = $total-($start+$perpage);
  4005. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4006. echo json_encode($rows);exit;
  4007. }
  4008. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4009. $this->data['shop'] = $wlshop;
  4010. $this->_Template('fullorder_review',$this->data);
  4011. }
  4012. public function _wlbz($arg_array)
  4013. {
  4014. $post = $this->input->post(NULL, TRUE);
  4015. if(isset($post['id']))
  4016. {
  4017. $id = $this->input->post('id',true);
  4018. $post['wlbz'] = $this->input->post('wlbz',true);
  4019. if($post['wlbz'] == '')
  4020. {
  4021. echo json_encode(array('msg'=>'备注不能为空','success'=>false));exit;
  4022. }
  4023. if($this->fullorder->save($post,$id))
  4024. {
  4025. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  4026. }
  4027. else
  4028. {
  4029. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  4030. }
  4031. }
  4032. $arg_array = $arg_array[0];
  4033. $fullorder = $this->fullorder->read($arg_array);
  4034. $this->data['fullorder'] = $fullorder;
  4035. $this->_Template('fullorder_wlbz',$this->data);
  4036. }
  4037. //导出资金统计excel
  4038. public function _fmexcel()
  4039. {
  4040. $user = $this->user->get_api($_SESSION['api']);
  4041. if($user)
  4042. {
  4043. $fgshop = "";$sid = "";
  4044. $user = explode('|',trim($user['shop'],'|'));
  4045. foreach ($user as $value)
  4046. {
  4047. $fgshop .= " shop = ".$value." or";
  4048. $sid .= " id = ".$value." or";
  4049. }
  4050. }
  4051. if(isset($_GET['excel']))
  4052. {
  4053. $timetk = $this->input->get('timetk',true);
  4054. $timetj = $this->input->get('timetj',true);
  4055. $shop = $this->input->get('shop',true);
  4056. $source = $this->input->get('source',true);
  4057. $state = $this->input->get('state',true);
  4058. $type = $this->input->get('type',true);
  4059. $orderinfo = $this->input->get('orderinfo',true);
  4060. $user = $this->input->get('user',true);
  4061. $name = $this->input->get('name',true);
  4062. $timetk = strtotime($timetk);
  4063. $timetj = strtotime($timetj);
  4064. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  4065. if($timetk && $timetj)
  4066. {
  4067. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  4068. }
  4069. if($shop)
  4070. {
  4071. $where .= " and shop = '$shop'";
  4072. }
  4073. if($source)
  4074. {
  4075. $where .= " and source = '$source'";
  4076. }
  4077. if($state)
  4078. {
  4079. if($state == 1)
  4080. {
  4081. $where .= " and state = '$state'";
  4082. }
  4083. }
  4084. if($type)
  4085. {
  4086. $where .= " and type = '$type'";
  4087. }
  4088. if($orderinfo)
  4089. {
  4090. $where .= " and orderinfo = '$orderinfo'";
  4091. }
  4092. if($user)
  4093. {
  4094. $where .= " and user = '$user'";
  4095. }
  4096. if($name)
  4097. {
  4098. $where .= " and name = '$name'";
  4099. }
  4100. //取得信息列表
  4101. $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');
  4102. //格式化数据
  4103. $i = 1;$shouldmoney = 0;$refund = 0;$budget = 0;$currency = 0;$hl=1;
  4104. foreach ($info_list as $key=>$value)
  4105. {
  4106. $info_list[$key]['id'] = $i;
  4107. if($value['currencytitle'] != "CNY")
  4108. {
  4109. $hl=$value['hl'];
  4110. }
  4111. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  4112. $budget=$budget+($value['budget']*$hl);
  4113. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  4114. $refund=$refund+($value['refund']*$hl);
  4115. $shop = $this->shop->read($value['shop']);
  4116. $info_list[$key]['shop'] = $shop['shopname'];
  4117. $info_list[$key]['user'] = $shop['shopuser'];
  4118. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  4119. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  4120. $country = $this->country->read($value['country']);
  4121. $info_list[$key]['country'] = $country['name'];
  4122. $express = $this->express->read($value['express']);
  4123. $info_list[$key]['express'] = $express['servicename'];
  4124. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  4125. $info_list[$key]['refund'] = $value['refund'].' '.$value['currencytitle'];
  4126. $info_list[$key]['budget'] = $value['budget'].' '.$value['currencytitle'];
  4127. $info_list[$key]['currency'] = sprintf("%.2f",$value['shouldmoney']-$value['budget']).' '.$value['currencytitle'];
  4128. $fpdata = array();
  4129. if(stripos($value['fpdata'],';') !== false)
  4130. {
  4131. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  4132. foreach ($fpdata as $ke=>$va)
  4133. {
  4134. $v = explode('|',rtrim($va,'|'));
  4135. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  4136. }
  4137. }
  4138. $info_list[$key]['fpdata'] = $fpdata;
  4139. $i++;
  4140. }
  4141. $data = array($shouldmoney.' CNY',$refund.' CNY',$currency.' CNY',$budget.' CNY');
  4142. $title = "订单资金信息";
  4143. $titlename = "<table border=1>
  4144. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  4145. <tr>
  4146. <td>NO.</td>
  4147. <td>店铺</td>
  4148. <td>负责人</td>
  4149. <td>编号</td>
  4150. <td>订单号</td>
  4151. <td>客户姓名</td>
  4152. <td>国家</td>
  4153. <td>订单日期</td>
  4154. <td>发货日期</td>
  4155. <td>快递公司</td>
  4156. <td>运单号</td>
  4157. <td>订单金额</td>
  4158. <td>退款金额</td>
  4159. <td>手续费</td>
  4160. <td>预估金额</td>
  4161. <td>
  4162. <table border=1>
  4163. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  4164. <tr>
  4165. <td>产品</td>
  4166. <td>条数</td>
  4167. <td>数量</td>
  4168. </tr>
  4169. </table>
  4170. </td>
  4171. <td>总条数</td>
  4172. </tr>
  4173. </table>";
  4174. $filename = $title.".xls";
  4175. $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";
  4176. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  4177. }
  4178. }
  4179. //导出订单excel
  4180. public function _fdexcel()
  4181. {
  4182. if(isset($_GET['excel']))
  4183. {
  4184. $page = $this->input->post('page',true);
  4185. $perpage = $this->input->post('perpage',true);
  4186. $timetk = $this->input->post('timetk',true);
  4187. $timetj = $this->input->post('timetj',true);
  4188. $shop = $this->input->post('shop',true);
  4189. $source = $this->input->post('source',true);
  4190. $state = $this->input->post('state',true);
  4191. $review = $this->input->post('review',true);
  4192. $express = $this->input->post('express',true);
  4193. $orderinfo = $this->input->post('orderinfo',true);
  4194. $user = $this->input->post('user',true);
  4195. $name = $this->input->post('name',true);
  4196. $waybill = $this->input->post('waybill',true);
  4197. $timetk = strtotime($timetk);
  4198. $timetj = strtotime($timetj);
  4199. $where = "1=1 and mergeid = 0";
  4200. if($timetk && $timetj)
  4201. {
  4202. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  4203. }
  4204. if($shop)
  4205. {
  4206. $where .= " and shop = '$shop'";
  4207. }
  4208. if($source)
  4209. {
  4210. $where .= " and source = '$source'";
  4211. }
  4212. if($state)
  4213. {
  4214. $where .= " and state = '$state'";
  4215. }
  4216. if($review)
  4217. {
  4218. $where .= " and review = '$review'";
  4219. }
  4220. if($express)
  4221. {
  4222. $where .= " and express = '$express'";
  4223. }
  4224. if($orderinfo)
  4225. {
  4226. $where .= " and orderinfo = '$orderinfo'";
  4227. }
  4228. if($user)
  4229. {
  4230. $where .= " and user = '$user'";
  4231. }
  4232. if($name)
  4233. {
  4234. $where .= " and name = '$name'";
  4235. }
  4236. if($waybill)
  4237. {
  4238. $where .= " and waybill = '$waybill'";
  4239. }
  4240. //取得信息列表
  4241. $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');
  4242. //格式化数据
  4243. $i = 1;$shouldmoney = 0;$hl=1;
  4244. foreach ($info_list as $key=>$value)
  4245. {
  4246. $info_list[$key]['id'] = $i;
  4247. if($value['source'] == 1)
  4248. {
  4249. $info_list[$key]['source'] = "线下订单";
  4250. }
  4251. else if($value['source'] == 2)
  4252. {
  4253. $info_list[$key]['source'] = "PC订单";
  4254. }
  4255. else if($value['source'] == 3)
  4256. {
  4257. $info_list[$key]['source'] = "手机订单";
  4258. }
  4259. if($value['currencytitle'] != "CNY")
  4260. {
  4261. $hl=$value['hl'];
  4262. }
  4263. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  4264. $shop = $this->shop->read($value['shop']);
  4265. $info_list[$key]['shop'] = $shop['shopname'];
  4266. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  4267. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  4268. $state = $this->typeclass->read($value['state']);
  4269. $info_list[$key]['state'] = $state['title'];
  4270. $country = $this->country->read($value['country']);
  4271. $info_list[$key]['country'] = $country['name'];
  4272. $express = $this->express->read($value['express']);
  4273. $info_list[$key]['express'] = $express['servicename'];
  4274. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  4275. $fpdata = array();
  4276. if(stripos($value['fpdata'],';') !== false)
  4277. {
  4278. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  4279. foreach ($fpdata as $ke=>$va)
  4280. {
  4281. $v = explode('|',rtrim($va,'|'));
  4282. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  4283. }
  4284. }
  4285. $info_list[$key]['fpdata'] = $fpdata;
  4286. $i++;
  4287. }
  4288. $data = array($shouldmoney.' CNY');
  4289. $title = "订单信息表";
  4290. $titlename = "<table border=1>
  4291. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  4292. <tr>
  4293. <td>NO.</td>
  4294. <td>店铺</td>
  4295. <td>编号</td>
  4296. <td>订单号</td>
  4297. <td>订单类型</td>
  4298. <td>客户姓名</td>
  4299. <td>收件人名称</td>
  4300. <td>收货人地址</td>
  4301. <td>城市</td>
  4302. <td>邮编</td>
  4303. <td>州</td>
  4304. <td>国家</td>
  4305. <td>收件电话</td>
  4306. <td>订单日期</td>
  4307. <td>发货日期</td>
  4308. <td>订单状态</td>
  4309. <td>订单金额</td>
  4310. <td>快递公司</td>
  4311. <td>运单号</td>
  4312. <td>订单备注</td>
  4313. <td>客户备注</td>
  4314. <td>
  4315. <table border=1>
  4316. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  4317. <tr>
  4318. <td>产品</td>
  4319. <td>条数</td>
  4320. <td>数量</td>
  4321. </tr>
  4322. </table>
  4323. </td>
  4324. <td>总条数</td>
  4325. </tr>
  4326. </table>";
  4327. $filename = $title.".xls";
  4328. $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";
  4329. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  4330. }
  4331. }
  4332. public function _black()
  4333. {
  4334. $post = $this->input->post(NULL, TRUE);
  4335. if(isset($post['bd']))
  4336. {
  4337. $bd = $this->input->post('bd',true);
  4338. $rows = $this->fullorder->read($bd);
  4339. $post['shop'] = $rows['shop'];
  4340. $post['source'] = 1;
  4341. $post['name'] = $rows['client'];
  4342. $post['email'] = $rows['email'];
  4343. $post['phone'] = $rows['phone'];
  4344. $post['country'] = $rows['country'];
  4345. $post['money'] = $rows['shouldmoney'];
  4346. $post['num'] = 1;
  4347. $post['time'] = $rows['dtime'];
  4348. $post['province'] = $rows['province'];
  4349. $post['city'] = $rows['city'];
  4350. $post['street'] = $rows['street'];
  4351. $post['address'] = $rows['address'];
  4352. $post['address2'] = $rows['address2'];
  4353. $post['zipcode'] = $rows['zipcode'];
  4354. $post['type'] = 2;
  4355. if($this->customer->insert($post))
  4356. {
  4357. $this->fullorder->save(array('black'=>1),$bd);
  4358. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  4359. }
  4360. else
  4361. {
  4362. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4363. }
  4364. }
  4365. }
  4366. public function _ryf()
  4367. {
  4368. $post = $this->input->post(NULL, TRUE);
  4369. if(isset($post['bd']))
  4370. {
  4371. $bd = $this->input->post('bd',true);
  4372. $d = $this->fullorder->read($bd);
  4373. if($d['state'] == 207 || $d['state'] == 207)//订单状态为等待发货或等待部分发货才可更改为允许发货
  4374. {
  4375. if($d['print'] < 3)//打印状态为未打印
  4376. {
  4377. $print = 1;//未打印
  4378. $libraryconfirm = 1;//不允许出库
  4379. $a = "订单未打印,";
  4380. }
  4381. else//已打印订单
  4382. {
  4383. $libraryconfirm = 2;//允许出库
  4384. $a = "";
  4385. }
  4386. if($this->fullorder->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  4387. {
  4388. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  4389. }
  4390. else
  4391. {
  4392. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4393. }
  4394. }
  4395. if($this->fullorder->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  4396. {
  4397. echo json_encode(array('msg'=>'操作失败!订单未非发货状态','success'=>false));exit;
  4398. }
  4399. else
  4400. {
  4401. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4402. }
  4403. }
  4404. }
  4405. public function _fsstate()
  4406. {
  4407. $post = $this->input->post(NULL, TRUE);
  4408. if(isset($post['s']))
  4409. {
  4410. $id_arr = $this->input->post('s');
  4411. $id_arr = explode(',',$id_arr);
  4412. if(!$id_arr)
  4413. {
  4414. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  4415. }
  4416. foreach ($id_arr as $v)
  4417. {
  4418. $data = $this->fullorder->read($v);
  4419. $warehouse = $this->warehouse->read($data['type']);
  4420. $fs = $this->notice->get_ordertatus($data['state']);
  4421. if($fs)
  4422. {
  4423. $ck = $this->_email($fs['content'],$data,$warehouse['company']);
  4424. if($ck == 1)
  4425. {
  4426. $this->fullorder->save(array('fscontent'=>date('Y-m-d H:i:s',time()).'已发送:'.$fs['title'].' - '),$v);
  4427. }
  4428. }
  4429. }
  4430. echo json_encode(array('msg'=>'发送完成!','success'=>true));exit;
  4431. }
  4432. }
  4433. public function _power()
  4434. {
  4435. $user = $this->user->get_api($_SESSION['api']);
  4436. $post = $this->input->post(NULL, TRUE);
  4437. if(isset($post['id']))
  4438. {
  4439. $id = $this->input->post('id',true);
  4440. $fullorder = $this->fullorder->read($id);
  4441. $express = $this->express->read($fullorder['express']);
  4442. $warehouse = $this->warehouse->read($fullorder['type']);
  4443. if(($warehouse['zd'] == '1' || stripos($fullorder['whlabel'],'z|') !== false) && $fullorder['library'] == '2')
  4444. {
  4445. echo json_encode(array('msg'=>'需要先退库释放库存后才可重置!','success'=>false));exit;
  4446. }
  4447. /**
  4448. if($fullorder['print'] == '3' && isset($express['iscode']) && ($express['iscode'] == 'ARAMEX' || $express['iscode'] == 'TOLL' || $express['iscode'] == 'FEDEX'))
  4449. {
  4450. $lj = $this->ali->get_lj($fullorder['number'],2,'订单修改');
  4451. if($lj != '1' && $lj != '订单不存在')
  4452. {
  4453. echo json_encode(array('msg'=>$lj,'success'=>false));exit;
  4454. }
  4455. }
  4456. **/
  4457. $warehouse = $this->warehouse->read($fullorder['warehouse']);
  4458. $typeclass = $this->typeclass->read($fullorder['state']);
  4459. $express = $this->express->read($fullorder['express']);
  4460. $printtype = array(1=>'运单',2=>'发货单',3=>'不打印单据');
  4461. $teset['number']=$fullorder['number'];
  4462. $teset['orderinfo']=$fullorder['orderinfo'];
  4463. $teset['shop']=$fullorder['shop'];
  4464. $teset['user']=$user['userid'];
  4465. $teset['ip']=$this->input->ip_address();
  4466. $teset['time']=time();
  4467. $teset['warehouse']=(isset($warehouse['title']))?$warehouse['title']:'未选择';
  4468. $teset['state']=(isset($typeclass['title']))?$typeclass['spare']:'未选择';
  4469. $teset['express']=(isset($express['title']))?$express['servicename']:'未选择';
  4470. $teset['printtype']=(isset($printtype[$fullorder['printtype']]))?$printtype[$fullorder['printtype']]:'未选择';
  4471. $teset['reviewtime']=($fullorder['reviewtime'] > '0')?date('Y-m-d H:i:s',$fullorder['reviewtime']):'无';
  4472. $teset['printtime']=($fullorder['printtime'] > '0')?date('Y-m-d H:i:s',$fullorder['printtime']):'无';
  4473. $teset['librarytime']=($fullorder['librarytime'] > '0')?date('Y-m-d H:i:s',$fullorder['librarytime']):'无';
  4474. $teset['shipremarks']=$fullorder['shipremarks'];
  4475. $teset['fpdata']=$fullorder['fpdata'];
  4476. $teset['oldwaybill']=$fullorder['oldwaybill'];
  4477. $teset['oldprinttime']=$fullorder['oldprinttime'];
  4478. if($fullorder['printtype'] == 1)
  4479. {
  4480. if($fullorder['waybill'] != '' && stripos($fullorder['oldwaybill'],$fullorder['waybill']) === false)
  4481. {
  4482. $teset['oldwaybill'] .= '-'.date('Ymd',$fullorder['printtime']).'/'.$fullorder['waybill'];
  4483. $teset['oldprinttime'] .= '-'.$fullorder['printtime'];
  4484. }
  4485. }
  4486. $review = ($fullorder['source']==1)?2:1;//线下单审核状态直接为待审核
  4487. if(!$this->fullreset->insert($teset))
  4488. {
  4489. echo json_encode(array('msg'=>'重置失败,请重试','success'=>true));exit;
  4490. }
  4491. 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))
  4492. {
  4493. echo json_encode(array('msg'=>'重置成功!如需再次提交,请先保存、再提交','success'=>true));exit;
  4494. }
  4495. else
  4496. {
  4497. echo json_encode(array('msg'=>'重置失败,请重试','success'=>false));exit;
  4498. }
  4499. }
  4500. }
  4501. public function _expresstype()
  4502. {
  4503. $post = $this->input->post(NULL, TRUE);
  4504. if(isset($post['id']))
  4505. {
  4506. $id = $this->input->post('id',true);
  4507. $data = $this->express->read($id);
  4508. echo json_encode(array('msg'=>$data['type'],'success'=>true));exit;
  4509. }
  4510. }
  4511. public function _email($content,$data,$shopname)
  4512. {
  4513. $express = $this->express->read($data['express']);
  4514. $t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
  4515. $h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['servicename'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
  4516. $content = str_replace($t,$h,$content);
  4517. $this->load->library('email');
  4518. $config['protocol'] = 'smtp';
  4519. $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
  4520. $config['smtp_port'] = 465;
  4521. $config['smtp_user'] = 'service@email.supernovahair.com';
  4522. $config['smtp_pass'] = 'LONGyihair374';
  4523. $config['smtp_crypto'] = 'ssl';
  4524. $config['crlf'] = "\r\n";
  4525. $config['newline'] = "\r\n";
  4526. $this->email->initialize($config);
  4527. $this->email->from('service@email.supernovahair.com',$shopname);
  4528. $this->email->to($data['email']);//收件
  4529. $this->email->subject('The product you purchased has a new progress');//标题
  4530. $this->email->message($content);//内容
  4531. if ( ! $this->email->send())
  4532. {
  4533. return 2;
  4534. }
  4535. else
  4536. {
  4537. return 1;
  4538. }
  4539. }
  4540. public function _error()
  4541. {
  4542. if(isset($_SESSION['api']))
  4543. {
  4544. $user = $this->user->get_api($_SESSION['api']);
  4545. $usp = $user;
  4546. $fgshop = "";$sid = "";
  4547. $user = explode('|',trim($user['shop'],'|'));
  4548. foreach ($user as $value)
  4549. {
  4550. $fgshop .= " shop = ".$value." or";
  4551. $sid .= " id = ".$value." or";
  4552. }
  4553. }
  4554. $post = $this->input->post(NULL, TRUE);
  4555. if(isset($post['page']))
  4556. {
  4557. $page = $this->input->post('page',true);
  4558. $perpage = $this->input->post('perpage',true);
  4559. $orderinfo = $this->input->post('orderinfo',true);
  4560. $waybill = $this->input->post('waybill',true);
  4561. $number = $this->input->post('number',true);
  4562. $timetk = $this->input->post('timetk',true);
  4563. $timetj = $this->input->post('timetj',true);
  4564. $timetk = strtotime($timetk);
  4565. $timetj = strtotime($timetj);
  4566. $where = "failed !='' and mergeid = 0 and print != 3 and (".rtrim($fgshop,'or').")";
  4567. if($orderinfo)
  4568. {
  4569. $where .= " and orderinfo = '$orderinfo'";
  4570. }
  4571. if($waybill)
  4572. {
  4573. $where .= " and waybill = '$waybill'";
  4574. }
  4575. if($number)
  4576. {
  4577. $where .= " and number = '$number'";
  4578. }
  4579. if($timetk && $timetj)
  4580. {
  4581. $timetj = $timetj+24*3600;
  4582. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4583. }
  4584. //数据排序
  4585. $order_str = "dtime desc";
  4586. if(empty($page))
  4587. {
  4588. $start = 0;
  4589. $perpage = 1;
  4590. }
  4591. else
  4592. {
  4593. $start = ($page - 1)*$perpage;
  4594. }
  4595. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,express,failed,operation',$order_str,$start,$perpage);
  4596. //格式化数据
  4597. foreach ($info_list as $key=>$value)
  4598. {
  4599. $ud = $this->fullorder->read($value['id']);
  4600. $shop = $this->shop->read($value['shop']);
  4601. $info_list[$key]['shop'] = $shop['shopname'];
  4602. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullorder/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'>".$value['orderinfo']."<p>";
  4603. $warehouse = $this->warehouse->read($value['type']);
  4604. $warehousetitle = $warehouse['title'];
  4605. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  4606. $info_list[$key]['type'] = $warehousetitle;
  4607. if($value['express'] != 0)
  4608. {
  4609. $express = $this->express->read($value['express']);
  4610. $expressservicename = $express['servicename'];
  4611. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  4612. $info_list[$key]['express'] = $expressservicename;
  4613. }
  4614. else
  4615. {
  4616. $info_list[$key]['express'] = "无";
  4617. }
  4618. $x = "";
  4619. if($ud['review'] >4 && $ud['print'] == 1)
  4620. {
  4621. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  4622. }
  4623. else
  4624. {
  4625. $x = "<p class='ckn'><b class='fojzof' data-type='9' data-id='".$value['id']."'>关闭</b></p>";
  4626. }
  4627. $info_list[$key]['operation'] = $x;
  4628. }
  4629. $total = $this->fullorder->find_count($where);
  4630. $pagenum = ceil($total/$perpage);
  4631. $over = $total-($start+$perpage);
  4632. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4633. echo json_encode($rows);exit;
  4634. }
  4635. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4636. $this->data['wlshop'] = $wlshop;
  4637. $this->data['express'] = $this->express->find_all();
  4638. $user = $this->user->get_api($_SESSION['api']);
  4639. $powerid = $this->power->read($user['power']);
  4640. $powertext = explode('|',trim($powerid['excelid'],'|'));
  4641. $pid = '';
  4642. foreach ($powertext as $v)
  4643. {
  4644. $pid .= " id = ".$v." or";
  4645. }
  4646. $fullorderexcel = $this->fullorderexcel->find_all("type = '100001' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  4647. $this->data['fullorderexcel'] = $fullorderexcel;
  4648. $this->_Template('fullorder_error',$this->data);
  4649. }
  4650. //验证地址
  4651. public function _yzaddress()
  4652. {
  4653. $post = $this->input->post(NULL, TRUE);
  4654. if(isset($post['address']))
  4655. {
  4656. $address = $this->input->post('address',true);
  4657. $address2 = $this->input->post('address2',true);
  4658. $city = $this->input->post('city',true);
  4659. $province = $this->input->post('province',true);
  4660. $zipcode = $this->input->post('zipcode',true);
  4661. $barcode = $this->usps->get_address(array('address'=>$address,'address2'=>$address2,'city'=>$city,'province'=>$province,'zipcode'=>$zipcode));
  4662. //$this->logic_ding->sendToDing("usps地址验证返回数据".$barcode);
  4663. echo $barcode;
  4664. }
  4665. }
  4666. //清除退货信息
  4667. public function _clearreturn()
  4668. {
  4669. $post = $this->input->post(NULL, TRUE);
  4670. if(isset($post['orderinfo']))
  4671. {
  4672. $orderinfo = $this->input->post('orderinfo',true);
  4673. $data = $this->fullorder->get_orderinfo($orderinfo);
  4674. $fu = 'fullorder';
  4675. if(!$data)
  4676. {
  4677. $data = $this->fullorder_smt->get_orderinfo($orderinfo);
  4678. $fu = 'fullorder_smt';
  4679. }
  4680. $this->$fu->save(array('library'=>'2','retreattime'=>'0','returndata'=>''),$data['id']);
  4681. echo json_encode(array('msg'=>'清除成功!','success'=>true));exit;
  4682. }
  4683. }
  4684. //订单退货
  4685. public function _return()
  4686. {
  4687. $post = $this->input->post(NULL, TRUE);
  4688. if(isset($post['orderinfo']))
  4689. {
  4690. $orderinfo = $this->input->post('orderinfo',true);
  4691. $data = $this->fullorder->get_orderinfo($orderinfo);
  4692. $fu = 'fullorder';
  4693. if(!$data)
  4694. {
  4695. $data = $this->fullorder_smt->get_orderinfo($orderinfo);
  4696. $fu = 'fullorder_smt';
  4697. }
  4698. $bctime = date('Ymd',time());
  4699. if($data['library'] != 2){
  4700. echo json_encode(array('msg'=>'此单不是出库状态,不允许退货','success'=>false));exit;
  4701. }
  4702. if($data['returndata'] != "")
  4703. {
  4704. echo json_encode(array('msg'=>'请求失败,已有Return Label信息!','success'=>false));exit;
  4705. }
  4706. $barcode = $this->usps->get_return($data);
  4707. // if(isset($barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription']))
  4708. // {
  4709. // echo json_encode(array('msg'=>$barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription'],'success'=>false));exit;
  4710. // }
  4711. // else if(isset($barcode['TrackingNumber']))
  4712. // {
  4713. // $pdf = $this->_pdf($barcode['ReturnLabel'],'t-'.$barcode['TrackingNumber'],$bctime);
  4714. // $read = 'PostalRouting:'.$barcode['PostalRouting'].' - TrackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['TrackingNumber'].'.pdf" target="_blank">'.$barcode['TrackingNumber'].'</a>';
  4715. // $this->$fu->save(array('returndata'=>$read),$data['id']);
  4716. // echo json_encode(array('msg'=>'生成Return Label成功!','data'=>$read,'success'=>true));exit;
  4717. // }
  4718. // else
  4719. // {
  4720. // echo json_encode(array('msg'=>'请求失败,请稍后重试!','cs'=>$barcode,'success'=>false));exit;
  4721. // }
  4722. if(isset($barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription']))
  4723. {
  4724. echo json_encode(array('msg'=>$barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription'],'success'=>false));exit;
  4725. }
  4726. else if(isset($barcode['trackingNumber']))
  4727. {
  4728. $pdf = $this->_pdf($barcode['returnLabelImage'],'t-'.$barcode['trackingNumber'],$bctime);
  4729. $read = 'PostalRouting:'.$barcode['routingInformation'].' - TrackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['trackingNumber'].'.pdf" target="_blank">'.$barcode['trackingNumber'].'</a>';
  4730. $this->$fu->save(array('returndata'=>$read),$data['id']);
  4731. echo json_encode(array('msg'=>'生成Return Label成功!','data'=>$read,'success'=>true));exit;
  4732. }
  4733. else
  4734. {
  4735. echo json_encode(array('msg'=>'请求失败,请稍后重试!'.json_encode($barcode),'cs'=>$barcode,'success'=>false));exit;
  4736. }
  4737. }
  4738. /**
  4739. $post = $this->input->post(NULL, TRUE);
  4740. if(isset($post['orderinfo']))
  4741. {
  4742. $orderinfo = $this->input->post('orderinfo',true);
  4743. $data = $this->fullorder->get_orderinfo($orderinfo);
  4744. $fu = 'fullorder';
  4745. if(!$data)
  4746. {
  4747. $data = $this->fullorder_smt->get_orderinfo($orderinfo);
  4748. $fu = 'fullorder_smt';
  4749. }
  4750. $bctime = date('Ymd',time());
  4751. if($data['returndata'] != "")
  4752. {
  4753. echo json_encode(array('msg'=>'请求失败,已有Return Label信息!','success'=>false));exit;
  4754. }
  4755. $barcode = $this->usps->get_return($data);
  4756. if(isset($barcode['error']['message']))
  4757. {
  4758. echo json_encode(array('msg'=>$barcode['error']['message'],'success'=>false));exit;
  4759. }
  4760. else if(isset($barcode['trackingNumber']))
  4761. {
  4762. $pdf = $this->_pdf($barcode['returnLabelImage'],'t-'.$barcode['trackingNumber'],$bctime);
  4763. $read = 'trackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['trackingNumber'].'.pdf" target="_blank">'.$barcode['trackingNumber'].'</a>';
  4764. $this->$fu->save(array('returndata'=>$read),$data['id']);
  4765. echo json_encode(array('msg'=>'生成Return Label成功!','data'=>$read,'success'=>true));exit;
  4766. }
  4767. else
  4768. {
  4769. echo json_encode(array('msg'=>'请求失败,请稍后重试!','cs'=>$barcode,'success'=>false));exit;
  4770. }
  4771. }**/
  4772. }
  4773. public function _pdf($pdf,$title,$bctime)
  4774. {
  4775. $pdf_path = './data/pdf/'.$bctime.'/';
  4776. $file_base64 = $pdf;
  4777. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4778. $file_base64 = base64_decode($file_base64);
  4779. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  4780. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  4781. return $bctime;
  4782. }
  4783. public function _find($find)
  4784. {
  4785. preg_match_all('/\d+/',$find,$n);
  4786. $a = '';
  4787. foreach($n[0] as $v)
  4788. {
  4789. $a .= $v;
  4790. }
  4791. return $a;
  4792. }
  4793. public function _dqpm()
  4794. {
  4795. if(isset($_SESSION['api']))
  4796. {
  4797. $user = $this->user->get_api($_SESSION['api']);
  4798. $usp = $user;
  4799. $fgshop = "";$sid = "";
  4800. $usersp = explode('|',trim($user['shop'],'|'));
  4801. foreach ($usersp as $value)
  4802. {
  4803. $fgshop .= " shop = ".$value." or";
  4804. $sid .= " id = ".$value." or";
  4805. }
  4806. }
  4807. $post = $this->input->post(NULL, TRUE);
  4808. if(isset($post['page']))
  4809. {
  4810. $timetk = $this->input->post('timetk',true);
  4811. $timetj = $this->input->post('timetj',true);
  4812. $timetk = strtotime($timetk);
  4813. $timetj = strtotime($timetj);
  4814. $where = "mergeid = 0 and (".rtrim($fgshop,'or').")";
  4815. if($timetk && $timetj)
  4816. {
  4817. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4818. }
  4819. //数据排序
  4820. $order_str = "dtime desc";
  4821. if(empty($page))
  4822. {
  4823. $start = 0;
  4824. $perpage = 1;
  4825. }
  4826. else
  4827. {
  4828. $start = ($page - 1)*$perpage;
  4829. }
  4830. $continentdata = '';
  4831. $continent = array();//陆地板块
  4832. $num = $this->fullorder->find_count($where);//订单总数量
  4833. $country = $this->country->find_all('1=1','id,continent,ename,zname');
  4834. foreach ($country as $k=>$v)
  4835. {
  4836. $tc = $this->typeclass->read($v['continent']);
  4837. $continent[$v['continent']] = array(0=>$tc['title'],1=>0,2=>'');
  4838. }
  4839. foreach ($country as $k=>$v)
  4840. {
  4841. $n = $this->fullorder->find_count($where.' and country = "'.$v['id'].'"');
  4842. $country[$k]['continent'] = $continent[$v['continent']][0];//此国家数量
  4843. $country[$k]['zname'] = '<a href="/fullorder/dqpmprovince/'.$v['id'].'/'.$timetk.'/'.$timetj.'">'.$v['zname'].'</a>';//此国家数量
  4844. $country[$k]['num'] = $n;//此国家数量
  4845. $country[$k]['zb'] = (sprintf("%.4f",$n/$num)*100).'%';//此国家占比
  4846. $continent[$v['continent']]['1'] += $n;//此洲数量增加;
  4847. }
  4848. array_multisort(array_column($continent, '1'), SORT_DESC, $continent);
  4849. array_multisort(array_column($country, 'num'), SORT_DESC, $country);
  4850. foreach ($continent as $k=>$v)
  4851. {
  4852. $continentdata .= $v['0'].' 总量:'.$v['1'].' 占比:'.(sprintf("%.4f",$v['1']/$num)*100).'%&nbsp;&nbsp; - &nbsp;&nbsp;';
  4853. }
  4854. echo json_encode(array('ewnr'=>$continentdata,'rows'=>$country,'total'=>count($country),'over'=>0,'pagenum'=>1,'success'=>true));exit;
  4855. }
  4856. $this->_Template('fullorder_dqpm',$this->data);
  4857. }
  4858. public function _dqpmprovince($arg_array)
  4859. {
  4860. if(isset($_SESSION['api']))
  4861. {
  4862. $user = $this->user->get_api($_SESSION['api']);
  4863. $usp = $user;
  4864. $fgshop = "";$sid = "";
  4865. $usersp = explode('|',trim($user['shop'],'|'));
  4866. foreach ($usersp as $value)
  4867. {
  4868. $fgshop .= " shop = ".$value." or";
  4869. $sid .= " id = ".$value." or";
  4870. }
  4871. }
  4872. $post = $this->input->post(NULL, TRUE);
  4873. if(isset($post['page']))
  4874. {
  4875. $country = $this->input->post('country',true);
  4876. $timetk = $this->input->post('timetk',true);
  4877. $timetj = $this->input->post('timetj',true);
  4878. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  4879. $province = array();
  4880. $city_list = $this->fullorder->find_all($where,'id,province');
  4881. $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');
  4882. foreach ($city_list as $k=>$v)
  4883. {
  4884. $v['province'] = strtoupper(trim($v['province'],' '));
  4885. if(isset($ToState[$v['province']]))
  4886. {
  4887. $v['province'] = $ToState[$v['province']];
  4888. }
  4889. if(!isset($province[$v['province']]))
  4890. {
  4891. $province[$v['province']] = array('id'=>$v['id'],'province'=>'<a href="/fullorder/ddpmdata/'.$country.'/'.$timetk.'/'.$timetj.'/'.strtoupper($v['province']).'">'.$v['province'].'</a>','num'=>0,'zb'=>'');
  4892. }
  4893. $province[$v['province']]['num'] += 1;
  4894. }
  4895. array_multisort(array_column($province, 'num'), SORT_DESC, $province);
  4896. $province = array_values($province);
  4897. foreach ($province as $k=>$v)
  4898. {
  4899. $province[$k]['zb'] = (sprintf("%.4f",$v['num']/count($city_list))*100).'%';
  4900. }
  4901. echo json_encode(array('rows'=>($province),'total'=>count($province),'over'=>0,'pagenum'=>1,'success'=>true));exit;
  4902. }
  4903. $this->data['arg_array'] = $arg_array;
  4904. $this->_Template('fullorder_dqpmprovince',$this->data);
  4905. }
  4906. public function _ddpmdata($arg_array)
  4907. {
  4908. $arg_array[3] = str_replace('%20',' ',$arg_array[3]);
  4909. if(isset($_SESSION['api']))
  4910. {
  4911. $user = $this->user->get_api($_SESSION['api']);
  4912. $usp = $user;
  4913. $fgshop = "";$sid = "";
  4914. $usersp = explode('|',trim($user['shop'],'|'));
  4915. foreach ($usersp as $value)
  4916. {
  4917. $fgshop .= " shop = ".$value." or";
  4918. $sid .= " id = ".$value." or";
  4919. }
  4920. }
  4921. $post = $this->input->post(NULL, TRUE);
  4922. if(isset($post['page']))
  4923. {
  4924. $page = $this->input->post('page',true);
  4925. $perpage = $this->input->post('perpage',true);
  4926. $province = $this->input->post('province',true);
  4927. $timetk = $this->input->post('timetk',true);;
  4928. $timetj = $this->input->post('timetj',true);;
  4929. $country = $this->input->post('country',true);;
  4930. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  4931. if($province)
  4932. {
  4933. $where .= " and province = '$province'";
  4934. }
  4935. $order_str = "dtime desc";
  4936. if(empty($page))
  4937. {
  4938. $start = 0;
  4939. $perpage = 1;
  4940. }
  4941. else
  4942. {
  4943. $start = ($page - 1)*$perpage;
  4944. }
  4945. $info_list = $this->fullorder->find_all($where,'id,orderinfo,number,shipremarks,shouldmoney',$order_str,$start,$perpage);
  4946. $total = $this->fullorder->find_count($where);
  4947. $pagenum = ceil($total/$perpage);
  4948. $over = $total-($start+$perpage);
  4949. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4950. echo json_encode($rows);exit;
  4951. }
  4952. $province = array();
  4953. $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');
  4954. $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');
  4955. foreach ($city_list as $k=>$v)
  4956. {
  4957. $v['province'] = strtoupper(trim($v['province'],' '));
  4958. if(isset($ToState[$v['province']]))
  4959. {
  4960. $v['province'] = $ToState[$v['province']];
  4961. }
  4962. $province[$v['province']] = array('province'=>$v['province']);
  4963. }
  4964. $this->data['province'] = $province;
  4965. $this->data['arg_array'] = $arg_array;
  4966. $this->_Template('fullorder_ddpmdata',$this->data);
  4967. }
  4968. public function _ddpmexcel($arg_array)
  4969. {
  4970. if(isset($_SESSION['api']))
  4971. {
  4972. $user = $this->user->get_api($_SESSION['api']);
  4973. $usp = $user;
  4974. $fgshop = "";$sid = "";
  4975. $usersp = explode('|',trim($user['shop'],'|'));
  4976. foreach ($usersp as $value)
  4977. {
  4978. $fgshop .= " shop = ".$value." or";
  4979. $sid .= " id = ".$value." or";
  4980. }
  4981. }
  4982. $province = $this->input->get('province',true);
  4983. $timetk = $arg_array[1];
  4984. $timetj = $arg_array[2];
  4985. $country = $arg_array[0];
  4986. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  4987. if($province)
  4988. {
  4989. $where .= " and province = '$province'";
  4990. }
  4991. $order_str = "dtime desc";
  4992. $info_list = $this->fullorder->find_all($where,'orderinfo,number,shipremarks,shouldmoney',$order_str);
  4993. $country = $this->country->read($arg_array[0]);
  4994. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  4995. $titlename = "<table border=1>
  4996. <tr><th colspan='4' align='left'><h3>".$title."<h3></th></tr>
  4997. <tr>
  4998. <td>订单号</td>
  4999. <td>订单编号</td>
  5000. <td>仓库品名</td>
  5001. <td>订单金额</td>
  5002. </tr>
  5003. </table>";
  5004. $filename = $title.".xls";
  5005. $tail = "\n";
  5006. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5007. }
  5008. public function _statedc()
  5009. {
  5010. $user = $this->user->get_api($_SESSION['api']);
  5011. if($user)
  5012. {
  5013. $fgshop = "";$sid = "";
  5014. $user = explode('|',trim($user['shop'],'|'));
  5015. foreach ($user as $value)
  5016. {
  5017. $fgshop .= " shop = ".$value." or";
  5018. $sid .= " id = ".$value." or";
  5019. }
  5020. }
  5021. $post = $this->input->get(NULL, TRUE);
  5022. if(isset($post['timetk']))
  5023. {
  5024. $page = $this->input->get('page',true);
  5025. $perpage = $this->input->get('perpage',true);
  5026. $timetk = $this->input->get('timetk',true);
  5027. $timetj = $this->input->get('timetj',true);
  5028. $shop = $this->input->get('shop',true);
  5029. $source = $this->input->get('source',true);
  5030. $state = $this->input->get('state',true);
  5031. $review = $this->input->get('review',true);
  5032. $express = $this->input->get('express',true);
  5033. $fs = $this->input->get('fs',true);
  5034. $orderinfo = $this->input->get('orderinfo',true);
  5035. $number = $this->input->get('number',true);
  5036. $user = $this->input->get('user',true);
  5037. $name = $this->input->get('name',true);
  5038. $waybill = $this->input->get('waybill',true);
  5039. $expressstate = $this->input->get('expressstate',true);
  5040. $wltype = $this->input->get('wltype',true);
  5041. $wlyc = $this->input->get('wlyc',true);
  5042. $xztime = $this->input->get('xztime',true);
  5043. $timetk = strtotime($timetk);
  5044. $timetj = strtotime($timetj);
  5045. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5046. if($timetk && $timetj)
  5047. {
  5048. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5049. }
  5050. if($xztime == 'librarytime')
  5051. {
  5052. $order_str = "librarytime desc";
  5053. }
  5054. else if($xztime == 'dtime')
  5055. {
  5056. $order_str = "dtime desc";
  5057. }
  5058. if($shop)
  5059. {
  5060. $where .= " and shop = '$shop'";
  5061. }
  5062. if($source)
  5063. {
  5064. if($source == 11)
  5065. {
  5066. $where .= " and source != '1'";
  5067. }
  5068. else
  5069. {
  5070. $where .= " and source = '$source'";
  5071. }
  5072. }
  5073. if($fs)
  5074. {
  5075. if($fs == '2')
  5076. {
  5077. $where .= " and exstateerror != ''";
  5078. }
  5079. else
  5080. {
  5081. $where .= " and exstateerror = ''";
  5082. }
  5083. }
  5084. if($state)
  5085. {
  5086. $where .= " and state = '$state'";
  5087. }
  5088. if($review)
  5089. {
  5090. $where .= " and review = '$review'";
  5091. }
  5092. if($expressstate != "")
  5093. {
  5094. $where .= " and expressstate = '$expressstate'";
  5095. }
  5096. if($wltype != "")
  5097. {
  5098. $where .= " and wltype = '$wltype'";
  5099. }
  5100. if($wlyc != "")
  5101. {
  5102. $where .= " and wlyc = '$wlyc'";
  5103. }
  5104. if($express)
  5105. {
  5106. $where .= " and express = '$express'";
  5107. }
  5108. if($orderinfo)
  5109. {
  5110. $where .= " and orderinfo = '$orderinfo'";
  5111. }
  5112. if($number)
  5113. {
  5114. $where .= " and number = '$number'";
  5115. }
  5116. if($user)
  5117. {
  5118. $where .= " and user = '$user'";
  5119. }
  5120. if($name)
  5121. {
  5122. $where .= " and name = '$name'";
  5123. }
  5124. if($waybill)
  5125. {
  5126. $where .= " and waybill = '$waybill'";
  5127. }
  5128. if(empty($page))
  5129. {
  5130. $start = 0;
  5131. $perpage = 1;
  5132. }
  5133. else
  5134. {
  5135. $start = ($page - 1)*$perpage;
  5136. }
  5137. //取得信息列表
  5138. $info_list = $this->fullorder->find_all($where,'shop,number,country,library,librarytime,expressstate,express,waybill,content,exstateerror,excontent',$order_str);
  5139. //格式化数据
  5140. foreach ($info_list as $key=>$value)
  5141. {
  5142. $shop = $this->shop->read($value['shop']);
  5143. $info_list[$key]['shop'] = $shop['shopname'];
  5144. $country = $this->country->read($value['country']);
  5145. $info_list[$key]['country'] = $country['name'];
  5146. //$state = $this->typeclass->read($value['state']);
  5147. //$info_list[$key]['state'] = $state['title'];
  5148. if($value['library'] == 1)
  5149. {
  5150. $info_list[$key]['library'] = "未出库";
  5151. }
  5152. else if($value['library'] == 2)
  5153. {
  5154. $info_list[$key]['library'] = "已出库";
  5155. }
  5156. else if($value['library'] == 3)
  5157. {
  5158. $info_list[$key]['library'] = "已退库";
  5159. }
  5160. if($value['librarytime'] == '0')
  5161. {
  5162. $info_list[$key]['librarytime'] = '无';
  5163. }
  5164. else
  5165. {
  5166. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  5167. }
  5168. if($value['expressstate'] == 0)
  5169. {
  5170. $info_list[$key]['expressstate'] = "无信息";
  5171. }
  5172. else if($value['expressstate'] == 2)
  5173. {
  5174. $info_list[$key]['expressstate'] = "已取件";
  5175. }
  5176. else if($value['expressstate'] == 3)
  5177. {
  5178. $info_list[$key]['expressstate'] = "在途中";
  5179. }
  5180. /**
  5181. else if($value['expressstate'] == 4)
  5182. {
  5183. $info_list[$key]['expressstate'] = "到达目的地国";
  5184. }
  5185. **/
  5186. else if($value['expressstate'] == 4 || $value['expressstate'] == 5)
  5187. {
  5188. $info_list[$key]['expressstate'] = "即将派送";
  5189. }
  5190. else if($value['expressstate'] == 6)
  5191. {
  5192. $info_list[$key]['expressstate'] = "已签收";
  5193. }
  5194. else if($value['expressstate'] == 1)
  5195. {
  5196. $info_list[$key]['expressstate'] = "派送异常";
  5197. }
  5198. $express = $this->express->read($value['express']);
  5199. $info_list[$key]['express'] = $express['servicename'];
  5200. }
  5201. }
  5202. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5203. $titlename = "<table border=1>
  5204. <tr>
  5205. <td>店铺名称</td>
  5206. <td>编号</td>
  5207. <td>收件人国家</td>
  5208. <td>出库状态</td>
  5209. <td>发货时间</td>
  5210. <td>物流状态</td>
  5211. <td>快递公司</td>
  5212. <td>运单号</td>
  5213. <td>消息状态</td>
  5214. <td>错误提示</td>
  5215. <td>物流信息</td>
  5216. </tr>
  5217. </table>";
  5218. $filename = $title.".xls";
  5219. $tail = "\n";
  5220. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5221. }
  5222. public function _statedcwl()
  5223. {
  5224. $user = $this->user->get_api($_SESSION['api']);
  5225. if($user)
  5226. {
  5227. $fgshop = "";$sid = "";
  5228. $user = explode('|',trim($user['shop'],'|'));
  5229. foreach ($user as $value)
  5230. {
  5231. $fgshop .= " shop = ".$value." or";
  5232. $sid .= " id = ".$value." or";
  5233. }
  5234. }
  5235. $post = $this->input->get(NULL, TRUE);
  5236. if(isset($post['timetk']))
  5237. {
  5238. $dowid = $this->input->get('a');
  5239. $wid = "";
  5240. if($dowid != "")
  5241. {
  5242. $id_arr = explode(',',rtrim($dowid,','));
  5243. $wid .= " id = 0 or";
  5244. foreach ($id_arr as $v)
  5245. {
  5246. $wid .= " id = '$v' or";
  5247. }
  5248. $wid = " and".rtrim($wid,'or');
  5249. }
  5250. $page = $this->input->get('page',true);
  5251. $perpage = $this->input->get('perpage',true);
  5252. $timetk = $this->input->get('timetk',true);
  5253. $timetj = $this->input->get('timetj',true);
  5254. $shop = $this->input->get('shop',true);
  5255. $expressstate = $this->input->get('expressstate',true);
  5256. $fs = $this->input->get('fs',true);
  5257. $state = $this->input->get('state',true);
  5258. $express = $this->input->get('express',true);
  5259. $orderinfo = $this->input->get('orderinfo',true);
  5260. $number = $this->input->get('number',true);
  5261. $waybill = $this->input->get('waybill',true);
  5262. $wlyc = $this->input->get('wlyc',true);
  5263. $wltype = $this->input->get('wltype',true);
  5264. $source = $this->input->get('source',true);
  5265. $xztime = $this->input->get('xztime',true);
  5266. $timetk = strtotime($timetk);
  5267. $timetj = strtotime($timetj);
  5268. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5269. if($timetk && $timetj)
  5270. {
  5271. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5272. }
  5273. if($xztime == 'librarytime')
  5274. {
  5275. $order_str = "librarytime desc";
  5276. }
  5277. else if($xztime == 'dtime')
  5278. {
  5279. $order_str = "dtime desc";
  5280. }else if($xztime == 'wlfstime'){
  5281. $order_str = "wlfstime desc";
  5282. }
  5283. if($shop)
  5284. {
  5285. $where .= " and shop = '$shop'";
  5286. }
  5287. if($expressstate)
  5288. {
  5289. $where .= " and expressstate = '$expressstate'";
  5290. }
  5291. if($fs)
  5292. {
  5293. if($fs == '1')
  5294. {
  5295. $where .= " and wlcontent != ''";
  5296. }
  5297. if($fs == '2')
  5298. {
  5299. $where .= " and wlerror != ''";
  5300. }
  5301. if($fs == '3')
  5302. {
  5303. $where .= " and wlcontent = '' and shouldmoney > 100";
  5304. }
  5305. else if($fs == '4')
  5306. {
  5307. $where .= " and wltype = '1'";
  5308. }
  5309. }
  5310. if($state)
  5311. {
  5312. $where .= " and state = '$state'";
  5313. }
  5314. if($express)
  5315. {
  5316. $where .= " and express = '$express'";
  5317. }
  5318. if($orderinfo)
  5319. {
  5320. $where .= " and orderinfo = '$orderinfo'";
  5321. }
  5322. if($number)
  5323. {
  5324. $where .= " and number = '$number'";
  5325. }
  5326. if($waybill)
  5327. {
  5328. $where .= " and waybill = '$waybill'";
  5329. }
  5330. if($wlyc!='')
  5331. {
  5332. $where .= " and wlyc = '$wlyc'";
  5333. }
  5334. if($wltype!='')
  5335. {
  5336. $where .= " and wltype = '$wltype'";
  5337. }
  5338. if($source)
  5339. {
  5340. if($source == 1)
  5341. {
  5342. $where .= " and source = '$source'";
  5343. }
  5344. else
  5345. {
  5346. $where .= " and source != '1'";
  5347. }
  5348. }
  5349. $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);
  5350. //格式化数据
  5351. foreach ($info_list as $key=>$value)
  5352. {
  5353. $country = $this->country->read($value['country']);
  5354. $info_list[$key]['country'] = $country['name'];
  5355. //$state = $this->typeclass->read($value['state']);
  5356. //$info_list[$key]['state'] = $state['title'];
  5357. if($value['library'] == 1)
  5358. {
  5359. $info_list[$key]['library'] = "未出库";
  5360. }
  5361. else if($value['library'] == 2)
  5362. {
  5363. $info_list[$key]['library'] = "已出库";
  5364. }
  5365. else if($value['library'] == 3)
  5366. {
  5367. $info_list[$key]['library'] = "已退库";
  5368. }
  5369. if($value['librarytime'] == '0')
  5370. {
  5371. $info_list[$key]['librarytime'] = '无';
  5372. }
  5373. else
  5374. {
  5375. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  5376. }
  5377. if($value['expressstate'] == 0)
  5378. {
  5379. $info_list[$key]['expressstate'] = "无信息";
  5380. }
  5381. else if($value['expressstate'] == 2)
  5382. {
  5383. $info_list[$key]['expressstate'] = "已取件";
  5384. }
  5385. else if($value['expressstate'] == 3)
  5386. {
  5387. $info_list[$key]['expressstate'] = "在途中";
  5388. }
  5389. /**
  5390. else if($value['expressstate'] == 4)
  5391. {
  5392. $info_list[$key]['expressstate'] = "到达目的地国";
  5393. }
  5394. **/
  5395. else if($value['expressstate'] == 4 || $value['expressstate'] == 5)
  5396. {
  5397. $info_list[$key]['expressstate'] = "即将派送";
  5398. }
  5399. else if($value['expressstate'] == 6)
  5400. {
  5401. $info_list[$key]['expressstate'] = "已签收";
  5402. }
  5403. else if($value['expressstate'] == 1)
  5404. {
  5405. $info_list[$key]['expressstate'] = "派送异常";
  5406. }
  5407. $info_list[$key]['wlfstime'] = date('Y-m-d H:i:s',$value['wlfstime']);
  5408. $express = $this->express->read($value['express']);
  5409. $info_list[$key]['express'] = $express['servicename'];
  5410. $info_list[$key]['excontent'] = str_replace('<br />','',$value['excontent']);
  5411. }
  5412. }
  5413. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5414. $titlename = "<table border=1>
  5415. <tr>
  5416. <td>订单号</td>
  5417. <td>编号</td>
  5418. <td>收件人国家</td>
  5419. <td>出库状态</td>
  5420. <td>出库时间</td>
  5421. <td>物流状态</td>
  5422. <td>快递公司</td>
  5423. <td>运单号</td>
  5424. <td>物流备注</td>
  5425. <td>订单备注</td>
  5426. <td>仓库品名</td>
  5427. <td>发送时间</td>
  5428. <td>邮箱</td>
  5429. <td>电话</td>
  5430. <td>邮件发送</td>
  5431. <td>错误提示</td>
  5432. <td>物流信息</td>
  5433. </tr>
  5434. </table>";
  5435. $filename = $title.".xls";
  5436. $tail = "\n";
  5437. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5438. }
  5439. public function _waybillemail()
  5440. {
  5441. $user = $this->user->get_api($_SESSION['api']);
  5442. if($user)
  5443. {
  5444. $fgshop = "";$sid = "";
  5445. $user = explode('|',trim($user['shop'],'|'));
  5446. foreach ($user as $value)
  5447. {
  5448. $fgshop .= " shop = ".$value." or";
  5449. $sid .= " id = ".$value." or";
  5450. }
  5451. }
  5452. $post = $this->input->post(NULL, TRUE);
  5453. if(isset($post['page']))
  5454. {
  5455. $page = $this->input->post('page',true);
  5456. $perpage = $this->input->post('perpage',true);
  5457. $timetk = $this->input->post('timetk',true);
  5458. $timetj = $this->input->post('timetj',true);
  5459. $shop = $this->input->post('shop',true);
  5460. $source = $this->input->post('source',true);
  5461. $expressstate = $this->input->post('expressstate',true);
  5462. $fs = $this->input->post('fs',true);
  5463. $state = $this->input->post('state',true);
  5464. $express = $this->input->post('express',true);
  5465. $orderinfo = $this->input->post('orderinfo',true);
  5466. $number = $this->input->post('number',true);
  5467. $waybill = $this->input->post('waybill',true);
  5468. $dlzemail = $this->input->post('dlzemail',true);
  5469. $xztime = $this->input->post('xztime',true);
  5470. $timetk = strtotime($timetk);
  5471. $timetj = strtotime($timetj);
  5472. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5473. if($timetk && $timetj)
  5474. {
  5475. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5476. }
  5477. $order_str = $xztime." desc";
  5478. if($source)
  5479. {
  5480. if($source == '2d')
  5481. {
  5482. $where .= " and source >= '2' and shop != 19";
  5483. }
  5484. else
  5485. {
  5486. $where .= " and source = '$source'";
  5487. }
  5488. }
  5489. if($shop)
  5490. {
  5491. $where .= " and shop = '$shop'";
  5492. }
  5493. if($expressstate)
  5494. {
  5495. $where .= " and expressstate = '$expressstate'";
  5496. }
  5497. if($state)
  5498. {
  5499. $where .= " and state = '$state'";
  5500. }
  5501. if($express)
  5502. {
  5503. $where .= " and express = '$express'";
  5504. }
  5505. if($orderinfo)
  5506. {
  5507. $where .= " and orderinfo = '$orderinfo'";
  5508. }
  5509. if($number)
  5510. {
  5511. $where .= " and number = '$number'";
  5512. }
  5513. if($waybill)
  5514. {
  5515. $where .= " and waybill = '$waybill'";
  5516. }
  5517. if($dlzemail != '')
  5518. {
  5519. $where .= " and dlzemail = '$dlzemail'";
  5520. }
  5521. if(empty($page))
  5522. {
  5523. $start = 0;
  5524. $perpage = 1;
  5525. }
  5526. else
  5527. {
  5528. $start = ($page - 1)*$perpage;
  5529. }
  5530. //取得信息列表
  5531. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,country,library,librarytime,express,waybill,dlzemail,dlzemailtime',$order_str,$start,$perpage);
  5532. //格式化数据
  5533. foreach ($info_list as $key=>$value)
  5534. {
  5535. $shop = $this->shop->read($value['shop']);
  5536. $info_list[$key]['shop'] = $shop['shopname'];
  5537. $country = $this->country->read($value['country']);
  5538. $info_list[$key]['country'] = $country['name'];
  5539. //$state = $this->typeclass->read($value['state']);
  5540. //$info_list[$key]['state'] = $state['title'];
  5541. if($value['library'] == 1)
  5542. {
  5543. $info_list[$key]['library'] = "未出库";
  5544. }
  5545. else if($value['library'] == 2)
  5546. {
  5547. $info_list[$key]['library'] = "已出库";
  5548. }
  5549. else if($value['library'] == 3)
  5550. {
  5551. $info_list[$key]['library'] = "已退库";
  5552. }
  5553. if($value['librarytime'] == '0')
  5554. {
  5555. $info_list[$key]['librarytime'] = '无';
  5556. }
  5557. else
  5558. {
  5559. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']);
  5560. }
  5561. $express = $this->express->read($value['express']);
  5562. $info_list[$key]['express'] = $express['servicename'];
  5563. if($value['dlzemail'] == '1')
  5564. {
  5565. $info_list[$key]['dlzemail'] = '发送成功';
  5566. }
  5567. else if ($value['dlzemail'] == '2')
  5568. {
  5569. $info_list[$key]['dlzemail'] = '发送失败';
  5570. }
  5571. else
  5572. {
  5573. $info_list[$key]['dlzemail'] = '';
  5574. }
  5575. $info_list[$key]['dlzemailtime'] = ($value['dlzemailtime']>0)?date('Y-m-d H:i:s',$value['dlzemailtime']):'';
  5576. }
  5577. $total = $this->fullorder->find_count($where);
  5578. $pagenum = ceil($total/$perpage);
  5579. $over = $total-($start+$perpage);
  5580. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5581. echo json_encode($rows);exit;
  5582. }
  5583. $notice = $this->notice->find_all("type = '2' and (".rtrim($fgshop,'or').")");
  5584. $this->data['notice'] = $notice;
  5585. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  5586. $this->data['wlshop'] = $wlshop;
  5587. $this->data['express'] = $this->express->find_all();
  5588. $this->_Template('fullorder_waybillemail',$this->data);
  5589. }
  5590. public function _khdd()
  5591. {
  5592. $dt = 0;$fgshop = "shop = 0";$sid = 'id = 0';
  5593. if(isset($_SESSION['api']))
  5594. {
  5595. $user = $this->user->get_api($_SESSION['api']);
  5596. $usp = $user;
  5597. $fgshop = "";$sid = "";
  5598. $usersp = explode('|',trim($user['shop'],'|'));
  5599. foreach ($usersp as $value)
  5600. {
  5601. $fgshop .= " shop = ".$value." or";
  5602. $sid .= " id = ".$value." or";
  5603. }
  5604. if($user['vip'] == 1)
  5605. {
  5606. $vip = 1;
  5607. }
  5608. else
  5609. {
  5610. $vip = 0;
  5611. }
  5612. }
  5613. $post = $this->input->post(NULL, TRUE);
  5614. if(isset($_GET['excel']))
  5615. {
  5616. $page = $this->input->get('page',true);
  5617. $perpage = $this->input->get('perpage',true);
  5618. $warehouse = $this->input->get('warehouse',true);
  5619. $timetk = $this->input->get('timetk',true);
  5620. $timetj = $this->input->get('timetj',true);
  5621. $shop = $this->input->get('shop',true);
  5622. $source = $this->input->get('source',true);
  5623. $state = $this->input->get('state',true);
  5624. $review = $this->input->get('review',true);
  5625. $type = $this->input->get('type',true);
  5626. $express = $this->input->get('express',true);
  5627. $orderinfo = $this->input->get('orderinfo',true);
  5628. $user = $this->input->get('user',true);
  5629. $client = $this->input->get('name',true);
  5630. $waybill = $this->input->get('waybill',true);
  5631. $number = $this->input->get('number',true);
  5632. $email = $this->input->get('email',true);
  5633. $phone = $this->input->get('phone',true);
  5634. $dlz = $this->input->get('dlz',true);
  5635. $print = $this->input->get('print',true);
  5636. $library = $this->input->get('library',true);
  5637. $js = $this->input->get('js',true);
  5638. $exstate = $this->input->get('exstate',true);
  5639. $xztime = $this->input->get('xztime',true);
  5640. $libraryconfirm = $this->input->get('libraryconfirm',true);
  5641. $timetk = strtotime($timetk);
  5642. $timetj = strtotime($timetj);
  5643. $plorder = $this->input->get('pl',true);
  5644. $paypal = $this->input->get('paypal',true);
  5645. $zf = $this->input->get('zf',true);
  5646. $pay = $this->input->get('pay',true);
  5647. $excel = $this->input->get('excel',true);
  5648. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5649. if($warehouse)
  5650. {
  5651. $where .= " and type = '$warehouse'";
  5652. }
  5653. if($timetk && $timetj)
  5654. {
  5655. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5656. }
  5657. if($shop)
  5658. {
  5659. $where .= " and shop = '$shop'";
  5660. }
  5661. if($source)
  5662. {
  5663. if($source == '2d')
  5664. {
  5665. $where .= " and source >= '2'";
  5666. }
  5667. else
  5668. {
  5669. $where .= " and source = '$source'";
  5670. }
  5671. }
  5672. if($state)
  5673. {
  5674. $where .= " and state = '$state'";
  5675. }
  5676. if($review)
  5677. {
  5678. $where .= " and review = '$review'";
  5679. }
  5680. if($type)
  5681. {
  5682. $where .= " and type = '$type'";
  5683. }
  5684. if($express)
  5685. {
  5686. $where .= " and express = '$express'";
  5687. }
  5688. if($orderinfo)
  5689. {
  5690. $where .= " and orderinfo = '$orderinfo'";
  5691. }
  5692. if($user)
  5693. {
  5694. $where .= " and user = '$user'";
  5695. }
  5696. if($client)
  5697. {
  5698. $where .= " and client like '%$client%'";
  5699. }
  5700. if($waybill)
  5701. {
  5702. $where .= " and waybill = '$waybill'";
  5703. }
  5704. if($number)
  5705. {
  5706. $where .= " and number = '$number'";
  5707. }
  5708. if($email)
  5709. {
  5710. $where .= " and email = '$email'";
  5711. }
  5712. if($phone)
  5713. {
  5714. $where .= " and phone like '%$phone%'";
  5715. }
  5716. if($library)
  5717. {
  5718. $where .= " and library = '$library'";
  5719. }
  5720. if($print)
  5721. {
  5722. $where .= " and print = '$print'";
  5723. }
  5724. if($dlz != '')
  5725. {
  5726. $where .= " and dlz = '$dlz'";
  5727. }
  5728. if($js)
  5729. {
  5730. $where .= " and js = '$js'";
  5731. }
  5732. if($exstate)
  5733. {
  5734. $where .= " and exstate = '$exstate'";
  5735. }
  5736. if($libraryconfirm)
  5737. {
  5738. $where .= " and libraryconfirm = '$libraryconfirm'";
  5739. }
  5740. if($paypal)
  5741. {
  5742. $where .= " and paypal = '$paypal'";
  5743. }
  5744. if($pay)
  5745. {
  5746. $where .= " and pay = '$pay'";
  5747. }
  5748. if($zf)
  5749. {
  5750. if($zf == 1)
  5751. {
  5752. $where .= " and paypal not like '%-%-%-%'";
  5753. }
  5754. else
  5755. {
  5756. $where .= " and paypal like '%-%-%-%'";
  5757. }
  5758. }
  5759. if($plorder)
  5760. {
  5761. $plorderinfo = '';$plnumber = '';$pln = 0;
  5762. $plorder = explode(',',trim($plorder,','));
  5763. foreach ($plorder as $value)
  5764. {
  5765. if(is_numeric($value))
  5766. {
  5767. $plorderinfo .= " orderinfo = ".$value." or";
  5768. }
  5769. else if($value != '')
  5770. {
  5771. $plorderinfo .= " number = '".$value."' or";
  5772. }
  5773. }
  5774. if($pln > 0)
  5775. {
  5776. $where .= " and (".rtrim($plorderinfo,'or').") and (".rtrim($plnumber,'or').")";
  5777. }
  5778. else
  5779. {
  5780. $where .= " and (".rtrim($plorderinfo,'or').")";
  5781. }
  5782. }
  5783. //数据排序
  5784. $order_str = "dtime desc";
  5785. if(empty($page))
  5786. {
  5787. $start = 0;
  5788. $perpage = 1;
  5789. }
  5790. else
  5791. {
  5792. $start = ($page - 1)*$perpage;
  5793. }
  5794. if($excel == '1')
  5795. {
  5796. $shop = array();
  5797. $shopdata = $this->shop->find_all("type = '269'");
  5798. foreach ($shopdata as $v)
  5799. {
  5800. $shop[$v['id']] = array('t'=>$v['brandname'],'z'=>0,'l'=>0,'x'=>0);//店铺名称,总客户,老客户,新客户
  5801. }
  5802. $oldnumber = 0;$newnumber = 0;
  5803. $info_list = $this->db->query('select distinct shop,email from crowd_fullorder where '.$where)->result_array();
  5804. foreach ($info_list as $key=>$v)
  5805. {
  5806. $shop[$v['shop']]['z'] += 1;
  5807. $num = $this->fullorder->find_count("email = '".$v['email']."' and shop = '".$v['shop']."' and ".$xztime." < '$timetj'");
  5808. if($num > 1)
  5809. {
  5810. $shop[$v['shop']]['l'] += 1;
  5811. }
  5812. else
  5813. {
  5814. $shop[$v['shop']]['x'] += 1;
  5815. }
  5816. if(isset($v['email']) && $usp['excelpass'] == '1')
  5817. {
  5818. $emailpass = $this->setting->get_excelpass($v['email']);
  5819. $info_list[$key]['email'] = $emailpass;
  5820. }
  5821. }
  5822. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5823. $titlename = "<table border=1>
  5824. <tr>
  5825. <td>店铺</td>
  5826. <td>客户数</td>
  5827. <td>老客户数</td>
  5828. <td>新客户数</td>
  5829. </tr>
  5830. </table>";
  5831. $filename = $title.".xls";
  5832. $tail = "\n";
  5833. $this->excel->get_fz2($shop,$titlename,$filename,$tail);
  5834. }
  5835. else if($excel == '2' || $excel == '3')
  5836. {
  5837. $kh = array();
  5838. $info_list = $this->db->query('select distinct shop,email from crowd_fullorder where email != "" and '.$where)->result_array();
  5839. foreach ($info_list as $key=>$v)
  5840. {
  5841. $k = $this->fullorder->find_all("shop = '".$v['shop']."' and email = '".$v['email']."' and ".$xztime." < '$timetj'",'name,email,dtime,shouldmoney','dtime desc');
  5842. if($excel == 2 && count($k) > 1)
  5843. {
  5844. $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')));
  5845. }
  5846. if($excel == 3 && count($k) < 2)
  5847. {
  5848. $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')));
  5849. }
  5850. if(isset($v['email']) && $usp['excelpass'] == '1')
  5851. {
  5852. $emailpass = $this->setting->get_excelpass($v['email']);
  5853. $info_list[$key]['email'] = $emailpass;
  5854. }
  5855. }
  5856. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5857. $titlename = "<table border=1>
  5858. <tr>
  5859. <td>名称</td>
  5860. <td>邮箱</td>
  5861. <td>最后购买时间</td>
  5862. <td>购买次数</td>
  5863. <td>购买总额</td>
  5864. </tr>
  5865. </table>";
  5866. $filename = $title.".xls";
  5867. $tail = "\n";
  5868. $this->excel->get_fz2($kh,$titlename,$filename,$tail);
  5869. }
  5870. else if($excel == '4' || $excel == '5')
  5871. {
  5872. $kh = array();
  5873. $info_list = $this->db->query('select distinct shop,email from crowd_fullorder where email != "" and '.$where)->result_array();
  5874. foreach ($info_list as $key=>$value)
  5875. {
  5876. $k = $this->fullorder->find_all("shop = '".$value['shop']."' and email = '".$value['email']."' and ".$xztime." < '$timetj'",'orderinfo,state,product,name,email,dtime,shouldmoney','dtime desc');
  5877. if($excel == 4 && count($k) > 1)
  5878. {
  5879. foreach ($k as $v)
  5880. {
  5881. $typeclass = $this->typeclass->read($v['state']);
  5882. $kh[] = array($v['orderinfo'],$typeclass['spare'],$v['product'],$v['name'],$v['email'],date("Y-m-d H:i:s",$v['dtime']),$v['shouldmoney']);
  5883. }
  5884. }
  5885. if($excel == 5 && count($k) < 2)
  5886. {
  5887. if(!isset($k[0]['state']))
  5888. {
  5889. $typeclass = $k[0]['state'].'-数据字典无此信息';
  5890. }
  5891. else
  5892. {
  5893. $typeclass = $this->typeclass->read($k[0]['state']);
  5894. }
  5895. $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']);
  5896. }
  5897. if(isset($value['email']) && $usp['excelpass'] == '1')
  5898. {
  5899. $emailpass = $this->setting->get_excelpass($value['email']);
  5900. $info_list[$key]['email'] = $emailpass;
  5901. }
  5902. }
  5903. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5904. $titlename = "<table border=1>
  5905. <tr>
  5906. <td>订单号</td>
  5907. <td>订单状态</td>
  5908. <td>产品名</td>
  5909. <td>客户名</td>
  5910. <td>客户邮箱</td>
  5911. <td>下单时间</td>
  5912. <td>订单金额</td>
  5913. </tr>
  5914. </table>";
  5915. $filename = $title.".xls";
  5916. $tail = "\n";
  5917. $this->excel->get_fz2($kh,$titlename,$filename,$tail);
  5918. }
  5919. }
  5920. }
  5921. public function _klarnadata()
  5922. {
  5923. $post = $this->input->post(NULL, TRUE);
  5924. if(isset($post['number']))
  5925. {
  5926. $number = $this->input->post('number',true);
  5927. $data = $this->fullorder->get_number($number);
  5928. $shop = $this->shop->read($data['shop']);
  5929. $f = '';
  5930. if($data['pay'] == '23')
  5931. {
  5932. $url = 'https://api-na.klarna.com/ordermanagement/v1/orders/'.$data['paypal'];
  5933. $header[] = "Content-Type:application/json";
  5934. $header[] = "Authorization: Basic ".base64_encode($shop['klarnaname'].":".$shop['klarnapass']);
  5935. $ch = curl_init();
  5936. curl_setopt($ch, CURLOPT_URL, $url);
  5937. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  5938. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  5939. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  5940. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  5941. $res = curl_exec($ch);
  5942. curl_close($ch);
  5943. $res = json_decode($res,true);
  5944. if(isset($res['fraud_status']) && $shop['klarnaname'] != '')
  5945. {
  5946. $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'];
  5947. }
  5948. }
  5949. else if(($data['pay'] == '22' || $data['pay'] == '7') && $shop['paypalname'] != '')
  5950. {
  5951. $f = $this->paypal->data($data['paypal'],$shop);
  5952. }
  5953. else if(($data['pay'] == '26') && $shop['afterpayname'] != '')
  5954. {
  5955. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$data['paypal'];
  5956. $header[] = "Accept:application/json";
  5957. $header[] = "User-Agent: Readme.io API Simulator'";
  5958. $header[] = "Authorization: Basic ".base64_encode($shop['afterpayname'].":".$shop['afterpaypass']);
  5959. $ch = curl_init();
  5960. curl_setopt($ch, CURLOPT_URL, $url);
  5961. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  5962. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  5963. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  5964. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  5965. $res = curl_exec($ch);
  5966. curl_close($ch);
  5967. $res = json_decode($res,true);
  5968. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  5969. {
  5970. $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'];
  5971. $f = str_replace(',,',',',$f);
  5972. }
  5973. }
  5974. else if(($data['pay'] == '27') && $shop['clearpayname'] != '')
  5975. {
  5976. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$data['paypal'];
  5977. $header[] = "Accept:application/json";
  5978. $header[] = "User-Agent: Readme.io API Simulator'";
  5979. $header[] = "Authorization: Basic ".base64_encode($shop['clearpayname'].":".$shop['clearpaypass']);
  5980. $ch = curl_init();
  5981. curl_setopt($ch, CURLOPT_URL, $url);
  5982. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  5983. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  5984. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  5985. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  5986. $res = curl_exec($ch);
  5987. curl_close($ch);
  5988. $res = json_decode($res,true);
  5989. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  5990. {
  5991. $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'];
  5992. $f = str_replace(',,',',',$f);
  5993. }
  5994. }
  5995. else if($data['pay'] == '1211')
  5996. {
  5997. $url = 'https://api.stripe.com/v1/payment_intents/'.$data['paypal'];
  5998. $header[] = "Authorization:Bearer ".$shop['stripe'];
  5999. $ch = curl_init();
  6000. curl_setopt($ch, CURLOPT_URL, $url);
  6001. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  6002. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  6003. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  6004. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  6005. $res = curl_exec($ch);
  6006. curl_close($ch);
  6007. $res = json_decode($res,true);
  6008. $f = '';
  6009. if(isset($res['shipping']['name']))
  6010. {
  6011. $line = ($res['shipping']['address']['line2'] != '')?$res['shipping']['address']['line1'].' '.$res['shipping']['address']['line2']:$res['shipping']['address']['line1'];
  6012. $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));
  6013. }
  6014. }
  6015. else
  6016. {
  6017. echo json_encode(array('msg'=>'此店铺没有对接信息','success'=>false));exit;
  6018. }
  6019. if($f != '')
  6020. {
  6021. if($this->fullorder->save(array('klarnadata'=>$f),$data['id']))
  6022. {
  6023. echo json_encode(array('msg'=>'获取成功,请关闭此页重新打开','success'=>true));exit;
  6024. }
  6025. else
  6026. {
  6027. echo json_encode(array('msg'=>'写入失败,请重试','success'=>false));exit;
  6028. }
  6029. }
  6030. else
  6031. {
  6032. echo json_encode(array('msg'=>'获取失败,请稍后重试','cl'=>base64_encode($shop['afterpayname'].":".$shop['afterpaypass']),'a'=>$data['paypal'],'success'=>false));exit;
  6033. }
  6034. }
  6035. }
  6036. public function _kcyz($warehouse,$whlabel,$id,$shop,$number)
  6037. {
  6038. if(!$whlabel || $whlabel == '|')
  6039. {
  6040. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  6041. }
  6042. $w = $this->warehouse->read($warehouse);
  6043. if($w['zd'] != 1)
  6044. {
  6045. return 1;
  6046. }
  6047. $pp = explode('|',trim($whlabel,'|'));
  6048. $x = 0;$save = array();
  6049. foreach ($pp as $va)
  6050. {
  6051. $num = explode('-',$va);
  6052. if($number)
  6053. {
  6054. $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 = '')");//通用
  6055. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  6056. }
  6057. else
  6058. {
  6059. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  6060. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  6061. }
  6062. $x++;
  6063. if(count($whlabel)+count($shopwhlabel) < $num[1])
  6064. {
  6065. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  6066. }
  6067. }
  6068. return $save;
  6069. }
  6070. public function _epod()
  6071. {
  6072. $post = $this->input->post(NULL, TRUE);
  6073. if(isset($post['number']))
  6074. {
  6075. $number = $this->input->post('number',true);
  6076. $data = $this->fullorder->get_number($number);
  6077. if(is_file('./data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf'))
  6078. {
  6079. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].'/data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf','success'=>true));exit;
  6080. }
  6081. else
  6082. {
  6083. $epod = $this->dhl->get_epod($data);
  6084. if($epod['c'] == 1)
  6085. {
  6086. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].$epod['d'],'success'=>true));exit;
  6087. }
  6088. else
  6089. {
  6090. echo json_encode(array('msg'=>$epod['d'],'success'=>false));exit;
  6091. }
  6092. }
  6093. }
  6094. }
  6095. public function _zw($arg_array)
  6096. {
  6097. $arg_array = $arg_array[0];$fpdata = array();
  6098. $fullorder = $this->fullorder->read($arg_array);
  6099. $fullorder['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$fullorder['shipremarks']);
  6100. $fullorder['parameter'] = str_replace(",","---",$fullorder['parameter']);
  6101. $this->data['fullorder'] = $fullorder;
  6102. $this->data['countrys'] = $this->country->find_all();
  6103. $this->data['express'] = $this->express->find_all();
  6104. $warehouse = $this->warehouse->read($fullorder['type']);
  6105. if(stripos($fullorder['fpdata'],';') !== false)
  6106. {
  6107. $fpdata = explode(';',rtrim($fullorder['fpdata'],';'));
  6108. foreach ($fpdata as $k=>$v)
  6109. {
  6110. $xxv = explode('|',$v);
  6111. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  6112. {
  6113. $xxv['zd'] = "<p>已占单</p>";
  6114. $bdck = $warehouse['bdck'];
  6115. if(stripos($xxv[9],'~') !== false)
  6116. {
  6117. $dxxv = explode('~',trim($xxv[9],'~'));
  6118. foreach ($dxxv as $val)
  6119. {
  6120. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  6121. if($wzid['details'] != '')
  6122. {
  6123. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  6124. }
  6125. }
  6126. }
  6127. else
  6128. {
  6129. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  6130. if($wzid['details'] != '')
  6131. {
  6132. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  6133. }
  6134. }
  6135. }
  6136. $fpdata[$k] = $xxv;
  6137. }
  6138. }
  6139. $this->data['fpdata'] = $fpdata;
  6140. $this->data['fpdata'] = $fpdata;
  6141. $thfpdataxs = array();
  6142. if($fullorder['thfpdata'] != '')
  6143. {
  6144. $thfpdata = explode(';',trim($fullorder['thfpdata'],';'));
  6145. foreach ($thfpdata as $k=>$v)
  6146. {
  6147. $thxs = explode('~',trim($v,'~'));
  6148. $thxs[0] = explode('|',trim($thxs[0],'|'));
  6149. $thxs[1] = explode('|',trim($thxs[1],'|'));
  6150. $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]);
  6151. }
  6152. }
  6153. $this->data['thfpdata'] = $thfpdataxs;
  6154. $shop = $this->shop->read($fullorder['shop']);
  6155. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  6156. $is = 0;
  6157. if($shop['type'] == 269 || $shop['type'] == 2678)//判断是否独立站,269是独立站
  6158. {
  6159. $is = 1;
  6160. }
  6161. $this->data['is'] = $is;
  6162. //单项开始
  6163. $warehouse = $this->warehouse->read($fullorder['warehouse']);//发货仓库
  6164. $state = $this->typeclass->read($fullorder['state']);//订单状态
  6165. $country = $this->country->read($fullorder['country']);//国家
  6166. if($fullorder['capital'] == 1)
  6167. {
  6168. $capital = '暂未支付';
  6169. }
  6170. else if($fullorder['capital'] == 2)
  6171. {
  6172. $capital = '部分支付';
  6173. }
  6174. else if($fullorder['capital'] == 3)
  6175. {
  6176. $capital = '全部支付';
  6177. }
  6178. if($fullorder['printtype'] == 1)
  6179. {
  6180. $printtype = '运单';
  6181. }
  6182. else if($fullorder['printtype'] == 2)
  6183. {
  6184. $printtype = '发货单';
  6185. }
  6186. else if($fullorder['printtype'] == 3)
  6187. {
  6188. $printtype = '不打印单据';
  6189. }
  6190. else
  6191. {
  6192. $printtype = '未选择';
  6193. }
  6194. $this->data['warehouse'] = $warehouse['title'];
  6195. $this->data['state'] = $state['title'];
  6196. $this->data['capital'] = $capital;
  6197. $this->data['country'] = $country['name'];
  6198. $this->data['printtype'] = $printtype;
  6199. //单项结束
  6200. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  6201. $downwaybill = '';$dwls = array();
  6202. $oldwaybill = explode('-',ltrim($fullorder['oldwaybill'],'-'));
  6203. if(isset($oldwaybill[0][1]))
  6204. {
  6205. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  6206. foreach ($oldwaybill as $v)
  6207. {
  6208. $dw = explode('/',$v);
  6209. if(isset($dw[1]))
  6210. {
  6211. if(stripos($downwaybill,$dw[1]) === false)
  6212. {
  6213. $dwls[$dw[1]] = 1;
  6214. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  6215. }
  6216. }
  6217. }
  6218. }
  6219. if($fullorder['printtype'] == 1)
  6220. {
  6221. if($fullorder['waybill'] != '' && !isset($dwls[$fullorder['waybill']]))
  6222. {
  6223. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullorder['printtime']).'/y-'.$fullorder['waybill'].'.pdf" target="_blank">'.$fullorder['waybill'].'</a>、'.$downwaybill;
  6224. }
  6225. }
  6226. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  6227. /** 历史打印时间 **/
  6228. $printtime = '';
  6229. if($fullorder['oldprinttime'])
  6230. {
  6231. $pte = explode('-',rtrim($fullorder['oldprinttime'],'-'));
  6232. foreach ($pte as $v)
  6233. {
  6234. $printtime .= date('Y-m-d H:i:s',$v).'、';
  6235. }
  6236. }
  6237. $this->data['printtime'] = rtrim($printtime,'、');
  6238. $product = '';
  6239. $fullorder['product'] = str_replace("'","",$fullorder['product']);
  6240. if($fullorder['link'] != '' && $fullorder['source'] != '1')
  6241. {
  6242. $pt = explode(',',$fullorder['product']);
  6243. $lk = explode(',',$fullorder['link']);
  6244. for($i=0;$i<count($pt);$i++)
  6245. {
  6246. if(isset($lk[$i]))
  6247. {
  6248. $octs = $this->colourorderts->get_texturl($pt[$i],$lk[$i]);
  6249. }
  6250. else
  6251. {
  6252. $octs = '';
  6253. }
  6254. $a = $octs?'<font style="color:#'.$octs['colour'].'">'.$pt[$i].'</font>':$pt[$i];
  6255. //$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];
  6256. if(isset($lk[$i]))
  6257. {
  6258. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  6259. }
  6260. else
  6261. {
  6262. $product .= ($product != '')?' , '.$a:$a;
  6263. }
  6264. }
  6265. }
  6266. else
  6267. {
  6268. $octs = $this->colourorderts->get_text($fullorder['product']);
  6269. $a = $octs?'<font style="color:#F39">'.$fullorder['product'].'</font>':$fullorder['product'];
  6270. //$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'];
  6271. $product = $a;
  6272. }
  6273. $this->data['product'] = $product;
  6274. $out = $this->systemtransfer->find_all("number = '".$fullorder['number']."'");
  6275. $outread = '';
  6276. if($out)
  6277. {
  6278. foreach ($out as $val)
  6279. {
  6280. $list = '';
  6281. $rk = explode('|',trim($val['rk'],'|'));
  6282. $rktime = explode('|',trim($val['rktime'],'|'));
  6283. $zw = array();
  6284. $t = $this->transfer->find_all("1=1");
  6285. foreach ($t as $v)
  6286. {
  6287. $zw[$v['id']] = $v['title'];
  6288. }
  6289. if($val['rk'] != '' && count($rk) > 0)
  6290. {
  6291. for($i=0;$i<count($rk);$i++)
  6292. {
  6293. if(!isset($rktime[$i]))
  6294. {
  6295. $list .= $zw[$cz[$i]];
  6296. }
  6297. else
  6298. {
  6299. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  6300. }
  6301. }
  6302. }
  6303. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  6304. }
  6305. }
  6306. else
  6307. {
  6308. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullorder['number']."'");
  6309. $outread = array();
  6310. if($systemwigsout)
  6311. {
  6312. foreach ($systemwigsout as $v)
  6313. {
  6314. if($v['czwarehouse'] == 37)
  6315. {
  6316. $outread[] = '华荣厂';
  6317. }
  6318. else if($v['czwarehouse'] == 0)
  6319. {
  6320. $outread[] = '龙盈厂';
  6321. }
  6322. $cz = explode('|',trim($v['cz'],'|'));
  6323. $cztime = explode('|',trim($v['cztime'],'|'));
  6324. $zw = $this->transfer->get_list();
  6325. if($v['cz'] != '' && count($cz) > 0)
  6326. {
  6327. for($i=0;$i<count($cz);$i++)
  6328. {
  6329. if(!isset($cztime[$i]))
  6330. {
  6331. $outread[] = $zw[$cz[$i]].' -&gt; ';
  6332. }
  6333. else
  6334. {
  6335. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  6336. }
  6337. }
  6338. $outread[] = '<br>';
  6339. }
  6340. }
  6341. }
  6342. }
  6343. $klarnacolor = '';
  6344. if($fullorder['klarnadata'] !='')
  6345. {
  6346. $klarnadata = explode('|',$fullorder['klarnadata']);
  6347. if($klarnadata[0] == 'paypal' || $klarnadata[0] == 'stripe')
  6348. {
  6349. $klarnadata[1] = json_decode($klarnadata[1],true);
  6350. if($klarnadata[0] == 'stripe' && $klarnadata[1]['shouldmoney'] != $fullorder['shouldmoney'] && $fullorder['pay'] == 1211)
  6351. {
  6352. $klarnacolor = 'style="color:#F00"';
  6353. }
  6354. }
  6355. else if($klarnadata[0]!=1 && $fullorder['pay']!=26 && $fullorder['pay']!=27 && $fullorder['pay']!=1211)
  6356. {
  6357. $klarnacolor = 'style="color:#F00"';
  6358. }
  6359. if($fullorder['pay'] == 23)//klarna
  6360. {
  6361. $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');
  6362. $ToState = array_flip($ToState);
  6363. $klarnadata3 = str_replace(' ','',$klarnadata[3]);
  6364. $city = str_replace(' ','',$fullorder['city']);
  6365. $klarnadataaddress = explode($city,$klarnadata3);
  6366. if(isset($klarnadataaddress[1]))
  6367. {
  6368. $klarnadata3 = $city.$klarnadataaddress[1];
  6369. $klarnadatacolor = explode(',',$klarnadata3);
  6370. unset($klarnadatacolor[4]);
  6371. unset($klarnadatacolor[6]);
  6372. if(isset($ToState[$klarnadatacolor[1]]))
  6373. {
  6374. $klarnadatacolor[1] = ucwords($ToState[$klarnadatacolor[1]]);
  6375. }
  6376. $klarnadata['color'] = $klarnadataaddress[0].implode(",",$klarnadatacolor);
  6377. }
  6378. else
  6379. {
  6380. $klarnadata['color'] = $klarnadata3;
  6381. }
  6382. }
  6383. }
  6384. else
  6385. {
  6386. $klarnadata = '';
  6387. }
  6388. $p = explode('-',$fullorder['paypal']);
  6389. $this->data['klarnacolor'] = $klarnacolor;
  6390. $this->data['klarnadata'] = $klarnadata;
  6391. $this->data['systemwigsout'] = $outread;
  6392. $this->_Template('fullorder_zw',$this->data);
  6393. }
  6394. public function _dcdxyz()
  6395. {
  6396. $post = $this->input->get(NULL, TRUE);
  6397. if(isset($post['timetk']))
  6398. {
  6399. $timetk = $this->input->get('timetk',true);
  6400. $timetj = $this->input->get('timetj',true);
  6401. $timetk = strtotime($timetk);
  6402. $timetj = strtotime($timetj);
  6403. $where = "oldwaybill != ''";
  6404. if($timetk && $timetj)
  6405. {
  6406. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  6407. }
  6408. //数据排序
  6409. $order_str = "dtime desc";
  6410. //取得信息列表
  6411. $info_list = $this->fullorder->find_all($where,'orderinfo,number,oldwaybill',$order_str);
  6412. $data = array();
  6413. foreach ($info_list as $key=>$value)
  6414. {
  6415. $ob = '';
  6416. $oldwaybill = explode('-',trim($value['oldwaybill'],'-'));
  6417. if(count($oldwaybill) < 2)
  6418. {
  6419. continue;
  6420. }
  6421. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  6422. foreach ($oldwaybill as $v)
  6423. {
  6424. $dw = explode('/',$v);
  6425. if(isset($dw[1]))
  6426. {
  6427. $dwls[$dw[1]] = 1;
  6428. $ob .= $dw[1].'、';
  6429. }
  6430. }
  6431. $info_list[$key]['oldwaybill'] = trim($ob,'、');
  6432. $data[] = $info_list[$key];
  6433. }
  6434. $title = "多运单信息 ".date("Y-m-d");
  6435. $titlename = "<table border=1>
  6436. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  6437. <tr>
  6438. <td>订单号</td>
  6439. <td>编号</td>
  6440. <td>运单号</td>
  6441. </tr>
  6442. </table>";
  6443. $filename = $title.".xls";
  6444. $tail = "\n";
  6445. $this->excel->get_fz2($data,$titlename,$filename,$tail);
  6446. }
  6447. }
  6448. public function _thxz()
  6449. {
  6450. $post = $this->input->get(NULL, TRUE);
  6451. if(isset($post['timetk']))
  6452. {
  6453. $timetk = $this->input->get('timetk',true);
  6454. $timetj = $this->input->get('timetj',true);
  6455. $timetk = strtotime($timetk);
  6456. $timetj = strtotime($timetj);
  6457. $where = "returndata != ''";
  6458. if($timetk && $timetj)
  6459. {
  6460. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  6461. }
  6462. //数据排序
  6463. $order_str = "dtime desc";
  6464. //取得信息列表
  6465. $info_list = $this->fullorder->find_all($where,'orderinfo,number,returndata',$order_str);
  6466. foreach ($info_list as $key=>$value)
  6467. {
  6468. $ydh = explode('">',$value['returndata']);
  6469. $ydh = explode('</a>',$ydh[1]);
  6470. $info_list[$key]['returndata'] = $ydh[0];
  6471. $time = explode('pdf/',$value['returndata']);
  6472. $time = explode('/',$time[1]);
  6473. $info_list[$key]['time'] = $time[0];
  6474. }
  6475. $title = "退货订单信息 ".date("Y-m-d");
  6476. $titlename = "<table border=1>
  6477. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  6478. <tr>
  6479. <td>订单号</td>
  6480. <td>编号</td>
  6481. <td>退货运单号</td>
  6482. <td>退货时间</td>
  6483. </tr>
  6484. </table>";
  6485. $filename = $title.".xls";
  6486. $tail = "\n";
  6487. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  6488. }
  6489. }
  6490. public function _ddcf()
  6491. {
  6492. $post = $this->input->post(NULL, TRUE);
  6493. if(isset($post['number']))
  6494. {
  6495. $number = $this->input->post('number',true);
  6496. $data = $this->fullorder->get_number($number);
  6497. if(!$data)
  6498. {
  6499. echo json_encode(array('msg'=>'没有找到此订单','success'=>false));exit;
  6500. }
  6501. if($data['review'] != 1 && $data['review'] != 2)
  6502. {
  6503. echo json_encode(array('msg'=>'必须是 待审核 状态才能拆分','success'=>false));exit;
  6504. }
  6505. if($data['merge'] != 0)
  6506. {
  6507. echo json_encode(array('msg'=>'已合并的订单无法使用此拆分功能','success'=>false));exit;
  6508. }
  6509. $cfnum = explode('-',trim($number,'-'));
  6510. // if((count($cfnum) > 3 && stripos($number,'-PF-') === false))
  6511. // {
  6512. // echo json_encode(array('msg'=>'只能在原单操作拆分','success'=>false));exit;
  6513. // }
  6514. if(count($cfnum) > 4 && stripos($number,'-PF-') !== false)
  6515. {
  6516. echo json_encode(array('msg'=>'只能在原单操作拆分','success'=>false));exit;
  6517. }
  6518. $num = $this->fullorder->find_count("number like '".$number."%'");
  6519. $data['number'] = $data['number'].'-'.$num;
  6520. $data['orderinfo'] = $data['shop'].date('ymdHis',time()).rand(0,1);;
  6521. $data['shouldmoney'] = 0;
  6522. $data['budget'] = 0;
  6523. $data['shipremarks'] = '';
  6524. $data['source'] = 1;
  6525. //$data['review'] = 2;
  6526. $data['extra_status'] = 1;//拆分的订单
  6527. unset($data['id']);
  6528. unset($data['jweight']);
  6529. unset($data['fpcount']);
  6530. unset($data['returndata']);
  6531. unset($data['waybill']);
  6532. unset($data['oldwaybill']);
  6533. unset($data['printtime']);
  6534. if($this->fullorder->insert($data))
  6535. {
  6536. echo json_encode(array('msg'=>'拆分成功!新订单编号:'.$data['number'],'success'=>true));exit;
  6537. }
  6538. else
  6539. {
  6540. echo json_encode(array('msg'=>'拆分失败,请重试','success'=>false));exit;
  6541. }
  6542. }
  6543. }
  6544. public function _cf() //合并订单拆分
  6545. {
  6546. $post = $this->input->post(NULL, TRUE);
  6547. if(isset($post['id']))
  6548. {
  6549. $id = $this->input->post('id',true);
  6550. $b = $this->fullorder->read($id);
  6551. $order = array();
  6552. if($b['merge'] == $b['id'])
  6553. {
  6554. $data = $this->fullorder->find_all("merge = '".$b['merge']."'");
  6555. foreach ($data as $v)
  6556. {
  6557. $a = $this->fullorderhb->get_orderinfo($v['orderinfo']);
  6558. if($a)
  6559. {
  6560. $this->fullorder->save($a,$v['id']);
  6561. }
  6562. $order[] = $v['id'];
  6563. }
  6564. echo json_encode(array('msg'=>'拆分成功!','d'=>$order,'success'=>true));exit;
  6565. }
  6566. else
  6567. {
  6568. echo json_encode(array('msg'=>'拆分条件错误!','success'=>false));exit;
  6569. }
  6570. }
  6571. }
  6572. }