Fullordersmt.php 154 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Fullordersmt extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_fullordersmt','fullordersmt');
  7. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  8. $this->load->_model('Model_shop','shop');
  9. $this->load->_model('Model_typeclass','typeclass');
  10. $this->load->_model('Model_express','express');
  11. $this->load->_model('Model_country','country');
  12. $this->load->_model('Model_productdescribe','productdescribe');
  13. $this->load->_model('Model_customs','customs');
  14. $this->load->_model('Model_detailed','detailed');
  15. $this->load->_model('Model_productdescription','productdescription');
  16. $this->load->_model('Model_logistics','logistics');
  17. $this->load->_model('Model_hl','hl');
  18. $this->load->_model('Model_excel','excel');
  19. $this->load->_model('Model_warehouse','warehouse');
  20. $this->load->_model('Model_customersmt','customersmt');
  21. $this->load->_model('Model_user','user');
  22. $this->load->_model('Model_dhl','dhl');
  23. $this->load->_model('Model_ali','ali');
  24. $this->load->_model('Model_notice','notice');
  25. $this->load->_model('Model_api','api');
  26. $this->load->_model('Model_apismt','apismt');
  27. $this->load->_model('Model_usps','usps');
  28. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  29. $this->load->_model('Model_fullordersmthb','fullordersmthb');
  30. $this->load->_model('Model_whlabel','whlabel');
  31. $this->load->_model('Model_specialstock','specialstock');
  32. $this->load->_model('Model_reset','fullreset');
  33. $this->load->_model('Model_systemwigsout','systemwigsout');
  34. $this->load->_model('Model_ck','ck');
  35. $this->load->_model('Model_weight','weight');
  36. $this->load->_model('Model_pay','pay');
  37. $this->load->_model('Model_whlabel_fc','whlabel_fc');
  38. $this->load->_model('Model_transfer','transfer');
  39. $this->load->_model('Model_systemtransfer','systemtransfer');
  40. $this->load->_model('Model_power','power');
  41. $this->load->_model('Model_setting','setting');
  42. $this->load->_model('Model_returngoods','returngoods');
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_fullordererrors","fullordererrors");
  45. $this->load->_model("Model_retreatlogs","retreatlogs");
  46. }
  47. //定义方法的调用规则 获取URI第二段值
  48. public function _remap($arg,$arg_array)
  49. {
  50. if($arg == 'add')//添加
  51. {
  52. $this->_add();
  53. }
  54. else if($arg == 'edit')//修改
  55. {
  56. $this->_edit($arg_array);
  57. }
  58. else if($arg == 'readonly')//修改
  59. {
  60. $this->_readonly($arg_array);
  61. }
  62. else if($arg == 'readlist')
  63. {
  64. $this->_readlist();
  65. }
  66. else if($arg == 'del')//修改
  67. {
  68. $this->_del();
  69. }
  70. else if($arg == 'price')//价格明细
  71. {
  72. $this->_price();
  73. }
  74. else if($arg == 'customs')
  75. {
  76. $this->_customs();
  77. }
  78. else if($arg == 'express')
  79. {
  80. $this->_express();
  81. }
  82. else if($arg == 'hl')
  83. {
  84. $this->_hl();
  85. }
  86. else if($arg == 'repeat')
  87. {
  88. $this->_repeat();
  89. }
  90. else if($arg == 'operation')
  91. {
  92. $this->_operation();
  93. }
  94. else if($arg == 'merge')
  95. {
  96. $this->_merge();
  97. }
  98. else if($arg == 'split')
  99. {
  100. $this->_split();
  101. }
  102. else if($arg == 'fmexcel')
  103. {
  104. $this->_fmexcel();
  105. }
  106. else if($arg == 'fdexcel')
  107. {
  108. $this->_fdexcel();
  109. }
  110. else if($arg == 'fdfexcel')
  111. {
  112. $this->_fdfexcel();
  113. }
  114. else if($arg == 'evaluate')
  115. {
  116. $this->_evaluate();
  117. }
  118. else if($arg == 'state')
  119. {
  120. $this->_state();
  121. }
  122. else if($arg == 'review')
  123. {
  124. $this->_review();
  125. }
  126. else if($arg == 'black')
  127. {
  128. $this->_black();
  129. }
  130. else if($arg == 'ryf')
  131. {
  132. $this->_ryf();
  133. }
  134. else if($arg == 'expresstype')
  135. {
  136. $this->_expresstype();
  137. }
  138. else if($arg == 'fsstate')
  139. {
  140. $this->_fsstate();
  141. }
  142. else if($arg == 'power')
  143. {
  144. $this->_power();
  145. }
  146. else if($arg == 'error')
  147. {
  148. $this->_error();
  149. }
  150. else if($arg == 'yzaddress')
  151. {
  152. $this->_yzaddress();
  153. }
  154. else if($arg == 'return')
  155. {
  156. $this->_return();
  157. }
  158. else if($arg == 'bcbz')
  159. {
  160. $this->_bcbz();
  161. }
  162. else if($arg == 'abc')
  163. {
  164. $this->_aaa();
  165. }
  166. else if($arg == 'b')
  167. {
  168. $this->_bbb($arg_array);
  169. }
  170. else if($arg == 'plcx')
  171. {
  172. $this->_plcx($arg_array);
  173. }
  174. else if($arg == 'cf')
  175. {
  176. $this->_cf();
  177. }
  178. else if($arg == 'epod')
  179. {
  180. $this->_epod();
  181. }
  182. else if($arg == 'ddcf')
  183. {
  184. $this->_ddcf();
  185. }
  186. else
  187. {
  188. $this->_index();
  189. }
  190. }
  191. //管理
  192. public function _index()
  193. {
  194. $dt = 0;
  195. if(isset($_SESSION['api']))
  196. {
  197. $user = $this->user->get_api($_SESSION['api']);
  198. $usp = $user;
  199. $fgshop = "";$sid = "";
  200. $user = explode('|',trim($user['shop'],'|'));
  201. foreach ($user as $value)
  202. {
  203. $fgshop .= " shop = ".$value." or";
  204. $sid .= " id = ".$value." or";
  205. }
  206. }
  207. $post = $this->input->post(NULL, TRUE);
  208. if(isset($post['page']))
  209. {
  210. $page = $this->input->post('page',true);
  211. $perpage = $this->input->post('perpage',true);
  212. $warehouse = $this->input->post('warehouse',true);
  213. $timetk = $this->input->post('timetkk',true);
  214. $timetj = $this->input->post('timetjj',true);
  215. $shop = $this->input->post('shop',true);
  216. $source = $this->input->post('source',true);
  217. $state = $this->input->post('state',true);
  218. $review = $this->input->post('review',true);
  219. $type = $this->input->post('type',true);
  220. $express = $this->input->post('express',true);
  221. $orderinfo = $this->input->post('orderinfo',true);
  222. $user = $this->input->post('user',true);
  223. $client = $this->input->post('name',true);
  224. $fullname = $this->input->post('fullname',true);
  225. $waybill = $this->input->post('waybill',true);
  226. $waybillid = $this->input->post('waybillid',true);
  227. $number = $this->input->post('number',true);
  228. $email = $this->input->post('email',true);
  229. $dlz = $this->input->post('dlz',true);
  230. $print = $this->input->post('print',true);
  231. $library = $this->input->post('library',true);
  232. $country = $this->input->post('country',true);
  233. $paypal = $this->input->post('paypal',true);
  234. $orderremarks = $this->input->post('orderremarks',true);
  235. $sku = $this->input->post('sku',true);
  236. $xztime = $this->input->post('xztime',true);
  237. $timetk = strtotime($timetk)-1;
  238. $timetj = strtotime($timetj);
  239. $px = $this->input->post('px',true);
  240. $plorder = $this->input->post('pl',true);
  241. $phone = $this->input->post('phone',true);
  242. $where = "1=1 and (".rtrim($fgshop,'or').")";
  243. if($warehouse)
  244. {
  245. $where .= " and type = '$warehouse'";
  246. }
  247. if($timetk && $timetj)
  248. {
  249. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  250. }
  251. if($shop)
  252. {
  253. $where .= " and shop = '$shop'";
  254. }
  255. if($source)
  256. {
  257. $where .= " and source = '$source'";
  258. }
  259. if($state)
  260. {
  261. $where .= " and state = '$state'";
  262. }
  263. if($review)
  264. {
  265. $where .= " and review = '$review'";
  266. }
  267. if($type)
  268. {
  269. $where .= " and type = '$type'";
  270. }
  271. if($express)
  272. {
  273. $where .= " and express = '$express'";
  274. }
  275. if($orderinfo)
  276. {
  277. $where .= " and orderinfo = '$orderinfo'";
  278. }
  279. if($user)
  280. {
  281. $where .= " and user = '$user'";
  282. }
  283. if($client)
  284. {
  285. $where .= " and client like '%$client%'";
  286. }
  287. if($waybill)
  288. {
  289. $where .= " and waybill = '$waybill'";
  290. }
  291. if($waybillid){
  292. $where .= " and waybillid like '%".$waybillid."%'";
  293. }
  294. if($number)
  295. {
  296. $where .= " and number like '$number%'";
  297. }
  298. if($email)
  299. {
  300. $where .= " and email = '$email'";
  301. }
  302. if($library)
  303. {
  304. $where .= " and library = '$library'";
  305. }
  306. if($country)
  307. {
  308. $where .= " and country = '$country'";
  309. }
  310. if($print)
  311. {
  312. $where .= " and print = '$print'";
  313. }
  314. if($paypal)
  315. {
  316. $where .= " and paypal = '$paypal'";
  317. }
  318. if($orderremarks){
  319. $where .= " and orderremarks like '%$orderremarks%'";
  320. }
  321. if($dlz != '')
  322. {
  323. $where .= " and dlz = '$dlz'";
  324. }
  325. if($sku)
  326. {
  327. $where .= " and sku like '%$sku%'";
  328. }
  329. if($fullname)
  330. {
  331. $where .= " and fullname = '$fullname'";
  332. }
  333. if($phone){
  334. $where .= " and phone like '%$phone%'";
  335. }
  336. //数据排序
  337. if($px)
  338. {
  339. $order_str = $px." desc";
  340. }
  341. else
  342. {
  343. $order_str = "numberpx desc";
  344. }
  345. if($plorder)
  346. {
  347. $plorderinfo = '';$plnumber = '';$pln = 0;
  348. $plorder = explode(',',trim($plorder,','));
  349. foreach ($plorder as $value)
  350. {
  351. if(is_numeric($value))
  352. {
  353. $plorderinfo .= " orderinfo = ".$value." or";
  354. }
  355. else if($value != '')
  356. {
  357. $plorderinfo .= " number = '".$value."' or";
  358. }
  359. }
  360. if($pln > 0)
  361. {
  362. $where .= " and (".rtrim($plorderinfo,'or').") and (".rtrim($plnumber,'or').")";
  363. }
  364. else
  365. {
  366. $where .= " and (".rtrim($plorderinfo,'or').")";
  367. }
  368. }
  369. if(empty($page))
  370. {
  371. $start = 0;
  372. $perpage = 1;
  373. }
  374. else
  375. {
  376. $start = ($page - 1)*$perpage;
  377. }
  378. //取得信息列表id,shop,type,source,user,orderinfo,number,name,state,buytime,clientremarks,review,print,library,libraryconfirm,express,waybill,orderremarks,black
  379. $info_list = $this->fullordersmt->find_all($where,'id,shop,type,orderinfo,number,fullname,state,buytime,review,libraryconfirm,express,waybill,orderremarks,library,black,clientremarks,waybillid',$order_str,$start,$perpage);
  380. //格式化数据
  381. foreach ($info_list as $key=>$value)
  382. {
  383. $ud = $this->fullordersmt->read($value['id']);
  384. $ud['address'] = str_replace("'","’",$ud['address']);
  385. $ud['name'] = str_replace("'","’",$ud['name']);
  386. //$customer = $ud['source'] != 1?$this->customersmt->get_fullname($ud['fullname']):$this->customersmt->get_shopdata($value['shop'],$ud['name'],$ud['address']);//目前只用地址和收货人判断是否老客户
  387. $customer = $this->customersmt->get_shopdata($value['shop'],$ud['name'],$ud['address']);
  388. //$a = array_column($customer, 'email'); //三维找其中健的数组
  389. //$a = array_flip($a); //键和值调换
  390. $currency = $this->country->read($ud['country']);
  391. $name = ($ud['source'] == 1)?$ud['name']:$value['fullname'];
  392. $lkh = "<p>".$name."</p><p style='color:#8f54fb'>".$currency['ename']."</p>";
  393. if($customer)
  394. {
  395. if($customer['type'] == 1 && $customer['num'] > 1)
  396. {
  397. $lkh .= "<p style='color:#FF3333'>老客户(".$customer['num'].")</p>";
  398. }
  399. else if($customer['type'] == 2)
  400. {
  401. $hmsp = $this->shop->read($customer['shop']);
  402. $lkh .= "<p style='color:#9900CC'>黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  403. }
  404. }
  405. // $info_list[$key]['fullname'] = $lkh;
  406. // $rginfo_list = $this->returngoods->find_all("email = '".$ud['email']."'");
  407. // if(!empty($rginfo_list))
  408. // {
  409. // $tmp_str = '';
  410. // foreach ($rginfo_list as $k => $v) {
  411. // $tmp_str .= $v['remark'].'<br/>';
  412. // }
  413. // $info_list[$key]['fullname'] = $info_list[$key]['sname']."<br/>售后单(".count($rginfo_list).")".'<p style="color:blue"><i class="method fa fa-list-ul" data-t="'.$tmp_str.'"></i><p>';
  414. // }
  415. $shop = $this->shop->read($value['shop']);
  416. $info_list[$key]['shop'] = $shop['shopname'];
  417. //$info_list[$key]['user'] = $shop['shopuser'];
  418. $warehouse = $this->warehouse->read($value['type']);
  419. $warehousetitle = $warehouse['title'];
  420. if($value['type'] != 13){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  421. $info_list[$key]['type'] = $warehousetitle;
  422. $typeclass = $this->typeclass->read($value['state']);
  423. if($ud['source'] != 1)
  424. {
  425. $info_list[$key]['state'] = "<a href='https://trade.aliexpress.com/order_detail.htm?orderId=".$value['orderinfo']."' target='_blank'>".$typeclass['title']."</a></br>";
  426. if($ud['overtime'] > 0 && $ud['state'] == 207)
  427. {
  428. //date_default_timezone_set("US/Pacific-New");
  429. $second = $ud['overtime']-time()+15*3600;
  430. $day = floor($second/(3600*24));
  431. $second = $second%(3600*24);//除去整天之后剩余的时间
  432. $hour = floor($second/3600);
  433. $second = $second%3600;//除去整小时之后剩余的时间
  434. $minute = floor($second/60);
  435. $second = $second%60;//除去整分钟之后剩余的时间
  436. //返回字符串
  437. $info_list[$key]['state'] .= "<p style='color:#555'>".$day." 天 ".$hour." 时 ".$minute." 分</p>";
  438. }
  439. }
  440. else
  441. {
  442. $info_list[$key]['state'] = $typeclass['title'];
  443. }
  444. if(!$value['buytime'])
  445. {
  446. $info_list[$key]['buytime'] = '<p>无</p>';
  447. }
  448. else
  449. {
  450. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']-$dt).'</p><p>'.date('H:i:s',$value['buytime']-$dt).'</p>';
  451. }
  452. if($value['review'] == 1)
  453. {
  454. $info_list[$key]['review'] = "未送审";
  455. }
  456. else if($value['review'] == 2)
  457. {
  458. $info_list[$key]['review'] = "<font style='color:#555'>待审核</font>";
  459. }
  460. else if($value['review'] == 3)
  461. {
  462. $info_list[$key]['review'] = "<font style='color:#f90f4b'>不通过</font>";
  463. }
  464. else if($value['review'] == 4)
  465. {
  466. $info_list[$key]['review'] = "取消重审";
  467. }
  468. else if($value['review'] == 5)
  469. {
  470. $info_list[$key]['review'] = "<font style='color:#2f80f9'>审核通过</font>";
  471. }
  472. else if($value['review'] == 6)
  473. {
  474. $info_list[$key]['review'] = "<font style='color:#2f80f9'>自动通过</font>";
  475. }
  476. if($ud['dlz'] == 1)
  477. {
  478. $dlz = "<p>发货声明成功</p>";
  479. }
  480. else if($ud['dlz'] == 3)
  481. {
  482. $dlz = "<p>不需要发货声明</p>";
  483. }
  484. else if($ud['dlz'] == 2)
  485. {
  486. $dlz = "<p style='color:#C3C'>发货声明失败</p>";
  487. }
  488. else
  489. {
  490. $dlz = "";
  491. }
  492. if($value['waybill'] != "")
  493. {
  494. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz;
  495. if(!empty($value['waybillid'])){
  496. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz."<p>".$value['waybillid']."</p>";
  497. }
  498. }
  499. if($value['express'] != 0)
  500. {
  501. $express = $this->express->read($value['express']);
  502. $expressservicename = $express['servicename'];
  503. if($value['express'] != 1 && $value['express'] != 63)
  504. {
  505. $expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";
  506. }
  507. else if($value['express'] == 63)
  508. {
  509. $expressservicename = "<font style='color:#a910f8'>".$express['servicename']."</font>";
  510. }
  511. $info_list[$key]['express'] = $expressservicename;
  512. }
  513. else
  514. {
  515. $info_list[$key]['express'] = "无";
  516. }
  517. $x = "";
  518. if($value['libraryconfirm'] == 2 && $value['review'] > 4 && $ud['library'] == 1)
  519. {
  520. $x = "<p class='ckn'><b class='fojz' data-type='1'>禁止发货</b></p>";
  521. }
  522. else if(($value['review'] > 4) && $ud['print'] != 1 && $value['libraryconfirm'] == 1)
  523. {
  524. $x = "<p class='ckn'><b class='fojzof' data-type='6' data-id='".$value['id']."'>允许发货</b></p>";
  525. }
  526. if(($value['review'] > 4) && $ud['print'] == 2 && ($ud['merge'] == 0 || $ud['merge'] == $ud['id']))
  527. {
  528. $x = "<p class='ckn'><b class='fojzof' data-type='7' data-id='".$value['id']."'>禁止打印</b></p>";
  529. }
  530. else if($value['review'] >4 && $ud['print'] == 1 && ($ud['merge'] == 0 || $ud['merge'] == $ud['id']))
  531. {
  532. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  533. }
  534. else if($value['review'] > 4 && $ud['print'] == 2 && $ud['merge'] != $ud['id'])
  535. {
  536. $x = "<p><b style='background-color:#999'>禁止打印</b></p>";
  537. }
  538. else if($value['review'] > 4 && $ud['print'] == 1 && $ud['merge'] != $ud['id'])
  539. {
  540. $x = "<p><b style='background-color:#999'>允许打印</b></p>";
  541. }
  542. if($value['waybill'] == "" && $value['review'] > 4)
  543. {
  544. $x .= "<p><b class='kn' data-type='2'>填写运单号</b></p>";
  545. }
  546. else if($value['waybill'] != "" && $value['review'] > 4 && $usp['vip'] == 1)
  547. {
  548. $x .= "<p><b class='kn' data-type='2'>修改运单号</b></p>";
  549. }
  550. else if($value['waybill'] != "" && $value['review'] > 4 && $value['library'] == 1 && $usp['vip'] != 1)
  551. {
  552. $x .= "<p><b class='kn' data-type='2'>修改运单号</b></p>";
  553. }
  554. 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']))
  555. {
  556. $x .= "<p><b class='focz' data-type='2' data-id='".$value['id']."'>提交审核</b></p>";
  557. }
  558. $x .= "<p><b class='window' data-h='/customersmt/edit/".$customer['id']."' data-t='客户信息 - 修改'>客户信息</b></p>";
  559. $info_list[$key]['black'] = $x;
  560. $tly = "";
  561. if($value['clientremarks'] != "")
  562. {
  563. $tly = "<p style='color:#FF3333'>有客户留言</p>";
  564. }
  565. if($value['review'] > 4 && $usp['vip'] != 1 && ($ud['merge'] == 0 || $ud['merge'] == $ud['id']))
  566. {
  567. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/readonly/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  568. }
  569. else if($ud['merge'] == 0 || $ud['merge'] == $ud['id'])
  570. {
  571. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  572. }
  573. else if($ud['merge'] != 0 && $ud['merge'] != $ud['id'])
  574. {
  575. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."' style='color:#000'><p>".$value['orderinfo']."</p>".$tly."</h9>"."<p>合并订单</p>";
  576. }
  577. if($value['library'] == 1 && $ud['printtype'] == 3)
  578. {
  579. $info_list[$key]['library'] = "不需要";
  580. }
  581. else if($value['library'] == 1 && $ud['printtype'] != 3)
  582. {
  583. $info_list[$key]['library'] = "未出库";
  584. }
  585. else if($value['library'] == 2)
  586. {
  587. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  588. }
  589. else if($value['library'] == 3)
  590. {
  591. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  592. }
  593. unset($info_list[$key]['waybillid']);
  594. }
  595. $total = $this->fullordersmt->find_count($where);
  596. $pagenum = ceil($total/$perpage);
  597. $over = $total-($start+$perpage);
  598. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  599. echo json_encode($rows);exit;
  600. }
  601. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  602. $this->data['wlshop'] = $wlshop;
  603. $this->data['express'] = $this->express->find_all();
  604. $user = $this->user->get_api($_SESSION['api']);
  605. $powerid = $this->power->read($user['power']);
  606. $powertext = explode('|',trim($powerid['excelid'],'|'));
  607. $pid = '';
  608. foreach ($powertext as $v)
  609. {
  610. $pid .= " id = ".$v." or";
  611. }
  612. $fullorderexcel = $this->fullorderexcel->find_all("type = '100004' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  613. $this->data['fullorderexcel'] = $fullorderexcel;
  614. $error = $this->fullordersmt->find_count("failed !='' and mergeid = 0 and (".rtrim($fgshop,'or').") and dtime > '".(time()-90*24*3600)."'");
  615. $this->data['error'] = $error;
  616. if(isset($_SESSION['api']))
  617. {
  618. $user = $this->user->get_api($_SESSION['api']);
  619. if($user['vip'] == 1)
  620. {
  621. $vip = 1;
  622. }
  623. else
  624. {
  625. $vip = 0;
  626. }
  627. }
  628. else
  629. {
  630. $vip = 0;
  631. }
  632. $this->data['power'] = $vip;
  633. $country = $this->country->find_all('1=1','id,name','name asc');//所有国家信息
  634. $this->data['country'] = $country;
  635. $this->data['user'] = $user;
  636. $cs_num = $this->fullordererrors->find_count( "plat = 'fullordersmt' and error_type = 1 and (".rtrim($fgshop,'or'). " ) and error_time > '".(time()-90*24*3600)."'");
  637. $this->data['cs_num'] = $cs_num;
  638. $this->_Template('fullordersmt',$this->data);
  639. }
  640. //筛选重复订单
  641. public function _repeat()
  642. {
  643. $user = $this->user->get_api($_SESSION['api']);
  644. if($user)
  645. {
  646. $fgshop = "";$sid = "";
  647. $user = explode('|',trim($user['shop'],'|'));
  648. foreach ($user as $value)
  649. {
  650. $fgshop .= " shop = ".$value." or";
  651. $sid .= " id = ".$value." or";
  652. }
  653. }
  654. $post = $this->input->post(NULL, TRUE);
  655. if(isset($post['page']))
  656. {
  657. $page = $this->input->post('page',true);
  658. $perpage = $this->input->post('perpage',true);
  659. $shop = $this->input->post('shop',true);
  660. $timetk = $this->input->post('timetk',true);
  661. $timetj = $this->input->post('timetj',true);
  662. $timetk = strtotime($timetk);
  663. $timetj = strtotime($timetj);
  664. // 接收前 是由已打印状态不展示的 现在不在限定此状态
  665. //$where = "print != 3 and review = 1 and state = 207 and (".rtrim($fgshop,'or').")";
  666. $where = "review = 1 and state = 207 and (".rtrim($fgshop,'or').")";
  667. if($shop)
  668. {
  669. $where .= " and shop = '$shop'";
  670. }
  671. if($timetk && $timetj)
  672. {
  673. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  674. }
  675. //数据排序
  676. $order_str = "numberpx desc";
  677. if(empty($page))
  678. {
  679. $start = 0;
  680. $perpage = 1;
  681. }
  682. else
  683. {
  684. $start = ($page - 1)*$perpage;
  685. }
  686. //取得信息列表
  687. $info_list = $this->fullordersmt->find_all($where,'id,shop,type,orderinfo,number,state,buytime,name,userid,address,merge');
  688. $info = array();
  689. $len = count($info_list);
  690. //格式化数据
  691. foreach ($info_list as $key=>$value)
  692. {
  693. $ud = $this->fullordersmt->read($value['id']);
  694. $shop = $this->shop->read($value['shop']);
  695. $info_list[$key]['shop'] = $shop['shopname'];
  696. $warehouse = $this->warehouse->read($value['type']);
  697. $info_list[$key]['type'] = $warehouse['title'];
  698. $typeclass = $this->typeclass->read($value['state']);
  699. if($ud['source'] != 1)
  700. {
  701. $info_list[$key]['state'] = "<a href='https://trade.aliexpress.com/order_detail.htm?orderId=".$value['orderinfo']."' target='_blank'>".$typeclass['title']."</a>";
  702. }
  703. else
  704. {
  705. $info_list[$key]['state'] = $typeclass['title'];
  706. }
  707. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  708. $info_list[$key]['userid'] = $value['userid'];
  709. if($value['merge'] == 0)
  710. {
  711. $info_list[$key]['merge'] = "<p><b class='jd' data-type='5'>合并订单</b></p>";
  712. }
  713. else
  714. {
  715. if($value['merge'] == $value['id'])
  716. {
  717. if($ud['print'] < '3' && $ud['library'] == '1')
  718. {
  719. $info_list[$key]['merge'] = "<p><b class='cforder' data-id='".$value['id']."'>拆分订单</b></p>";
  720. }
  721. else
  722. {
  723. $info_list[$key]['merge'] = "已合并";
  724. }
  725. }
  726. else
  727. {
  728. $info_list[$key]['merge'] = "被合并";
  729. }
  730. }
  731. }
  732. for($i=0;$i<$len;$i++)
  733. {
  734. for($j=$i+1;$j<$len;$j++)
  735. {
  736. if ($info_list[$i]['name'] == $info_list[$j]['name'] || $info_list[$i]['address'] == $info_list[$j]['address'] || $info_list[$i]['userid'] == $info_list[$j]['userid'] && ($info_list[$i]['state'] == $info_list[$j]['state'] && $info_list[$i]['type'] == $info_list[$j]['type']))
  737. {
  738. if(!array_key_exists($j,$info))
  739. {
  740. $info[$j] = $info_list[$j];
  741. }
  742. if(!array_key_exists($i,$info))
  743. {
  744. $info[$i] = $info_list[$i];
  745. }
  746. }
  747. }
  748. }
  749. rsort($info);
  750. $total = count($info);
  751. $pagenum = ceil($total/$perpage);
  752. $over = $total-($start+$perpage);
  753. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_slice($info,$start,$perpage)));
  754. echo json_encode($rows);exit;
  755. }
  756. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  757. $this->data['wlshop'] = $wlshop;
  758. $this->_Template('fullordersmt_repeat',$this->data);
  759. }
  760. //修改
  761. public function _edit($arg_array)
  762. {
  763. if(isset($_SESSION['api']))
  764. {
  765. $user = $this->user->get_api($_SESSION['api']);
  766. if($user['vip'] == 1)
  767. {
  768. $vip = 1;
  769. $this->data['userid'] = $user['id'];
  770. }
  771. else
  772. {
  773. $vip = 0;
  774. $this->data['userid'] = 0;
  775. }
  776. $xwtype = '';
  777. $userwh = explode('|',trim($user['warehouse'],'|'));
  778. foreach ($userwh as $v)
  779. {
  780. $xwtype .= " id = ".$v." or";
  781. }
  782. }
  783. else
  784. {
  785. $vip = 0;
  786. $this->data['userid'] = 0;
  787. }
  788. $post = $this->input->post(NULL, TRUE);
  789. if(isset($post['id']))
  790. {
  791. $id = $this->input->post('id',true);
  792. $data = $this->fullordersmt->read($id);
  793. $post['type'] = $this->input->post('warehouse',true);
  794. $post['country'] = $this->input->post('country',true);
  795. $currency = $this->country->read($post['country']);
  796. $post['al'] = $currency['lb'];
  797. $post['freight'] = $this->input->post('freight',true);
  798. $post['expressmoney'] = $this->input->post('expressmoney',true);
  799. $post['shouldmoney'] = $this->input->post('shouldmoney',true);
  800. $orderremarks = $this->input->post('orderremarks');
  801. $orderremarks = str_replace(array('%26','%2B'),array('&','+'),$orderremarks);
  802. $post['orderremarks'] = $orderremarks;
  803. $post['shipremarks'] = $this->input->post('shipremarks');
  804. $post['email'] = $this->input->post('email',true);
  805. $name = $this->input->post('name',true);
  806. $post['name'] = str_replace("'","’",$name);
  807. $post['phone'] = $this->input->post('phone',true);
  808. $post['country'] = $this->input->post('country',true);
  809. $post['province'] = $this->input->post('province',true);
  810. $post['city'] = $this->input->post('city',true);
  811. $post['zipcode'] = $this->input->post('zipcode',true);
  812. $post['street'] = $this->input->post('street',true);
  813. $address = $this->input->post('address',true);
  814. $post['address'] = str_replace("'","’",$address);
  815. $post['express'] = $this->input->post('express',true);
  816. $post['printtype'] = $this->input->post('printtype',true);
  817. $fpdata = $this->input->post('fpdata');
  818. $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
  819. $post['fpdata'] = $fpdata;
  820. $post['waybill'] = $this->input->post('waybill',true);
  821. $post['msg'] = $this->input->post('msg',true);
  822. $post['zsbjz'] = $this->input->post('zsbjz',true);
  823. $post['refundy'] = $this->input->post('refundy',true);
  824. $post['refundj'] = $this->input->post('refundj',true);
  825. $rtime = $this->input->post('rtime',true);
  826. $post['rtime'] = strtotime($rtime);
  827. $post['rpaypal'] = $this->input->post('rpaypal',true);
  828. $post['rtext'] = $this->input->post('rtext',true);
  829. $post['ioss'] = $this->input->post('ioss',true);
  830. $post['sbpm'] = $this->input->post('sbpm',true);
  831. $post['edittime'] = time();
  832. $post['waybill'] = preg_replace('/( | | | |\s)/','',$post['waybill']);
  833. $pay = $this->pay->get_typeclass($data['pay']);
  834. $yga = $post['shouldmoney'];
  835. $ygc = $data['estimaterate'];
  836. $post['budget'] = 0;
  837. $ifbudget = eval("return $yga*1.$ygc;");
  838. if($ifbudget > 0)
  839. {
  840. $post['budget'] = eval("return $yga*1.$ygc;");
  841. }
  842. $editstate = $this->input->post('state',true);
  843. $whlabel = $this->input->post('whlabel',true);
  844. $fpcount = $this->input->post('fpcount',true);
  845. $whlabeldata = explode('|',trim($whlabel,'|'));$way = 0;
  846. foreach ($whlabeldata as $va)
  847. {
  848. if(stripos($va,'z') !== false)
  849. {
  850. $way += 1;
  851. }
  852. }
  853. //如果备注中出现网红的两个字 ,那么在fpdata种的品名中必须有 WH这两个字 且美仓不用
  854. if($post['type'] !=5 ){
  855. if(stripos($post['shipremarks'],'网红') !== false){
  856. if(stripos($post['fpdata'],'-2090-') === false){
  857. echo json_encode(array('msg'=>'网红单请在商品名称中勾选WH!','success'=>false));exit;
  858. }
  859. }
  860. }
  861. if((($post['express'] == 2 || $post['express'] == 63 || $post['express'] == 64 || $post['express'] == 81) && $post['type'] != 5) || ($post['express'] != 2 && $post['express'] != 63 && $post['express'] != 64 && $post['express'] != 81 && $post['type'] == 5))
  862. {
  863. echo json_encode(array('msg'=>'此快递方式不可从美仓发货!','success'=>false));exit;
  864. }
  865. if($way == count($whlabeldata) && $post['type'] != 12)
  866. {
  867. echo json_encode(array('msg'=>'必须选择特殊仓!','success'=>false));exit;
  868. }
  869. // if($post['express'] == 42 && $post['sbpm'] != 'Human Hair Wigs' && $post['sbpm'] != 'Human Hair Goods')//$post['express'] == 3 ||
  870. // {
  871. // echo json_encode(array('msg'=>'此快递方式必须选择Human Hair Wigs/Human Hair Goods!','success'=>false));exit;
  872. // }
  873. //减少代码复用吧
  874. $lo_ret = $this->logic_order->checkEditExpress($post,['plat'=>'fullordersmt']);
  875. if($lo_ret['code'] != 1){
  876. echo json_encode(array('msg'=>$lo_ret['msg'],'success'=>false));exit;
  877. }
  878. if($post['express'] == 24 && $post['sbpm'] != 'Hair Sample' && $post['sbpm'] != 'Human Hair Wigs' && $post['sbpm'] != 'Human Hair Goods')//$post['express'] == 3 ||
  879. {
  880. echo json_encode(array('msg'=>'此快递方式必须选择Hair Sample/Human Hair Wigs/Human Hair Goods!','success'=>false));exit;
  881. }
  882. if($post['country'] != 192 && $post['express'] == 1 && $post['sbpm'] != 'Synthetic Hair Wigs' && $post['sbpm'] != 'Synthetic Hair Goods')//$post['express'] == 3 ||
  883. {
  884. echo json_encode(array('msg'=>'非美国选择官方DHL必须选择Synthetic Hair Wigs/Synthetic Hair Goods','success'=>false));exit;
  885. }
  886. $post['review'] = 1;
  887. if($post['zsbjz'] < '0.01')
  888. {
  889. echo json_encode(array('msg'=>'总申报价错误!','success'=>false));exit;
  890. }
  891. if($data['shop'] == '9' && $post['type'] != '7' && $post['type'] != '8' && $post['type'] != '9')
  892. {
  893. echo json_encode(array('msg'=>'仓库选择错误!','success'=>false));exit;
  894. }
  895. if($data['library'] == 1)
  896. {
  897. if($data['print'] != 3 && $data['review'] < 5)
  898. {
  899. $post['libraryconfirm'] = 1;
  900. $post['librarynot'] = "订单未打印";
  901. }
  902. else if($data['print'] != 3 && $data['review'] > 4)
  903. {
  904. $post['print'] = 1;
  905. $post['libraryconfirm'] = 1;
  906. $post['librarynot'] = "订单未打印,订单审核后修改";
  907. }
  908. else
  909. {
  910. $post['libraryconfirm'] = 1;
  911. $post['librarynot'] = "订单打印后修改";
  912. }
  913. }
  914. if($data['yhs'] == 1)
  915. {
  916. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  917. }
  918. if(($post['express'] == '5' || $post['express'] == '24' || $post['express'] == '31') && $post['country'] != 192)
  919. {
  920. echo json_encode(array('msg'=>'非美国无法选择Fedex!','success'=>false));exit;
  921. }
  922. if(($post['express'] == '28' || $post['express'] == '7') && $post['country'] != 191)
  923. {
  924. echo json_encode(array('msg'=>'非英国无法选择CNE和GES!','success'=>false));exit;
  925. }
  926. if($data['type'] != '5' && $post['type'] == '5' && $editstate != '207')
  927. {
  928. echo json_encode(array('msg'=>'等待发货状态才可选择美仓!','success'=>false));exit;
  929. }
  930. if($post['express'] == 52 && empty($post['email'])){
  931. echo json_encode(array('msg'=>'惠程安迈世发货需要有邮箱!','success'=>false));exit;
  932. }
  933. if($post['express'] == '2' && $post['bx'] > 0)
  934. {
  935. echo json_encode(array('msg'=>'此物流不允许购买保险','success'=>false));exit;
  936. }
  937. if($post['printtype'] == 1)//如果是运单
  938. {
  939. $post['productdescription'] = $this->input->post('productdescription',true);
  940. $post['customs'] = $this->input->post('customs',true);
  941. }
  942. $express = $this->express->read($post['express']);
  943. if($express['ioss'] == 1 && $post['ioss'] == '')
  944. {
  945. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  946. }
  947. if(strlen($post['address']) > $express['addresssize'] || strlen($post['address2']) > $express['addresssize'])
  948. {
  949. echo json_encode(array('msg'=>'此快递地址不可超出'.$express['addresssize'].'个字符','success'=>false));exit;
  950. }
  951. if( ($express['sbjz'] > 0) && ($post['zsbjz'] > $express['sbjz']))
  952. {
  953. echo json_encode(array('msg'=>'总申报价值不可超出'.$express['sbjz'],'success'=>false));exit;
  954. }
  955. if($post['shouldmoney'] > $express['shouldmoney'] && $express['shouldmoney'] != 0)
  956. {
  957. echo json_encode(array('msg'=>'订单金额不可超出'.$express['shouldmoney'],'success'=>false));exit;
  958. }
  959. if($post['express'] == '2' && $post['zzl'] > '16' && $post['js'] == '0')
  960. {
  961. echo json_encode(array('msg'=>'重量大于16不可按Ground Advantage提交!','success'=>false));exit;
  962. }
  963. if($post['express'] == '2' && isset($post['js']) && $post['js'] == '0'&& $post['qm'] == '1')
  964. {
  965. echo json_encode(array('msg'=>'Ground Advantage不可使用签名服务!','success'=>false));exit;
  966. }
  967. if(($post['express'] == '3' || $post['express'] == '42' || $post['express'] == '24' || $post['express'] == '31') && $post['shouldmoney'] < 1)
  968. {
  969. echo json_encode(array('msg'=>'零金额订单不可发 UPS/DHL官方-美国/Fedex(杭州)','success'=>false));exit;
  970. }
  971. if($post['express'] == '6' && $post['province'] == '')
  972. {
  973. echo json_encode(array('msg'=>'选择DPEX必须填写州信息','success'=>false));exit;
  974. }
  975. if(($post['express'] == '24' || $post['express'] == '3') && $post['shouldmoney'] == 0)
  976. {
  977. echo json_encode(array('msg'=>'0金额订单不可发UPS/Fedex(杭州)!!!','success'=>false));exit;
  978. }
  979. if($post['express'] == '42' && $post['zsbjz'] < 1)
  980. {
  981. echo json_encode(array('msg'=>'零申报金额不可发 DHL官方-美国','success'=>false));exit;
  982. }
  983. if($post['country'] == '35' && $post['zsbjz'] > 20)
  984. {
  985. echo json_encode(array('msg'=>'加拿大不可申报超过20美金!!!','success'=>false));exit;
  986. }
  987. if($post['express'] == 2 && strlen($post['zipcode']) != 5)//如果usps 邮编不是5位
  988. {
  989. echo json_encode(array('msg'=>'USPS-USA的邮编需按5位数格式提交!','success'=>false));exit;
  990. }
  991. /**
  992. if($editstate == 216 && $data['state'] != 216)
  993. {
  994. echo json_encode(array('msg'=>'不可修改为完成状态','success'=>false));exit;
  995. }
  996. **/
  997. if($editstate == 216 && preg_match('/\d/is',$post['waybill']) != true)
  998. {
  999. echo json_encode(array('msg'=>'当前信息不可修改订单状态','success'=>false));exit;
  1000. }
  1001. else
  1002. {
  1003. if($data['review'] == 1 && $data['source'] != 1)
  1004. {
  1005. $review = 6;
  1006. if($data['merge'] != '0')
  1007. {
  1008. $hdata = $this->fullordersmt->find_all("merge = '".$data['merge']."' and id != '".$data['id']."'");
  1009. foreach ($hdata as $v)
  1010. {
  1011. $this->fullordersmt->save(array('review'=>6),$v['id']);
  1012. }
  1013. }
  1014. }
  1015. else if($data['review'] == 3 || ($data['review'] == 1 && $data['source'] == 1))
  1016. {
  1017. $review = 2;
  1018. }
  1019. else
  1020. {
  1021. $review = $data['review'];
  1022. }
  1023. $post['review'] = $review;
  1024. $post['state'] = $editstate;
  1025. $post['reviewtime'] = time();
  1026. }
  1027. $thisdata = $this->fullordersmt->read($id);
  1028. $warehouse = $this->warehouse->read($thisdata['type']);
  1029. $warehousenew = $this->warehouse->read($post['type']);
  1030. if($warehousenew['bdcountry'] != 0 && $post['country'] != $warehousenew['bdcountry'])
  1031. {
  1032. echo json_encode(array('msg'=>'当前国家无法选择'.$warehousenew['title'].'!','success'=>false));exit;
  1033. }
  1034. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  1035. {
  1036. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  1037. }
  1038. $expt = $this->express->read($post['express']);
  1039. if($expt['pt'] != '' && stripos($post['fpdata'],$expt['pt']) !== false)
  1040. {
  1041. echo json_encode(array('msg'=>$expt['ptts'],'success'=>false));exit;
  1042. }
  1043. if($expt['province'] != '' && stripos($expt['province'],$post['province'].'、') !== false)
  1044. {
  1045. echo json_encode(array('msg'=>'此省/州不可使用 '.$expt['servicename'],'success'=>false));exit;
  1046. }
  1047. /**
  1048. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  1049. {
  1050. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  1051. }
  1052. **/
  1053. //开始注释 xyxg
  1054. /**
  1055. $ft = array();
  1056. $ftdata = explode('|',rtrim($fpcount,'|'));
  1057. foreach ($ftdata as $va)
  1058. {
  1059. $ftitle = '';
  1060. $va = explode('-',trim($va,'-'));
  1061. foreach ($va as $v)
  1062. {
  1063. $v = $this->typeclass->read($v);
  1064. $ftitle .= $v['title'].' ';
  1065. }
  1066. $ft[] = rtrim($ftitle,' ');
  1067. }
  1068. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  1069. {
  1070. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  1071. if($tskcyz['t'] > '0')
  1072. {
  1073. echo $tskcyz['m'];exit;
  1074. }
  1075. }
  1076. $kcyz = $this->whlabel->get_kc($data['state'],$post['state'],$warehousenew['zd'],$warehousenew['ys'],$post['type'],$whlabel,$fpcount,$ft,$thisdata['number'],$thisdata['shop'],$thisdata['type'],$thisdata['whlabel']);
  1077. if($kcyz['t'] > '0')
  1078. {
  1079. echo $kcyz['m'];exit;
  1080. }
  1081. else
  1082. {
  1083. if($this->fullordersmt->save($post,$id))
  1084. {
  1085. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  1086. }
  1087. else
  1088. {
  1089. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  1090. }
  1091. }
  1092. //结束注释
  1093. **/
  1094. $warehouse = $this->warehouse->read($post['type']);
  1095. if($data['library'] == 1 || ($data['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  1096. {
  1097. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  1098. if($kcyz['t'] > '0')
  1099. {
  1100. echo $kcyz['m'];exit;
  1101. }
  1102. else if($kcyz['fpdata'] != '')
  1103. {
  1104. $post['whlabel'] = $kcyz['whlabel'];
  1105. $post['fpdata'] = $kcyz['fpdata'];
  1106. }
  1107. }
  1108. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  1109. $post['sfxh'] = $fl['sfxh'];
  1110. $post['ckfl'] = $fl['ckfl'];
  1111. //查询净重开始
  1112. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  1113. //查询净重结束
  1114. if($this->fullordersmt->save($post,$id))
  1115. {
  1116. if($data['printtime'] == '0')
  1117. {
  1118. $xghz = ',该单将自动禁止打印';
  1119. }
  1120. else if($data['printtime'] > '0' && $data['librarytime'] == '0')
  1121. {
  1122. $xghz = ',该单将自动禁止发货';
  1123. }
  1124. else
  1125. {
  1126. $xghz = '';
  1127. }
  1128. echo json_encode(array('msg'=>'修改成功'.$xghz,'id'=>$id,'success'=>true));exit;
  1129. }
  1130. else
  1131. {
  1132. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  1133. }
  1134. }
  1135. $arg_array = $arg_array[0];$fpdata = array();
  1136. $fullordersmt = $this->fullordersmt->read($arg_array);
  1137. $returngoods = $this->returngoods->get_orderinfo($fullordersmt['orderinfo']);
  1138. $this->data['returngoods'] = $returngoods?1:0;
  1139. $fullordersmt['parameter'] = str_replace(",","---",$fullordersmt['parameter']);
  1140. $country = $this->country->find_all('1=1','id,name','name asc');//所有国家信息
  1141. $express = $this->express->find_all('1=1');//所有快递配置信息
  1142. $this->data['fullordersmt'] = $fullordersmt;
  1143. if($fullordersmt['express'] == 2)
  1144. {
  1145. $zzhl = 'oz';
  1146. }
  1147. else
  1148. {
  1149. $zzhl = 'kg';
  1150. }
  1151. $this->data['zzhl'] = $zzhl;
  1152. $this->data['country'] = $country;
  1153. $this->data['express'] = $express;
  1154. $this->data['dtime'] = date('Y-m-d H:i:s',$fullordersmt['dtime']);
  1155. $warehouse = $this->warehouse->read($fullordersmt['type']);
  1156. if(stripos($fullordersmt['fpdata'],';') !== false)
  1157. {
  1158. $fpdata = explode(';',rtrim($fullordersmt['fpdata'],';'));
  1159. foreach ($fpdata as $k=>$v)
  1160. {
  1161. $xxv = explode('|',$v);
  1162. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  1163. {
  1164. $xxv['zd'] = "<p>已占单</p>";
  1165. $bdck = $warehouse['bdck'];
  1166. if(stripos($xxv[9],'~') !== false)
  1167. {
  1168. $dxxv = explode('~',trim($xxv[9],'~'));
  1169. foreach ($dxxv as $val)
  1170. {
  1171. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  1172. if($wzid['details'] != '')
  1173. {
  1174. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1175. }
  1176. }
  1177. }
  1178. else
  1179. {
  1180. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  1181. if($wzid['details'] != '')
  1182. {
  1183. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1184. }
  1185. }
  1186. }
  1187. $fpdata[$k] = $xxv;
  1188. }
  1189. }
  1190. $this->data['fpdata'] = $fpdata;
  1191. $thfpdataxs = array();
  1192. if($fullordersmt['thfpdata'] != '')
  1193. {
  1194. $thfpdata = explode(';',trim($fullordersmt['thfpdata'],';'));
  1195. foreach ($thfpdata as $k=>$v)
  1196. {
  1197. $thxs = explode('~',trim($v,'~'));
  1198. $thxs[0] = explode('|',trim($thxs[0],'|'));
  1199. $thxs[1] = explode('|',trim($thxs[1],'|'));
  1200. $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]);
  1201. }
  1202. }
  1203. $this->data['thfpdata'] = $thfpdataxs;
  1204. $shop = $this->shop->read($fullordersmt['shop']);
  1205. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  1206. $is = 0;
  1207. if($shop['type'] == 269)//判断是否独立站,269是独立站
  1208. {
  1209. $is = 1;
  1210. }
  1211. $this->data['is'] = $is;
  1212. $this->data['power'] = $vip;
  1213. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  1214. $downwaybill = '';$dwls = array();
  1215. $oldwaybill = explode('-',ltrim($fullordersmt['oldwaybill'],'-'));
  1216. if(isset($oldwaybill[0][1]))
  1217. {
  1218. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  1219. foreach ($oldwaybill as $v)
  1220. {
  1221. $dw = explode('/',$v);
  1222. if(isset($dw[1]))
  1223. {
  1224. if(stripos($downwaybill,$dw[1]) === false)
  1225. {
  1226. $dwls[$dw[1]] = 1;
  1227. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  1228. }
  1229. }
  1230. }
  1231. }
  1232. if($fullordersmt['printtype'] == 1)
  1233. {
  1234. if($fullordersmt['waybill'] != '' && !isset($dwls[$fullordersmt['waybill']]))
  1235. {
  1236. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullordersmt['printtime']).'/y-'.$fullordersmt['waybill'].'.pdf" target="_blank">'.$fullordersmt['waybill'].'</a>、'.$downwaybill;
  1237. }
  1238. }
  1239. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  1240. $product = '';
  1241. if($fullordersmt['link'] != '' && $fullordersmt['source'] != '1')
  1242. {
  1243. $pt = explode(';',rtrim($fullordersmt['product'],';'));
  1244. $lk = explode(',',$fullordersmt['link']);
  1245. for($i=0;$i<count($pt);$i++)
  1246. {
  1247. if(isset($lk[$i]) && isset($pt[$i]))
  1248. {
  1249. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$pt[$i].'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$pt[$i].'</a>';
  1250. }
  1251. }
  1252. }
  1253. else
  1254. {
  1255. $product = $fullordersmt['product'];
  1256. }
  1257. $this->data['product'] = $product;
  1258. $out = $this->systemtransfer->find_all("number = '".$fullordersmt['number']."'");
  1259. $outread = '';
  1260. if($out)
  1261. {
  1262. foreach ($out as $val)
  1263. {
  1264. $list = '';
  1265. $rk = explode('|',trim($val['rk'],'|'));
  1266. $rktime = explode('|',trim($val['rktime'],'|'));
  1267. $zw = array();
  1268. $t = $this->transfer->find_all("1=1");
  1269. foreach ($t as $v)
  1270. {
  1271. $zw[$v['id']] = $v['title'];
  1272. }
  1273. if($val['rk'] != '' && count($rk) > 0)
  1274. {
  1275. for($i=0;$i<count($rk);$i++)
  1276. {
  1277. if(!isset($rktime[$i]))
  1278. {
  1279. $list .= $zw[$cz[$i]];
  1280. }
  1281. else
  1282. {
  1283. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  1284. }
  1285. }
  1286. }
  1287. //$outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  1288. $outread .= '<span style="color:#f00">'.$val['shipremarks'].'</span>:'.$list.'<br>';
  1289. }
  1290. }
  1291. else
  1292. {
  1293. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullordersmt['number']."'");
  1294. $outread = array();
  1295. if($systemwigsout)
  1296. {
  1297. foreach ($systemwigsout as $v)
  1298. {
  1299. if($v['czwarehouse'] == 37)
  1300. {
  1301. $outread[] = '华荣厂';
  1302. }
  1303. else if($v['czwarehouse'] == 0)
  1304. {
  1305. $outread[] = '龙盈厂';
  1306. }
  1307. $cz = explode('|',trim($v['cz'],'|'));
  1308. $cztime = explode('|',trim($v['cztime'],'|'));
  1309. $zw = $this->transfer->get_list();
  1310. if($v['cz'] != '' && count($cz) > 0)
  1311. {
  1312. for($i=0;$i<count($cz);$i++)
  1313. {
  1314. if(!isset($cztime[$i]))
  1315. {
  1316. $outread[] = $zw[$cz[$i]].' -&gt; ';
  1317. }
  1318. else
  1319. {
  1320. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  1321. }
  1322. }
  1323. $outread[] = '<br>';
  1324. }
  1325. }
  1326. }
  1327. }
  1328. $this->data['systemwigsout'] = $outread;
  1329. $this->data['xwuser'] = 0;
  1330. if($user['power'] == 47)
  1331. {
  1332. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($xwtype,'or'),"*","px asc");
  1333. $this->data['warehouse'] = $warehouse;
  1334. $this->data['xwuser'] = 1;
  1335. }
  1336. $this->data['user'] = $user;
  1337. $this->_Template('fullordersmt_edit',$this->data);
  1338. }
  1339. //不可修改
  1340. public function _readonly($arg_array)
  1341. {
  1342. $user = $this->user->get_api($_SESSION['api']);
  1343. $post = $this->input->post(NULL, TRUE);
  1344. if(isset($post['id']))
  1345. {
  1346. $id = $this->input->post('id',true);
  1347. $ud = $this->fullordersmt->read($id);$data = $ud;
  1348. $post['type'] = $this->input->post('warehouse',true);
  1349. $post['orderremarks'] = $this->input->post('orderremarks',true);
  1350. $post['state'] = $this->input->post('state',true);
  1351. $post['msg'] = $this->input->post('msg',true);
  1352. $post['refundy'] = $this->input->post('refundy',true);
  1353. $post['refundj'] = $this->input->post('refundj',true);
  1354. $fpdata = $this->input->post('fpdata');
  1355. $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
  1356. $post['fpdata'] = $fpdata;
  1357. $rtime = $this->input->post('rtime',true);
  1358. $post['rtime'] = strtotime($rtime);
  1359. $post['rpaypal'] = $this->input->post('rpaypal',true);
  1360. $post['rtext'] = $this->input->post('rtext',true);
  1361. //$post['ioss'] = $this->input->post('ioss',true);
  1362. $whlabel = $this->input->post('whlabel',true);
  1363. $post['edittime'] = time();
  1364. $editstate = $post['state'];
  1365. /**
  1366. if($post['state'] == 216 && $ud['state'] != 216)
  1367. {
  1368. echo json_encode(array('msg'=>'不可修改为完成状态','success'=>false));exit;
  1369. }
  1370. **/
  1371. $whlabeldata = explode('|',trim($whlabel,'|'));$way = 0;
  1372. foreach ($whlabeldata as $va)
  1373. {
  1374. if(stripos($va,'z') !== false)
  1375. {
  1376. $way += 1;
  1377. }
  1378. }
  1379. if($way == count($whlabeldata) && $post['type'] != 12)
  1380. {
  1381. echo json_encode(array('msg'=>'必须选择特殊仓!','success'=>false));exit;
  1382. }
  1383. $fpcount = $this->input->post('fpcount',true);
  1384. if(!$fpcount)
  1385. {
  1386. echo json_encode(array('msg'=>'需要先清理浏览器缓存,刷新当前页面后再试!','success'=>false));exit;
  1387. }
  1388. if($ud['shop'] == '9' && $post['type'] != '7' && $post['type'] != '8')
  1389. {
  1390. echo json_encode(array('msg'=>'仓库选择错误!','success'=>false));exit;
  1391. }
  1392. if($ud['library'] == 1)
  1393. {
  1394. if($ud['print'] != 3)
  1395. {
  1396. $post['print'] = 1;
  1397. $post['libraryconfirm'] = 1;
  1398. $post['librarynot'] = "订单未打印,未审核或未通过";
  1399. }
  1400. else
  1401. {
  1402. $post['libraryconfirm'] = 1;
  1403. $post['librarynot'] = "未审核或未通过";
  1404. }
  1405. }
  1406. if(($post['express'] == '5' || $post['express'] == '24' || $post['express'] == '31') && $ud['country'] != 192)
  1407. {
  1408. echo json_encode(array('msg'=>'非美国无法选择Fedex!','success'=>false));exit;
  1409. }
  1410. if(($post['express'] == '28' || $post['express'] == '7') && $ud['country'] != 191)
  1411. {
  1412. echo json_encode(array('msg'=>'非英国无法选择CNE和GES!','success'=>false));exit;
  1413. }
  1414. if($post['type'] != 5 && in_array($post['express'],[2,63,64,81]))
  1415. {
  1416. echo json_encode(array('msg'=>"此快递方式必须从美仓发货!",'success'=>false));exit;
  1417. }
  1418. if($post['type'] == 5 && !in_array($post['express'],[2,63,64,81]))
  1419. {
  1420. echo json_encode(array('msg'=>"此快递方式不能美仓发货!",'success'=>false));exit;
  1421. }
  1422. $express = $this->express->read($post['express']);
  1423. /**
  1424. if($express['ioss'] == 1 && $post['ioss'] == '')
  1425. {
  1426. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  1427. }
  1428. **/
  1429. $thisdata = $this->fullordersmt->read($id);
  1430. $warehouse = $this->warehouse->read($thisdata['type']);
  1431. $warehousenew = $this->warehouse->read($post['type']);
  1432. if(($post['express'] == '5' || $post['express'] == '24') && strlen($ud['address']) > 32)
  1433. {
  1434. echo json_encode(array('msg'=>'地址1长度不合格!','success'=>false));exit;
  1435. }
  1436. if($post['express'] == '27' && strlen($post['address']) > 30)
  1437. {
  1438. echo json_encode(array('msg'=>'地址1长度不合格!','success'=>false));exit;
  1439. }
  1440. if($data['type'] != '5' && $post['type'] == '5' && $editstate != '207')
  1441. {
  1442. echo json_encode(array('msg'=>'等待发货状态才可选择美仓!','success'=>false));exit;
  1443. }
  1444. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  1445. {
  1446. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  1447. }
  1448. if($ud['yhs'] == 1)
  1449. {
  1450. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  1451. }
  1452. $expt = $this->express->read($post['express']);
  1453. if($expt['pt'] != '' && stripos($post['fpdata'],$expt['pt']) !== false)
  1454. {
  1455. echo json_encode(array('msg'=>$expt['ptts'],'success'=>false));exit;
  1456. }
  1457. if($expt['province'] != '' && stripos($expt['province'],$ud['province'].'、') !== false)
  1458. {
  1459. echo json_encode(array('msg'=>'此省/州不可使用 '.$expt['servicename'],'success'=>false));exit;
  1460. }
  1461. /**
  1462. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  1463. {
  1464. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  1465. }
  1466. **/
  1467. //开始注释 xyxg
  1468. /**
  1469. $ft = array();
  1470. $ftdata = explode('|',rtrim($fpcount,'|'));
  1471. foreach ($ftdata as $va)
  1472. {
  1473. $ftitle = '';
  1474. $va = explode('-',trim($va,'-'));
  1475. foreach ($va as $v)
  1476. {
  1477. $v = $this->typeclass->read($v);
  1478. $ftitle .= $v['title'].' ';
  1479. }
  1480. $ft[] = rtrim($ftitle,' ');
  1481. }
  1482. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  1483. {
  1484. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  1485. if($tskcyz['t'] > '0')
  1486. {
  1487. echo $tskcyz['m'];exit;
  1488. }
  1489. }
  1490. $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']);//旧状态、新状态、仓库占单设置、仓库预设设置、新仓库、新产品简化数字、旧产品数字、旧产品名称、订单号、订单店铺、旧订单仓库、旧产品简化数字
  1491. if($kcyz['t'] > '0')
  1492. {
  1493. echo $kcyz['m'];exit;
  1494. }
  1495. else
  1496. {
  1497. if($this->fullordersmt->save($post,$id))
  1498. {
  1499. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  1500. }
  1501. else
  1502. {
  1503. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  1504. }
  1505. }
  1506. //结束注释
  1507. **/
  1508. $warehouse = $this->warehouse->read($post['type']);
  1509. if($ud['library'] == 1 || ($ud['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  1510. {
  1511. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  1512. if($kcyz['t'] > '0')
  1513. {
  1514. echo $kcyz['m'];exit;
  1515. }
  1516. else if($kcyz['fpdata'] != '')
  1517. {
  1518. $post['whlabel'] = $kcyz['whlabel'];
  1519. $post['fpdata'] = $kcyz['fpdata'];
  1520. }
  1521. }
  1522. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  1523. $post['sfxh'] = $fl['sfxh'];
  1524. $post['ckfl'] = $fl['ckfl'];
  1525. //查询净重开始
  1526. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  1527. //查询净重结束
  1528. if($this->fullordersmt->save($post,$id))
  1529. {
  1530. if($data['printtime'] == '0')
  1531. {
  1532. $xghz = ',该单将自动禁止打印';
  1533. }
  1534. else if($data['printtime'] > '0' && $data['librarytime'] == '0')
  1535. {
  1536. $xghz = ',该单将自动禁止发货';
  1537. }
  1538. else
  1539. {
  1540. $xghz = '';
  1541. }
  1542. echo json_encode(array('msg'=>'修改成功'.$xghz,'id'=>$id,'success'=>true));exit;
  1543. }
  1544. else
  1545. {
  1546. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  1547. }
  1548. }
  1549. $arg_array = $arg_array[0];$fpdata = array();
  1550. $fullordersmt = $this->fullordersmt->read($arg_array);
  1551. $returngoods = $this->returngoods->get_orderinfo($fullordersmt['orderinfo']);
  1552. $this->data['returngoods'] = $returngoods?1:0;
  1553. $fullordersmt['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$fullordersmt['shipremarks']);
  1554. $fullordersmt['parameter'] = str_replace(",","---",$fullordersmt['parameter']);
  1555. $this->data['fullordersmt'] = $fullordersmt;
  1556. if($fullordersmt['express'] == 2)
  1557. {
  1558. $zzhl = 'oz';
  1559. }
  1560. else
  1561. {
  1562. $zzhl = 'kg';
  1563. }
  1564. $this->data['zzhl'] = $zzhl;
  1565. $this->data['countrys'] = $this->country->find_all();
  1566. $this->data['express'] = $this->express->find_all();
  1567. $warehouse = $this->warehouse->read($fullordersmt['type']);
  1568. if(stripos($fullordersmt['fpdata'],';') !== false)
  1569. {
  1570. $fpdata = explode(';',rtrim($fullordersmt['fpdata'],';'));
  1571. foreach ($fpdata as $k=>$v)
  1572. {
  1573. $xxv = explode('|',$v);
  1574. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  1575. {
  1576. $xxv['zd'] = "<p>已占单</p>";
  1577. $bdck = $warehouse['bdck'];
  1578. if(stripos($xxv[9],'~') !== false)
  1579. {
  1580. $dxxv = explode('~',trim($xxv[9],'~'));
  1581. foreach ($dxxv as $val)
  1582. {
  1583. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  1584. if($wzid['details'] != '')
  1585. {
  1586. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1587. }
  1588. }
  1589. }
  1590. else
  1591. {
  1592. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  1593. if($wzid['details'] != '')
  1594. {
  1595. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1596. }
  1597. }
  1598. }
  1599. $fpdata[$k] = $xxv;
  1600. }
  1601. }
  1602. $this->data['fpdata'] = $fpdata;
  1603. $thfpdataxs = array();
  1604. if($fullordersmt['thfpdata'] != '')
  1605. {
  1606. $thfpdata = explode(';',trim($fullordersmt['thfpdata'],';'));
  1607. foreach ($thfpdata as $k=>$v)
  1608. {
  1609. $thxs = explode('~',trim($v,'~'));
  1610. $thxs[0] = explode('|',trim($thxs[0],'|'));
  1611. $thxs[1] = explode('|',trim($thxs[1],'|'));
  1612. $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]);
  1613. }
  1614. }
  1615. $this->data['thfpdata'] = $thfpdataxs;
  1616. $shop = $this->shop->read($fullordersmt['shop']);
  1617. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  1618. $is = 0;
  1619. if($shop['type'] == 269)//判断是否独立站,269是独立站
  1620. {
  1621. $is = 1;
  1622. }
  1623. $this->data['is'] = $is;
  1624. //单项开始
  1625. $warehouse = $this->warehouse->read($fullordersmt['warehouse']);//发货仓库
  1626. $state = $this->typeclass->read($fullordersmt['state']);//订单状态
  1627. $country = $this->country->read($fullordersmt['country']);//国家
  1628. if($fullordersmt['capital'] == 1)
  1629. {
  1630. $capital = '暂未支付';
  1631. }
  1632. else if($fullordersmt['capital'] == 2)
  1633. {
  1634. $capital = '部分支付';
  1635. }
  1636. else if($fullordersmt['capital'] == 3)
  1637. {
  1638. $capital = '全部支付';
  1639. }
  1640. if($fullordersmt['printtype'] == 1)
  1641. {
  1642. $printtype = '运单';
  1643. }
  1644. else if($fullordersmt['printtype'] == 2)
  1645. {
  1646. $printtype = '发货单';
  1647. }
  1648. else if($fullordersmt['printtype'] == 3)
  1649. {
  1650. $printtype = '不打印单据';
  1651. }
  1652. else
  1653. {
  1654. $printtype = '未选择';
  1655. }
  1656. $this->data['warehouse'] = $warehouse['title'];
  1657. $this->data['state'] = $state['title'];
  1658. $this->data['capital'] = $capital;
  1659. $this->data['country'] = $country['ename'];
  1660. $this->data['printtype'] = $printtype;
  1661. //单项结束
  1662. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  1663. $downwaybill = '';$dwls = array();
  1664. $oldwaybill = explode('-',ltrim($fullordersmt['oldwaybill'],'-'));
  1665. if(isset($oldwaybill[0][1]))
  1666. {
  1667. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  1668. foreach ($oldwaybill as $v)
  1669. {
  1670. $dw = explode('/',$v);
  1671. if(isset($dw[1]))
  1672. {
  1673. $dwls[$dw[1]] = 1;
  1674. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  1675. }
  1676. }
  1677. }
  1678. if($fullordersmt['printtype'] == 1)
  1679. {
  1680. if($fullordersmt['waybill'] != '' && !isset($dwls[$fullordersmt['waybill']]))
  1681. {
  1682. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullordersmt['printtime']).'/y-'.$fullordersmt['waybill'].'.pdf" target="_blank">'.$fullordersmt['waybill'].'</a>、'.$downwaybill;
  1683. }
  1684. }
  1685. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  1686. /** 历史打印时间 **/
  1687. $printtime = '';
  1688. if($fullordersmt['oldprinttime'])
  1689. {
  1690. $pte = explode('-',rtrim($fullordersmt['oldprinttime'],'-'));
  1691. foreach ($pte as $v)
  1692. {
  1693. $printtime .= date('Y-m-d H:i:s',$v).'、';
  1694. }
  1695. }
  1696. $this->data['printtime'] = rtrim($printtime,'、');
  1697. $product = '';
  1698. if($fullordersmt['link'] != '' && $fullordersmt['source'] != '1')
  1699. {
  1700. $pt = explode(';',rtrim($fullordersmt['product'],';'));
  1701. $lk = explode(',',$fullordersmt['link']);
  1702. for($i=0;$i<count($pt);$i++)
  1703. {
  1704. if(isset($lk[$i]) && isset($pt[$i]))
  1705. {
  1706. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$pt[$i].'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$pt[$i].'</a>';
  1707. }
  1708. }
  1709. }
  1710. else
  1711. {
  1712. $product = $fullordersmt['product'];
  1713. }
  1714. $this->data['username'] = ($user['shop']=='|9|')?'1':'0';
  1715. $out = $this->systemtransfer->find_all("number = '".$fullordersmt['number']."'");
  1716. $outread = '';
  1717. if($out)
  1718. {
  1719. foreach ($out as $val)
  1720. {
  1721. $list = '';
  1722. $rk = explode('|',trim($val['rk'],'|'));
  1723. $rktime = explode('|',trim($val['rktime'],'|'));
  1724. $zw = array();
  1725. $t = $this->transfer->find_all("1=1");
  1726. foreach ($t as $v)
  1727. {
  1728. $zw[$v['id']] = $v['title'];
  1729. }
  1730. if($val['rk'] != '' && count($rk) > 0)
  1731. {
  1732. for($i=0;$i<count($rk);$i++)
  1733. {
  1734. if(!isset($rktime[$i]))
  1735. {
  1736. $list .= $zw[$cz[$i]];
  1737. }
  1738. else
  1739. {
  1740. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  1741. }
  1742. }
  1743. }
  1744. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  1745. }
  1746. }
  1747. else
  1748. {
  1749. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullordersmt['number']."'");
  1750. $outread = array();
  1751. if($systemwigsout)
  1752. {
  1753. foreach ($systemwigsout as $v)
  1754. {
  1755. if($v['czwarehouse'] == 37)
  1756. {
  1757. $outread[] = '华荣厂';
  1758. }
  1759. else if($v['czwarehouse'] == 0)
  1760. {
  1761. $outread[] = '龙盈厂';
  1762. }
  1763. $cz = explode('|',trim($v['cz'],'|'));
  1764. $cztime = explode('|',trim($v['cztime'],'|'));
  1765. $zw = $this->transfer->get_list();
  1766. if($v['cz'] != '' && count($cz) > 0)
  1767. {
  1768. for($i=0;$i<count($cz);$i++)
  1769. {
  1770. if(!isset($cztime[$i]))
  1771. {
  1772. $outread[] = $zw[$cz[$i]].' -&gt; ';
  1773. }
  1774. else
  1775. {
  1776. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  1777. }
  1778. }
  1779. $outread[] = '<br>';
  1780. }
  1781. }
  1782. }
  1783. }
  1784. $this->data['systemwigsout'] = $outread;
  1785. $this->data['user'] = $user;
  1786. $this->_Template('fullordersmt_readonly',$this->data);
  1787. }
  1788. //浏览列表
  1789. public function _readlist()
  1790. {
  1791. $post = $this->input->post(NULL, TRUE);
  1792. if(isset($post['page']))
  1793. {
  1794. $page = $this->input->post('page',true);
  1795. $perpage = $this->input->post('perpage',true);
  1796. $warehouse = $this->input->post('warehouse',true);
  1797. $express = $this->input->post('express',true);
  1798. $state = $this->input->post('state',true);
  1799. $print = $this->input->post('print',true);
  1800. $libraryconfirm = $this->input->post('libraryconfirm',true);
  1801. $orderinfo = $this->input->post('orderinfo',true);
  1802. $client = $this->input->post('name',true);
  1803. $email = $this->input->post('email',true);
  1804. $number = $this->input->post('number',true);
  1805. $waybill = $this->input->post('waybill',true);
  1806. $timetk = $this->input->post('timetk',true);
  1807. $timetj = $this->input->post('timetj',true);
  1808. $timetk = strtotime($timetk);
  1809. $timetj = strtotime($timetj);
  1810. $where = "mergeid = 0";
  1811. if($warehouse)
  1812. {
  1813. $where .= " and type = '$warehouse'";
  1814. }
  1815. if($express)
  1816. {
  1817. $where .= " and express = '$express'";
  1818. }
  1819. if($state)
  1820. {
  1821. $where .= " and state = '$state'";
  1822. }
  1823. if($print)
  1824. {
  1825. $where .= " and print = '$print'";
  1826. }
  1827. if($libraryconfirm)
  1828. {
  1829. $where .= " and libraryconfirm = '$libraryconfirm'";
  1830. }
  1831. if($orderinfo)
  1832. {
  1833. $where .= " and orderinfo = '$orderinfo'";
  1834. }
  1835. if($client)
  1836. {
  1837. $where .= " and client like '%$client%'";
  1838. }
  1839. if($email)
  1840. {
  1841. $where .= " and email = '$email'";
  1842. }
  1843. if($number)
  1844. {
  1845. $where .= " and number = '$number'";
  1846. }
  1847. if($waybill)
  1848. {
  1849. $where .= " and waybill = '$waybill'";
  1850. }
  1851. if($timetk && $timetj)
  1852. {
  1853. $timetj = $timetj+24*3600;
  1854. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  1855. }
  1856. //数据排序
  1857. $order_str = "numberpx desc";
  1858. if(empty($page))
  1859. {
  1860. $start = 0;
  1861. $perpage = 1;
  1862. }
  1863. else
  1864. {
  1865. $start = ($page - 1)*$perpage;
  1866. }
  1867. //取得信息列表
  1868. $info_list = $this->fullordersmt->find_all($where,'id,type,orderinfo,number,client,state,buytime,express,waybill,print,library,orderremarks',$order_str,$start,$perpage);
  1869. //格式化数据
  1870. foreach ($info_list as $key=>$value)
  1871. {
  1872. $ud = $this->fullordersmt->read($value['id']);
  1873. $warehouse = $this->warehouse->read($value['type']);
  1874. $info_list[$key]['type'] = $warehouse['title'];
  1875. $typeclass = $this->typeclass->read($value['state']);
  1876. $info_list[$key]['state'] = $typeclass['spare'];
  1877. if($ud['source'] == 1) //线下单用订单时间,其他用付款时间
  1878. {
  1879. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$ud['dtime']).'</p><p>'.date('H:i:s',$ud['dtime']).'</p>';
  1880. }
  1881. else
  1882. {
  1883. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  1884. }
  1885. $express = $this->express->read($value['express']);
  1886. $info_list[$key]['express'] = $express['servicename'];
  1887. if($value['print'] == 1)
  1888. {
  1889. $info_list[$key]['print'] = "不可打印";
  1890. }
  1891. else if($value['print'] == 2)
  1892. {
  1893. $info_list[$key]['print'] = "未打印";
  1894. }
  1895. else if($value['print'] == 3)
  1896. {
  1897. $info_list[$key]['print'] = '<p>'.date('Y-m-d',$ud['printtime']).'</p><p>'.date('H:i:s',$ud['printtime']).'</p>';
  1898. }
  1899. if($value['library'] == 1)
  1900. {
  1901. $info_list[$key]['library'] = "未出库";
  1902. }
  1903. else if($value['library'] == 2)
  1904. {
  1905. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'</p>';
  1906. }
  1907. else if($value['library'] == 3)
  1908. {
  1909. $info_list[$key]['library'] = "已退库";
  1910. }
  1911. }
  1912. $total = $this->fullordersmt->find_count($where);
  1913. $pagenum = ceil($total/$perpage);
  1914. $over = $total-($start+$perpage);
  1915. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  1916. echo json_encode($rows);exit;
  1917. }
  1918. $this->_Template('fullordersmt_readlist',$this->data);
  1919. }
  1920. //删除
  1921. public function _del()
  1922. {
  1923. $post = $this->input->post(NULL, TRUE);
  1924. if(isset($post['s']))
  1925. {
  1926. $id_arr = $this->input->post('s');
  1927. $id_arr = explode(',',$id_arr);
  1928. if(!$id_arr)
  1929. {
  1930. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1931. }
  1932. //循环删除记录
  1933. foreach ($id_arr as $v)
  1934. {
  1935. $this->fullordersmt->remove($v);
  1936. }
  1937. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  1938. }
  1939. }
  1940. //查找商品价格
  1941. public function _price()
  1942. {
  1943. $post = $this->input->post(NULL, TRUE);
  1944. if(isset($post['data']))
  1945. {
  1946. $data = $this->input->post('data');
  1947. $data = explode('-',$data);
  1948. $number = '';$num = count($data);
  1949. //循环删除记录
  1950. for($i=0;$i<$num-1;$i++)
  1951. {
  1952. if($data[$i] != 0)
  1953. {
  1954. $number=$number.$data[$i];
  1955. if($i == 2)
  1956. {
  1957. $number=$number.$data[$num-1];
  1958. }
  1959. }
  1960. }
  1961. $list = $this->productdescribe->get_number($number);
  1962. if($list)
  1963. {
  1964. echo json_encode(array('msg'=>($list),'n'=>$data[$num-1],'number'=>$number,'success'=>true));
  1965. }
  1966. else
  1967. {
  1968. $list = array('purchase'=>0,'cost'=>0,'salesprice'=>0);
  1969. //echo json_encode(array('msg'=>'此信息没有配置价格!','n'=>$data[$num-1],'success'=>false));exit;
  1970. echo json_encode(array('msg'=>($list),'n'=>$data[$num-1],'number'=>$number,'success'=>true));exit;
  1971. }
  1972. }
  1973. }
  1974. public function _customs()
  1975. {
  1976. $post = $this->input->post(NULL, TRUE);
  1977. if(isset($post['e']))
  1978. {
  1979. $e = $this->input->post('e');//快递信息
  1980. $c = $this->input->post('c');//国家信息
  1981. $data = $this->customs->find_all('express = "'.$e.'" and country = "'.$c.'"');
  1982. $list = $this->productdescription->find_all('express = "'.$e.'" and country = "'.$c.'"');
  1983. $rows = array();
  1984. foreach ($data as $key=>$value)
  1985. {
  1986. $detailed = explode('|',trim($value['detailed'],'|'));
  1987. //此处未对比重量选择价值,暂直接选择第一条海关价值
  1988. $detailed = $this->detailed->read($detailed[0]);
  1989. $money = $detailed['customsval'];//找到海关价值
  1990. }
  1991. foreach ($list as $key=>$value)
  1992. {
  1993. $description = $this->typeclass->read($value['description']);
  1994. $list[$key]['title'] = $description['title'];//产品描述名称
  1995. }
  1996. if(!$data && !$list)
  1997. {
  1998. echo json_encode(array('msg'=>'无此快递配置信息!','success'=>false));exit;
  1999. }
  2000. else
  2001. {
  2002. //$list-title -description 取值
  2003. echo json_encode(array('money'=>sprintf("%.2f",$money),'msg'=>$list,'success'=>true));
  2004. }
  2005. }
  2006. }
  2007. public function _express()
  2008. {
  2009. $post = $this->input->post(NULL, TRUE);
  2010. if(isset($post['e']))
  2011. {
  2012. $e = $this->input->post('e');//快递信息
  2013. $c = $this->input->post('c');//国家信息
  2014. $data = $this->logistics->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2015. if(!$data)
  2016. {
  2017. echo json_encode(array('success'=>false));exit;
  2018. }
  2019. else
  2020. {
  2021. echo json_encode(array('money'=>sprintf("%.2f",$data[0]['firstmoney']),'success'=>true));
  2022. }
  2023. }
  2024. }
  2025. public function _hl()
  2026. {
  2027. $post = $this->input->post(NULL, TRUE);
  2028. if(isset($post['cy']))
  2029. {
  2030. $hl = 0;
  2031. $cy = $this->input->post('cy');//币种ID
  2032. $cy = $this->typeclass->read($cy);
  2033. $gethl = $this->hl->get_hl();
  2034. foreach ($gethl as $v)
  2035. {
  2036. $code = str_replace(" ","",$v['code']);
  2037. if($code == $cy['title'])
  2038. {
  2039. $hl = $v['refePrice']/100;
  2040. }
  2041. }
  2042. echo json_encode(array('msg'=>$hl,'success'=>true));
  2043. }
  2044. }
  2045. public function _operation()
  2046. {
  2047. $post = $this->input->post(NULL, TRUE);
  2048. if(isset($post['type']))
  2049. {
  2050. $type = $this->input->post('type');
  2051. $id = $this->input->post('id');
  2052. $msg = $this->input->post('msg');
  2053. if($type == 1)//禁止发货
  2054. {
  2055. $d = $this->fullordersmt->read($id);
  2056. if($d['library'] != 1)
  2057. {
  2058. echo json_encode(array('msg'=>'操作失败,订单非未出库状态!','success'=>false));exit;
  2059. }
  2060. if($msg == "")
  2061. {
  2062. echo json_encode(array('msg'=>'必须填写禁止原因!','success'=>false));exit;
  2063. }
  2064. if($d['print'] < 3)
  2065. {
  2066. $a = "订单未打印,";
  2067. }
  2068. else
  2069. {
  2070. $a = "";
  2071. }
  2072. if($this->fullordersmt->save(array('libraryconfirm'=>1,'librarynot'=>$a.$msg),$id))
  2073. {
  2074. echo json_encode(array('msg'=>'操作成功','l'=>1,'d'=>$id,'success'=>true));exit;
  2075. }
  2076. else
  2077. {
  2078. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2079. }
  2080. }
  2081. if($type == 6)//允许发货
  2082. {
  2083. $d = $this->fullordersmt->read($id);
  2084. if($d['library'] > 1)
  2085. {
  2086. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2087. }
  2088. if($d['print'] < 3)
  2089. {
  2090. $a = "订单未打印,";
  2091. }
  2092. else
  2093. {
  2094. $a = "";
  2095. }
  2096. if($this->fullordersmt->save(array('libraryconfirm'=>2,'librarynot'=>$a.$msg),$id))
  2097. {
  2098. echo json_encode(array('msg'=>'操作成功','l'=>1,'d'=>$id,'success'=>true));exit;
  2099. }
  2100. else
  2101. {
  2102. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2103. }
  2104. }
  2105. if($type == 7)//禁止打印
  2106. {
  2107. $d = $this->fullordersmt->read($id);
  2108. if($d['printtime'] != 0)
  2109. {
  2110. echo json_encode(array('msg'=>'订单已打印,操作失败','success'=>false));exit;
  2111. }
  2112. if($d['library'] > 1)
  2113. {
  2114. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2115. }
  2116. if($d['print'] == 3)
  2117. {
  2118. echo json_encode(array('msg'=>'操作失败,订单已打印!','success'=>false));exit;
  2119. }
  2120. if($d['print'] < 3)
  2121. {
  2122. $a = "订单未打印,";
  2123. }
  2124. else
  2125. {
  2126. $a = "";
  2127. }
  2128. if($this->fullordersmt->save(array('print'=>1),$id))
  2129. {
  2130. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2131. }
  2132. else
  2133. {
  2134. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2135. }
  2136. }
  2137. if($type == 8)//允许打印
  2138. {
  2139. $d = $this->fullordersmt->read($id);
  2140. /**
  2141. if($d['printtime'] != 0)
  2142. {
  2143. echo json_encode(array('msg'=>'订单已打印,操作失败','success'=>false));exit;
  2144. }
  2145. **/
  2146. if($d['library'] > 1)
  2147. {
  2148. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2149. }
  2150. if($d['print'] < 3)
  2151. {
  2152. $a = "订单未打印,";
  2153. }
  2154. else
  2155. {
  2156. $a = "";
  2157. }
  2158. if($d['printtime'] == '0')
  2159. {
  2160. $bcprint = 2;
  2161. }
  2162. else
  2163. {
  2164. $bcprint = 3;
  2165. }
  2166. if($this->fullordersmt->save(array('print'=>$bcprint,'failed'=>'','librarynot'=>$a.$d['librarynot']),$id))
  2167. {
  2168. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2169. }
  2170. else
  2171. {
  2172. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2173. }
  2174. }
  2175. if($type == 9)//关闭
  2176. {
  2177. if($this->fullordersmt->save(array('failed'=>''),$id))
  2178. {
  2179. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2180. }
  2181. else
  2182. {
  2183. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2184. }
  2185. }
  2186. if($type == 10)//允许出库
  2187. {
  2188. if($this->fullordersmt->save(array('failed'=>'','libraryconfirm'=>2),$id))
  2189. {
  2190. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2191. }
  2192. else
  2193. {
  2194. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2195. }
  2196. }
  2197. if($type == 2)//填写运单、修改运单
  2198. {
  2199. $d = $this->fullordersmt->read($id);
  2200. if($d['source'] == 1)
  2201. {
  2202. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>216,'dlz'=>3),$id);
  2203. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  2204. }
  2205. $ex = $this->express->read($d['express']);
  2206. $shop = $this->shop->read($d['shop']);
  2207. if($d['express'] == 0)
  2208. {
  2209. echo json_encode(array('msg'=>'操作失败,未选择物流方式!','success'=>false));exit;
  2210. }
  2211. if($d['library'] == 3 || ($d['print'] == 3 && $d['libraryconfirm'] == 1))
  2212. {
  2213. echo json_encode(array('msg'=>'操作失败,不允许填写运单号!','success'=>false));exit;
  2214. }
  2215. if($d['dlz'] == 1 || $d['dlz'] == 2)//如果已经声明过需要操作修改声明
  2216. {
  2217. $msg = trim($msg);
  2218. $obtain = $this->apismt->get_obtain($d['orderinfo'],$shop['code']);//修改声明先查询之前物流信息
  2219. if(isset($obtain['logistics_no']))
  2220. {
  2221. $result = $this->apismt->get_editout($obtain['logistics_no'],$msg,'all',$d['orderinfo'],$obtain['service_name'],$ex['aecode'],$shop['code']);
  2222. }
  2223. if(isset($result['result_success']) && $result['result_success'] == 1)
  2224. {
  2225. $this->fullordersmt->save(array('waybill'=>$msg),$id);
  2226. /** 合并信息处理开始-修改声明 **/
  2227. if($d['merge'] != '0')
  2228. {
  2229. $hdata = $this->fullordersmt->find_all("merge = '".$d['merge']."' and id != '".$d['id']."' and dlz = '0' and source != 1");$i=0;
  2230. foreach ($hdata as $v)
  2231. {
  2232. $obtain = $this->apismt->get_obtain($v['orderinfo'],$shop['code']);//修改声明先查询之前物流信息
  2233. if(isset($obtain['logistics_no']))
  2234. {
  2235. $result = $this->apismt->get_editout($obtain['logistics_no'],$msg,'all',$v['orderinfo'],$obtain['service_name'],$ex['aecode'],$shop['code']);
  2236. }
  2237. if(isset($result['result_success']) && $result['result_success'] == 1)
  2238. {
  2239. $this->fullordersmt->save(array('waybill'=>$msg),$v['id']);
  2240. }
  2241. else
  2242. {
  2243. $this->fullordersmt->save(array('waybill'=>$msg,'dlz'=>4),$v['id']);
  2244. }
  2245. $i++;
  2246. if($i > 10)
  2247. {
  2248. break;
  2249. }
  2250. }
  2251. }
  2252. /** 合并信息处理结束开始 **/
  2253. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  2254. }
  2255. else
  2256. {
  2257. $this->fullordersmt->save(array('waybill'=>$msg,'dlz'=>4),$id);
  2258. echo json_encode(array('msg'=>'修改声明失败,请重试','xq'=>$obtain,'success'=>false));exit;
  2259. }
  2260. }
  2261. else if($d['dlz'] == '0')//未发货声明状态
  2262. {
  2263. $msg = trim($msg);
  2264. $result_t = $this->apismt->get_out($msg,'all',$d['orderinfo'],$ex['aecode'],$shop['code']);
  2265. if(isset($result_t['result']))
  2266. {
  2267. $result = $result_t['result'];
  2268. if(isset($result['success']) && $result['success'] == "true"){
  2269. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>1),$id);
  2270. /** 合并信息处理开始-发货声明 **/
  2271. if($d['merge'] != '0')
  2272. {
  2273. $hdata = $this->fullordersmt->find_all("merge = '".$d['merge']."' and id != '".$d['id']."' and dlz = '0' and source != 1");$i=0;
  2274. foreach ($hdata as $v)
  2275. {
  2276. $result_t = $this->apismt->get_out($msg,'all',$v['orderinfo'],$ex['aecode'],$shop['code']);
  2277. if(isset($result_t['result'])){
  2278. $result = $result_t['result'];
  2279. if(isset($result['success']) && $result['success'] == "true")
  2280. {
  2281. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>1),$v['id']);
  2282. }
  2283. else
  2284. {
  2285. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>2),$v['id']);
  2286. }
  2287. }else{
  2288. if(isset($d['result_success']) && $d['result_success'] == "true")
  2289. {
  2290. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>1),$v['id']);
  2291. }
  2292. else
  2293. {
  2294. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>2),$v['id']);
  2295. }
  2296. }
  2297. $i++;
  2298. if($i > 10)
  2299. {
  2300. break;
  2301. }
  2302. }
  2303. }
  2304. /** 合并信息处理结束开始 **/
  2305. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  2306. }else{
  2307. echo json_encode(array('msg'=>'操作失败,请联系技术','success'=>false));exit;
  2308. }
  2309. }
  2310. else
  2311. {
  2312. if(isset($result_t['result_success']) && $result_t['result_success'] == "true"){
  2313. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>1),$id);
  2314. /** 合并信息处理开始-发货声明 **/
  2315. if($d['merge'] != '0')
  2316. {
  2317. $hdata = $this->fullordersmt->find_all("merge = '".$d['merge']."' and id != '".$d['id']."' and dlz = '0' and source != 1");$i=0;
  2318. foreach ($hdata as $v)
  2319. {
  2320. $result_t = $this->apismt->get_out($msg,'all',$v['orderinfo'],$ex['aecode'],$shop['code']);
  2321. if(isset($d['result_success']) && $d['result_success'] == "true")
  2322. {
  2323. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>1),$v['id']);
  2324. }
  2325. else
  2326. {
  2327. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>2),$v['id']);
  2328. }
  2329. $i++;
  2330. if($i > 10)
  2331. {
  2332. break;
  2333. }
  2334. }
  2335. }
  2336. echo json_encode(array('msg'=>'操作成功','success'=>false));exit;
  2337. }else{
  2338. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>2),$id);
  2339. echo json_encode(array('msg'=>'声明失败:'.$result_t['error_msg'],'success'=>false));exit;
  2340. }
  2341. }
  2342. }
  2343. else
  2344. {
  2345. if($this->fullordersmt->save(array('waybill'=>$msg),$id))
  2346. {
  2347. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  2348. }
  2349. else
  2350. {
  2351. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));
  2352. }
  2353. }
  2354. }
  2355. }
  2356. }
  2357. public function _merge()
  2358. {
  2359. $user = $this->user->get_api($_SESSION['api']);
  2360. if(!$user)
  2361. {
  2362. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2363. }
  2364. $post = $this->input->post(NULL, TRUE);
  2365. if(isset($post['s']))
  2366. {
  2367. $id_arr = $this->input->post('s');
  2368. $id_arr = explode(',',trim( $id_arr,','));
  2369. $id_arr = array_reverse($id_arr);
  2370. if(!$id_arr)
  2371. {
  2372. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2373. }
  2374. if(count($id_arr) < 2)
  2375. {
  2376. echo json_encode(array('msg'=>'缺少可合并单!','success'=>false));exit;
  2377. }
  2378. $tmp_list = $this->db->from('fullordersmt')->where_in('id',$id_arr)->select('id,orderinfo,number,type,express')->get()->result_array();
  2379. $count_warehouse_list = [];
  2380. $count_express_list = [];
  2381. $flag = 0;
  2382. $flag_str = '';
  2383. foreach ($tmp_list as $k => $v) {
  2384. $count_warehouse_list[$v['type']] = $v['type'];
  2385. if(empty($v['express'])){
  2386. $flag = 1;
  2387. $flag_str.= $v['number'].'仓库未选,请先选快递;';
  2388. }
  2389. $count_express_list[$v['express']] = $v['express'];
  2390. }
  2391. if($flag == 1){
  2392. echo json_encode(array('msg'=>$flag_str,'success'=>false));exit;
  2393. }
  2394. if(count($count_warehouse_list) > 1){
  2395. echo json_encode(array('msg'=>'合并单的仓库不一致,无法合并!','success'=>false));exit;
  2396. }
  2397. if(count($count_express_list) > 1){
  2398. echo json_encode(array('msg'=>'合并单的快递不一致,无法合并!','success'=>false));exit;
  2399. }
  2400. $post = array();
  2401. $u = $this->fullordersmt->read($id_arr[0]);
  2402. unset($id_arr[0]);
  2403. $this->db->trans_begin();
  2404. $hd = $this->fullordersmthb->get_orderinfo($u['orderinfo']);
  2405. if(!$hd)
  2406. {
  2407. $this->fullordersmthb->insert($u);
  2408. }
  2409. //相加
  2410. $post['shouldmoney'] = $u['shouldmoney'];//购买应收金额
  2411. $post['budget'] = $u['budget'];//预估到帐金额
  2412. $post['expressmoney']= $u['expressmoney'];//物流金额
  2413. //$post['refundy'] = $u['refundy'];//补/退原额
  2414. //$post['refundj'] = $u['refundj'];//补/退净额
  2415. $post['cost'] = $u['cost'];//成本金额
  2416. //$post['zzl'] = $u['zzl'];//总重量
  2417. //$post['zsbjz'] = $u['zsbjz'];//总申报价值
  2418. $post['ts'] = $u['ts'];//条数
  2419. $post['cost'] = $u['cost'];//成本金额
  2420. //追加
  2421. $post['rpaypal'] = $u['rpaypal'];//补/退交易号
  2422. $post['rtext'] = $u['rtext'];//补/退原因
  2423. $post['pay'] = $u['pay'];//付款方式
  2424. $post['paypal'] = $u['paypal'];//交易号
  2425. $post['clientremarks'] = $u['clientremarks'];//客户留言
  2426. $post['product'] = $u['product'];//商品名称
  2427. //$post['issku'] = $u['issku'];//sku
  2428. //$post['orderremarks'] = $u['orderremarks'];//订单备注
  2429. $post['shipremarks'] = $u['shipremarks'];//仓库品名
  2430. //产品追加
  2431. $post['fpdata'] = $u['fpdata'];//产品内容
  2432. $post['whlabel'] = $u['whlabel'];//产品对应库存码
  2433. $merge = $u['id'];
  2434. $d = array($u['id']);$order = '';
  2435. $zsl = 0;$zccsl = 0;
  2436. foreach ($id_arr as $v)
  2437. {
  2438. $v = $this->fullordersmt->read($v);
  2439. if($u['type'] != $v['type'])
  2440. {
  2441. echo json_encode(array('msg'=>'仓库不一致,无法合并!','success'=>false));exit;
  2442. }
  2443. if($v['shop'] = $u['shop'])
  2444. {
  2445. $hd = $this->fullordersmthb->get_orderinfo($v['orderinfo']);
  2446. if(!$hd)
  2447. {
  2448. $this->fullordersmthb->insert($v);
  2449. }
  2450. // $post['shouldmoney'] += $v['shouldmoney'];//购买应收金额
  2451. // $post['budget'] += $v['budget'];//预估到帐金额
  2452. // $post['expressmoney'] += $v['expressmoney'];//物流金额
  2453. //$post['refundy'] += $v['refundy'];//补/退原额
  2454. //$post['refundj'] += $v['refundj'];//补/退净额
  2455. $post['cost'] += $v['cost'];//成本金额
  2456. //$post['zzl'] += $v['zzl'];//总重量
  2457. //$post['zsbjz'] += $v['zsbjz'];//总申报价值
  2458. $post['ts'] += $v['ts'];//条数
  2459. //$post['rpaypal'] .= $v['rpaypal'];//补/退交易号
  2460. //$post['rtext'] .= $v['rtext'];//补/退原因
  2461. //$post['pay'] .= (stripos($post['pay'],$v['pay']) !== false)?'':';'.$v['pay'];//付款方式
  2462. //$post['paypal'] .= $v['paypal'];//交易号
  2463. $post['clientremarks'] .= $v['clientremarks'];//客户留言
  2464. $post['product'] .= $v['product'];//商品名称
  2465. //$post['issku'] .= $v['issku'];//sku
  2466. //$post['orderremarks'] .= $v['orderremarks'];//订单备注
  2467. $post['shipremarks'] .= $v['shipremarks'];//仓库品名
  2468. $post['fpdata'] .= $v['fpdata'];//产品内容
  2469. $post['whlabel'] .= ltrim($v['whlabel'],'|');//产品对应库存码
  2470. $d[] = $v['id'];
  2471. $order .= $v['orderinfo'].'('.$v['number'].')、';
  2472. $wl = $this->whlabel->find_all("zd = '".$v['number']."'");//查找是否有占用库存情况
  2473. $i = 0;
  2474. if($wl)//如果有那么清除所有占用
  2475. {
  2476. foreach ($wl as $val)
  2477. {
  2478. if($val['sku'] == 'Preset' && $val['state'] == '9')
  2479. {
  2480. $this->whlabel->remove($val['id']);//删除预设
  2481. $i++;
  2482. }
  2483. else
  2484. {
  2485. $this->whlabel->save(array('zd'=>''),$val['id']);//专属
  2486. $i++;
  2487. }
  2488. }
  2489. }
  2490. $zsl += count($wl);
  2491. $zccsl += $i;
  2492. $this->fullordersmt->save(array('merge'=>$u['id'],'mergeid'=>1,'orderremarks'=>' 《合并信息》:'.'已合并到'.$u['orderinfo'].'('.$u['number'].')中; '.$v['orderremarks'],'print'=>1,'libraryconfirm'=>1,'whlabel'=>'','fpdata'=>'','shipremarks'=>''),$v['id']);
  2493. }
  2494. }
  2495. //计算出单条价值
  2496. /**
  2497. if($post['zsbjz'] < 1 || $post['ts'] < 1)
  2498. {
  2499. //$post['dtsbjz'] = 0;
  2500. }
  2501. else
  2502. {
  2503. //$post['dtsbjz'] = $post['zsbjz']/$post['ts'];//单条申报价
  2504. }
  2505. **/
  2506. $post['orderremarks'] = ' 《合并信息》:由'.rtrim($order,'、').'合并而来; '.$u['orderremarks'];;
  2507. $post['merge'] = $u['id'];
  2508. //$post['mergeid'] = 1;
  2509. //合并重复项
  2510. $hbcfw = explode('|',trim($post['whlabel'],'|'));
  2511. $hbcff = explode(';',trim($post['fpdata'],';'));
  2512. $c = 0;
  2513. $hbw = array();
  2514. $hbf = array();
  2515. for($i=0;$i<count($hbcfw);$i++)
  2516. {
  2517. $w = explode('-',$hbcfw[$i]);
  2518. $f = explode('|',$hbcff[$i]);
  2519. if(isset($w[2]))
  2520. {
  2521. $w2 = ($w[2]==0)?0:'';
  2522. }
  2523. else
  2524. {
  2525. $w2 = '';
  2526. }
  2527. if(!isset($hbw[$w[0].$w2]))
  2528. {
  2529. $hbw[$w[0].$w2] = $hbcfw[$i];
  2530. $hbf[$w[0].$w2] = $hbcff[$i];
  2531. }
  2532. else
  2533. {
  2534. $c++;
  2535. $cw = explode('-',$hbw[$w[0].$w2]);
  2536. $cf = explode('|',$hbf[$w[0].$w2]);
  2537. if($cw[2] != 0 && $w[2] != 0)
  2538. {
  2539. $cf[2] += $f[2];
  2540. $cf[9] .= '~'.$f[9];
  2541. $hbf[$w[0].$w2] = implode("|",$cf);
  2542. $cw[1] += $f[2];
  2543. $cw[2] .= '~'.$f[9];
  2544. $hbw[$w[0].$w2] = implode("-",$cw);
  2545. }
  2546. else if($cw[2] == 0 && $w[2] == 0)
  2547. {
  2548. $cf[2] += $f[2];
  2549. $hbf[$w[0].$w2] = implode("|",$cf);
  2550. $cw[1] += $f[2];
  2551. $hbw[$w[0].$w2] = implode("-",$cw);
  2552. }
  2553. else
  2554. {
  2555. $hbw[] = $hbcfw[$i];
  2556. $hbf[] = $hbcff[$i];
  2557. }
  2558. }
  2559. }
  2560. if($c > 0)
  2561. {
  2562. $post['fpdata'] = implode(";",$hbf).';';
  2563. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  2564. }
  2565. //合并重复项结束
  2566. $this->fullordersmt->save($post,$u['id']);
  2567. if ($this->db->trans_status() === FALSE)
  2568. {
  2569. $this->db->trans_commit();
  2570. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2571. }
  2572. else
  2573. {
  2574. $this->db->trans_commit();
  2575. echo json_encode(array('msg'=>'操作成功','d'=>($d),'b'=>$u['id'],'success'=>true));
  2576. }
  2577. }
  2578. }
  2579. public function _split()
  2580. {
  2581. $user = $this->user->get_api($_SESSION['api']);
  2582. if($user)
  2583. {
  2584. $fgshop = "";$sid = "";
  2585. $user = explode('|',trim($user['shop'],'|'));
  2586. foreach ($user as $value)
  2587. {
  2588. $fgshop .= " shop = ".$value." or";
  2589. $sid .= " id = ".$value." or";
  2590. }
  2591. }
  2592. $post = $this->input->post(NULL, TRUE);
  2593. if(isset($post['id']))
  2594. {
  2595. $id = $this->input->post('id');
  2596. $data = $this->fullordersmt->find_all("merge = '$id' and print !=3 and library =1 and (".rtrim($fgshop,'or').")");
  2597. $datanum = $this->fullordersmt->find_count("merge = '$id' and (".rtrim($fgshop,'or').")");
  2598. if($data && count($data) == $datanum)
  2599. {
  2600. foreach ($data as $k=>$v)
  2601. {
  2602. unset($data[$k]['id']);
  2603. unset($data[$k]['express']);
  2604. unset($data[$k]['printtype']);
  2605. unset($data[$k]['review']);
  2606. unset($data[$k]['reviewtime']);
  2607. $t = $this->fullordersmt->get_orderinfo($v['orderinfo']);
  2608. $this->fullordersmt->save($v,$t['id']);
  2609. }
  2610. echo json_encode(array('msg'=>'拆分成功!','success'=>true));
  2611. }
  2612. else
  2613. {
  2614. echo json_encode(array('msg'=>'有订单不符合条件,请重试','success'=>false));exit;
  2615. }
  2616. }
  2617. }
  2618. //评价管理
  2619. public function _evaluate()
  2620. {
  2621. $user = $this->user->get_api($_SESSION['api']);
  2622. if($user)
  2623. {
  2624. $fgshop = "";$sid = "";
  2625. $user = explode('|',trim($user['shop'],'|'));
  2626. foreach ($user as $value)
  2627. {
  2628. $fgshop .= " shop = ".$value." or";
  2629. $sid .= " id = ".$value." or";
  2630. }
  2631. }
  2632. $post = $this->input->post(NULL, TRUE);
  2633. if(isset($post['page']))
  2634. {
  2635. $page = $this->input->post('page',true);
  2636. $perpage = $this->input->post('perpage',true);
  2637. $shop = $this->input->post('shop',true);
  2638. $where = "1=1 and evaluate = 0 and (".rtrim($fgshop,'or').")";
  2639. if($shop)
  2640. {
  2641. $where .= " and shop = '$shop'";
  2642. }
  2643. //数据排序
  2644. $order_str = "id desc";
  2645. if(empty($page))
  2646. {
  2647. $start = 0;
  2648. $perpage = 1;
  2649. }
  2650. else
  2651. {
  2652. $start = ($page - 1)*$perpage;
  2653. }
  2654. //取得信息列表
  2655. $info_list = $this->fullordersmt->find_all($where,'id,shop,orderinfo,number,operation',$order_str,$start,$perpage);
  2656. //格式化数据
  2657. foreach ($info_list as $key=>$value)
  2658. {
  2659. $shop = $this->shop->read($value['shop']);
  2660. $info_list[$key]['shop'] = $shop['shopname'];
  2661. $info_list[$key]['operation'] = "评价";
  2662. }
  2663. $total = $this->fullordersmt->find_count($where);
  2664. $pagenum = ceil($total/$perpage);
  2665. $over = $total-($start+$perpage);
  2666. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2667. echo json_encode($rows);exit;
  2668. }
  2669. $this->_Template('fullordersmt_evaluate',$this->data);
  2670. }
  2671. //订单消息
  2672. public function _state()
  2673. {
  2674. $user = $this->user->get_api($_SESSION['api']);
  2675. if($user)
  2676. {
  2677. $fgshop = "";$sid = "";
  2678. $user = explode('|',trim($user['shop'],'|'));
  2679. foreach ($user as $value)
  2680. {
  2681. $fgshop .= " shop = ".$value." or";
  2682. $sid .= " id = ".$value." or";
  2683. }
  2684. }
  2685. $post = $this->input->post(NULL, TRUE);
  2686. if(isset($post['page']))
  2687. {
  2688. $page = $this->input->post('page',true);
  2689. $perpage = $this->input->post('perpage',true);
  2690. $timetk = $this->input->post('timetk',true);
  2691. $timetj = $this->input->post('timetj',true);
  2692. $shop = $this->input->post('shop',true);
  2693. $source = $this->input->post('source',true);
  2694. $state = $this->input->post('state',true);
  2695. $review = $this->input->post('review',true);
  2696. $expressstate = $this->input->post('expressstate',true);
  2697. $express = $this->input->post('express',true);
  2698. $orderinfo = $this->input->post('orderinfo',true);
  2699. $user = $this->input->post('user',true);
  2700. $name = $this->input->post('name',true);
  2701. $waybill = $this->input->post('waybill',true);
  2702. $timetk = strtotime($timetk);
  2703. $timetj = strtotime($timetj);
  2704. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  2705. if($timetk && $timetj)
  2706. {
  2707. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2708. }
  2709. if($shop)
  2710. {
  2711. $where .= " and shop = '$shop'";
  2712. }
  2713. if($source)
  2714. {
  2715. $where .= " and source = '$source'";
  2716. }
  2717. if($state)
  2718. {
  2719. $where .= " and state = '$state'";
  2720. }
  2721. if($review)
  2722. {
  2723. $where .= " and review = '$review'";
  2724. }
  2725. if($expressstate != "")
  2726. {
  2727. $where .= " and expressstate = '$expressstate'";
  2728. }
  2729. if($express)
  2730. {
  2731. $where .= " and express = '$express'";
  2732. }
  2733. if($orderinfo)
  2734. {
  2735. $where .= " and orderinfo = '$orderinfo'";
  2736. }
  2737. if($user)
  2738. {
  2739. $where .= " and user = '$user'";
  2740. }
  2741. if($name)
  2742. {
  2743. $where .= " and name = '$name'";
  2744. }
  2745. if($waybill)
  2746. {
  2747. $where .= " and waybill = '$waybill'";
  2748. }
  2749. //数据排序
  2750. $order_str = "id desc";
  2751. if(empty($page))
  2752. {
  2753. $start = 0;
  2754. $perpage = 1;
  2755. }
  2756. else
  2757. {
  2758. $start = ($page - 1)*$perpage;
  2759. }
  2760. //取得信息列表
  2761. $info_list = $this->fullordersmt->find_all($where,'id,shop,user,orderinfo,number,country,state,library,librarytime,exstate,express,waybill,content,exstateerror',$order_str,$start,$perpage);
  2762. //格式化数据
  2763. foreach ($info_list as $key=>$value)
  2764. {
  2765. $ud = $this->fullordersmt->read($value['id']);
  2766. $shop = $this->shop->read($value['shop']);
  2767. $info_list[$key]['shop'] = $shop['shopname'];
  2768. $info_list[$key]['user'] = $shop['shopuser'];
  2769. $country = $this->country->read($value['country']);
  2770. $info_list[$key]['country'] = $country['name'];
  2771. $state = $this->typeclass->read($value['state']);
  2772. if($ud['source'] != '1')
  2773. {
  2774. $info_list[$key]['state'] = "<a href='https://trade.aliexpress.com/order_detail.htm?orderId=".$value['orderinfo']."' target='_blank'>".$state['title']."</a>";
  2775. }
  2776. else
  2777. {
  2778. $info_list[$key]['state'] = $state['title'];
  2779. }
  2780. if($value['library'] == 1)
  2781. {
  2782. $info_list[$key]['library'] = "未出库";
  2783. }
  2784. else if($value['library'] == 2)
  2785. {
  2786. $info_list[$key]['library'] = "已出库";
  2787. }
  2788. else if($value['library'] == 3)
  2789. {
  2790. $info_list[$key]['library'] = "已退库";
  2791. }
  2792. if($value['librarytime'] == '0')
  2793. {
  2794. $info_list[$key]['librarytime'] = '无';
  2795. }
  2796. else
  2797. {
  2798. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  2799. }
  2800. if($value['exstate'] == 0)
  2801. {
  2802. $info_list[$key]['exstate'] = "未取件";
  2803. }
  2804. else if($value['exstate'] == 1)
  2805. {
  2806. $info_list[$key]['exstate'] = "已揽收";
  2807. }
  2808. else if($value['exstate'] == 2)
  2809. {
  2810. $info_list[$key]['exstate'] = "在途中";
  2811. }
  2812. else if($value['exstate'] == 3)
  2813. {
  2814. $info_list[$key]['exstate'] = "派送中";
  2815. }
  2816. else if($value['exstate'] == 4)
  2817. {
  2818. $info_list[$key]['exstate'] = "签收";
  2819. }
  2820. if($value['express'])
  2821. {
  2822. $express = $this->express->read($value['express']);
  2823. $info_list[$key]['express'] = $express['servicename'];
  2824. }
  2825. else
  2826. {
  2827. $info_list[$key]['express'] = '';
  2828. }
  2829. }
  2830. $total = $this->fullordersmt->find_count($where);
  2831. $pagenum = ceil($total/$perpage);
  2832. $over = $total-($start+$perpage);
  2833. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2834. echo json_encode($rows);exit;
  2835. }
  2836. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2837. $this->data['wlshop'] = $wlshop;
  2838. $this->data['express'] = $this->express->find_all();
  2839. $this->_Template('fullordersmt_state',$this->data);
  2840. }
  2841. //审核订单
  2842. public function _review()
  2843. {
  2844. $user = $this->user->get_api($_SESSION['api']);
  2845. $fgshop = "";
  2846. if($user)
  2847. {
  2848. $fgshop = "";$sid = "";
  2849. $user = explode('|',trim($user['shop'],'|'));
  2850. foreach ($user as $value)
  2851. {
  2852. $fgshop .= " shop = ".$value." or";
  2853. }
  2854. $fgshop = " and (".rtrim($fgshop,'or').")";
  2855. }
  2856. $post = $this->input->post(NULL, TRUE);
  2857. if(isset($post['page']))
  2858. {
  2859. $page = $this->input->post('page',true);
  2860. $perpage = $this->input->post('perpage',true);
  2861. $source = $this->input->post('source',true);
  2862. $warehouse = $this->input->post('warehouse',true);
  2863. $express = $this->input->post('express',true);
  2864. $user = $this->input->post('user',true);
  2865. $shop = $this->input->post('shop',true);
  2866. $review = $this->input->post('review',true);
  2867. $orderinfo = $this->input->post('orderinfo',true);
  2868. $number = $this->input->post('number',true);
  2869. $timetk = $this->input->post('timetk',true);
  2870. $timetj = $this->input->post('timetj',true);
  2871. $timetk = strtotime($timetk);
  2872. $timetj = strtotime($timetj);
  2873. $where = "mergeid = 0".$fgshop;
  2874. if($timetk && $timetj)
  2875. {
  2876. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2877. }
  2878. if($source)
  2879. {
  2880. $where .= " and source = '$source'";
  2881. }
  2882. if($shop)
  2883. {
  2884. $where .= " and shop = '$shop'";
  2885. }
  2886. if($warehouse)
  2887. {
  2888. $where .= " and type = '$warehouse'";
  2889. }
  2890. if($express)
  2891. {
  2892. $where .= " and express = '$express'";
  2893. }
  2894. if($user)
  2895. {
  2896. $where .= " and user = '$user'";
  2897. }
  2898. if($review)
  2899. {
  2900. $where .= " and review = '$review'";
  2901. }
  2902. if($orderinfo)
  2903. {
  2904. $where .= " and orderinfo = '$orderinfo'";
  2905. }
  2906. if($number)
  2907. {
  2908. $where .= " and number = '$number'";
  2909. }
  2910. //数据排序
  2911. $order_str = "id desc";
  2912. if(empty($page))
  2913. {
  2914. $start = 0;
  2915. $perpage = 1;
  2916. }
  2917. else
  2918. {
  2919. $start = ($page - 1)*$perpage;
  2920. }
  2921. //取得信息列表
  2922. $info_list = $this->fullordersmt->find_all($where,'id,shop,user,type,orderinfo,number,client,express,buytime,shouldmoney,review,currencytitle,library');
  2923. //格式化数据
  2924. foreach ($info_list as $key=>$value)
  2925. {
  2926. $lr = $this->fullordersmt->read($value['id']);
  2927. $shop = $this->shop->read($value['shop']);
  2928. $info_list[$key]['shop'] = $shop['shopname'];
  2929. $info_list[$key]['user'] = $shop['shopuser'];
  2930. $warehouse = $this->warehouse->read($value['type']);
  2931. $info_list[$key]['type'] = $warehouse['title'];
  2932. $express = $this->express->read($value['express']);
  2933. $info_list[$key]['express'] = $express['servicename'];
  2934. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  2935. if($value['review'] == 1)
  2936. {
  2937. $info_list[$key]['review'] = "未送审";
  2938. }
  2939. else if($value['review'] == 2)
  2940. {
  2941. $info_list[$key]['review'] = "待审核";
  2942. }
  2943. else if($value['review'] == 3)
  2944. {
  2945. $info_list[$key]['review'] = "不通过";
  2946. }
  2947. else if($value['review'] == 4)
  2948. {
  2949. $info_list[$key]['review'] = "取消重审";
  2950. }
  2951. else if($value['review'] == 5)
  2952. {
  2953. $info_list[$key]['review'] = "审核通过";
  2954. }
  2955. else if($value['review'] == 6)
  2956. {
  2957. $info_list[$key]['review'] = "自动通过";
  2958. }
  2959. if($value['review'] == 2)
  2960. {
  2961. $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>";
  2962. }
  2963. else if($value['review'] == 3)
  2964. {
  2965. $info_list[$key]['library'] = "<p><b class='fullorderreview' data-type='5' data-id='".$value['id']."'>审核通过</b></p>";
  2966. }
  2967. else if($value['review'] == 5)
  2968. {
  2969. $info_list[$key]['library'] = "<p><b class='fullorderreview' data-type='3' data-id='".$value['id']."'>不通过</b></p>";
  2970. }
  2971. else
  2972. {
  2973. $info_list[$key]['library'] = "";
  2974. }
  2975. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$lr['currencytitle'];
  2976. $lr['hl'] = $lr['hl']==0?6.71:$lr['hl'];
  2977. $cost = $lr['cost']/$lr['hl'];
  2978. $currencytitle = $lr['budget']-$lr['refundj']-$cost-$lr['expressmoney'];
  2979. $info_list[$key]['currencytitle'] = sprintf("%.2f",$currencytitle).' '.$lr['currencytitle'];
  2980. }
  2981. $total = $this->fullordersmt->find_count($where);
  2982. $pagenum = ceil($total/$perpage);
  2983. $over = $total-($start+$perpage);
  2984. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2985. echo json_encode($rows);exit;
  2986. }
  2987. $this->_Template('fullordersmt_review',$this->data);
  2988. }
  2989. //导出资金统计excel
  2990. public function _fmexcel()
  2991. {
  2992. $user = $this->user->get_api($_SESSION['api']);
  2993. if($user)
  2994. {
  2995. $fgshop = "";$sid = "";
  2996. $user = explode('|',trim($user['shop'],'|'));
  2997. foreach ($user as $value)
  2998. {
  2999. $fgshop .= " shop = ".$value." or";
  3000. $sid .= " id = ".$value." or";
  3001. }
  3002. }
  3003. if(isset($_GET['excel']))
  3004. {
  3005. $timetk = $this->input->get('timetk',true);
  3006. $timetj = $this->input->get('timetj',true);
  3007. $shop = $this->input->get('shop',true);
  3008. $source = $this->input->get('source',true);
  3009. $state = $this->input->get('state',true);
  3010. $type = $this->input->get('type',true);
  3011. $orderinfo = $this->input->get('orderinfo',true);
  3012. $user = $this->input->get('user',true);
  3013. $name = $this->input->get('name',true);
  3014. $timetk = strtotime($timetk);
  3015. $timetj = strtotime($timetj);
  3016. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3017. if($timetk && $timetj)
  3018. {
  3019. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3020. }
  3021. if($shop)
  3022. {
  3023. $where .= " and shop = '$shop'";
  3024. }
  3025. if($source)
  3026. {
  3027. $where .= " and source = '$source'";
  3028. }
  3029. if($state)
  3030. {
  3031. if($state == 1)
  3032. {
  3033. $where .= " and state = '$state'";
  3034. }
  3035. }
  3036. if($type)
  3037. {
  3038. $where .= " and type = '$type'";
  3039. }
  3040. if($orderinfo)
  3041. {
  3042. $where .= " and orderinfo = '$orderinfo'";
  3043. }
  3044. if($user)
  3045. {
  3046. $where .= " and user = '$user'";
  3047. }
  3048. if($name)
  3049. {
  3050. $where .= " and name = '$name'";
  3051. }
  3052. //取得信息列表
  3053. $info_list = $this->fullordersmt->find_all($where,'id,shop,user,number,orderinfo,client,country,dtime,ftime,express,waybill,shouldmoney,refund,currency,budget,fpdata,hl,currencytitle');
  3054. //格式化数据
  3055. $i = 1;$shouldmoney = 0;$refund = 0;$budget = 0;$currency = 0;$hl=1;
  3056. foreach ($info_list as $key=>$value)
  3057. {
  3058. $info_list[$key]['id'] = $i;
  3059. if($value['currencytitle'] != "CNY")
  3060. {
  3061. $hl=$value['hl'];
  3062. }
  3063. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  3064. $budget=$budget+($value['budget']*$hl);
  3065. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  3066. $refund=$refund+($value['refund']*$hl);
  3067. $shop = $this->shop->read($value['shop']);
  3068. $info_list[$key]['shop'] = $shop['shopname'];
  3069. $info_list[$key]['user'] = $shop['shopuser'];
  3070. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  3071. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  3072. $country = $this->country->read($value['country']);
  3073. $info_list[$key]['country'] = $country['name'];
  3074. $express = $this->express->read($value['express']);
  3075. $info_list[$key]['express'] = $express['servicename'];
  3076. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  3077. $info_list[$key]['refund'] = $value['refund'].' '.$value['currencytitle'];
  3078. $info_list[$key]['budget'] = $value['budget'].' '.$value['currencytitle'];
  3079. $info_list[$key]['currency'] = sprintf("%.2f",$value['shouldmoney']-$value['budget']).' '.$value['currencytitle'];
  3080. $fpdata = array();
  3081. if(stripos($value['fpdata'],';') !== false)
  3082. {
  3083. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  3084. foreach ($fpdata as $ke=>$va)
  3085. {
  3086. $v = explode('|',rtrim($va,'|'));
  3087. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  3088. }
  3089. }
  3090. $info_list[$key]['fpdata'] = $fpdata;
  3091. $i++;
  3092. }
  3093. $data = array($shouldmoney.' CNY',$refund.' CNY',$currency.' CNY',$budget.' CNY');
  3094. $title = "订单资金信息";
  3095. $titlename = "<table border=1>
  3096. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  3097. <tr>
  3098. <td>NO.</td>
  3099. <td>店铺</td>
  3100. <td>负责人</td>
  3101. <td>编号</td>
  3102. <td>订单号</td>
  3103. <td>客户姓名</td>
  3104. <td>国家</td>
  3105. <td>订单日期</td>
  3106. <td>发货日期</td>
  3107. <td>快递公司</td>
  3108. <td>运单号</td>
  3109. <td>订单金额</td>
  3110. <td>退款金额</td>
  3111. <td>手续费</td>
  3112. <td>预估金额</td>
  3113. <td>
  3114. <table border=1>
  3115. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  3116. <tr>
  3117. <td>产品</td>
  3118. <td>条数</td>
  3119. <td>数量</td>
  3120. </tr>
  3121. </table>
  3122. </td>
  3123. <td>总条数</td>
  3124. </tr>
  3125. </table>";
  3126. $filename = $title.".xls";
  3127. $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";
  3128. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  3129. }
  3130. }
  3131. //导出订单excel
  3132. public function _fdexcel()
  3133. {
  3134. if(isset($_GET['excel']))
  3135. {
  3136. $page = $this->input->post('page',true);
  3137. $perpage = $this->input->post('perpage',true);
  3138. $timetk = $this->input->post('timetk',true);
  3139. $timetj = $this->input->post('timetj',true);
  3140. $shop = $this->input->post('shop',true);
  3141. $source = $this->input->post('source',true);
  3142. $state = $this->input->post('state',true);
  3143. $review = $this->input->post('review',true);
  3144. $express = $this->input->post('express',true);
  3145. $orderinfo = $this->input->post('orderinfo',true);
  3146. $user = $this->input->post('user',true);
  3147. $name = $this->input->post('name',true);
  3148. $waybill = $this->input->post('waybill',true);
  3149. $timetk = strtotime($timetk);
  3150. $timetj = strtotime($timetj);
  3151. $where = "1=1 and mergeid = 0";
  3152. if($timetk && $timetj)
  3153. {
  3154. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3155. }
  3156. if($shop)
  3157. {
  3158. $where .= " and shop = '$shop'";
  3159. }
  3160. if($source)
  3161. {
  3162. $where .= " and source = '$source'";
  3163. }
  3164. if($state)
  3165. {
  3166. $where .= " and state = '$state'";
  3167. }
  3168. if($review)
  3169. {
  3170. $where .= " and review = '$review'";
  3171. }
  3172. if($express)
  3173. {
  3174. $where .= " and express = '$express'";
  3175. }
  3176. if($orderinfo)
  3177. {
  3178. $where .= " and orderinfo = '$orderinfo'";
  3179. }
  3180. if($user)
  3181. {
  3182. $where .= " and user = '$user'";
  3183. }
  3184. if($name)
  3185. {
  3186. $where .= " and name = '$name'";
  3187. }
  3188. if($waybill)
  3189. {
  3190. $where .= " and waybill = '$waybill'";
  3191. }
  3192. //取得信息列表
  3193. $info_list = $this->fullordersmt->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');
  3194. //格式化数据
  3195. $i = 1;$shouldmoney = 0;$hl=1;
  3196. foreach ($info_list as $key=>$value)
  3197. {
  3198. $info_list[$key]['id'] = $i;
  3199. if($value['source'] == 1)
  3200. {
  3201. $info_list[$key]['source'] = "线下订单";
  3202. }
  3203. else if($value['source'] == 2)
  3204. {
  3205. $info_list[$key]['source'] = "PC订单";
  3206. }
  3207. else if($value['source'] == 3)
  3208. {
  3209. $info_list[$key]['source'] = "手机订单";
  3210. }
  3211. if($value['currencytitle'] != "CNY")
  3212. {
  3213. $hl=$value['hl'];
  3214. }
  3215. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  3216. $shop = $this->shop->read($value['shop']);
  3217. $info_list[$key]['shop'] = $shop['shopname'];
  3218. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  3219. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  3220. $state = $this->typeclass->read($value['state']);
  3221. $info_list[$key]['state'] = $state['title'];
  3222. $country = $this->country->read($value['country']);
  3223. $info_list[$key]['country'] = $country['name'];
  3224. $express = $this->express->read($value['express']);
  3225. $info_list[$key]['express'] = $express['servicename'];
  3226. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  3227. $fpdata = array();
  3228. if(stripos($value['fpdata'],';') !== false)
  3229. {
  3230. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  3231. foreach ($fpdata as $ke=>$va)
  3232. {
  3233. $v = explode('|',rtrim($va,'|'));
  3234. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  3235. }
  3236. }
  3237. $info_list[$key]['fpdata'] = $fpdata;
  3238. $i++;
  3239. }
  3240. $data = array($shouldmoney.' CNY');
  3241. $title = "订单信息表";
  3242. $titlename = "<table border=1>
  3243. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  3244. <tr>
  3245. <td>NO.</td>
  3246. <td>店铺</td>
  3247. <td>编号</td>
  3248. <td>订单号</td>
  3249. <td>订单类型</td>
  3250. <td>客户姓名</td>
  3251. <td>收件人名称</td>
  3252. <td>收货人地址</td>
  3253. <td>城市</td>
  3254. <td>邮编</td>
  3255. <td>州</td>
  3256. <td>国家</td>
  3257. <td>收件电话</td>
  3258. <td>订单日期</td>
  3259. <td>发货日期</td>
  3260. <td>订单状态</td>
  3261. <td>订单金额</td>
  3262. <td>快递公司</td>
  3263. <td>运单号</td>
  3264. <td>订单备注</td>
  3265. <td>客户备注</td>
  3266. <td>
  3267. <table border=1>
  3268. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  3269. <tr>
  3270. <td>产品</td>
  3271. <td>条数</td>
  3272. <td>数量</td>
  3273. </tr>
  3274. </table>
  3275. </td>
  3276. <td>总条数</td>
  3277. </tr>
  3278. </table>";
  3279. $filename = $title.".xls";
  3280. $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";
  3281. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  3282. }
  3283. }
  3284. public function _black()
  3285. {
  3286. $post = $this->input->post(NULL, TRUE);
  3287. if(isset($post['bd']))
  3288. {
  3289. $bd = $this->input->post('bd',true);
  3290. $rows = $this->fullordersmt->read($bd);
  3291. $post['shop'] = $rows['shop'];
  3292. $post['source'] = 1;
  3293. $post['name'] = $rows['client'];
  3294. $post['email'] = $rows['email'];
  3295. $post['phone'] = $rows['phone'];
  3296. $post['country'] = $rows['country'];
  3297. $post['money'] = $rows['shouldmoney'];
  3298. $post['num'] = 1;
  3299. $post['time'] = $rows['dtime'];
  3300. $post['province'] = $rows['province'];
  3301. $post['city'] = $rows['city'];
  3302. $post['street'] = $rows['street'];
  3303. $post['address'] = $rows['address'];
  3304. $post['address2'] = $rows['address2'];
  3305. $post['zipcode'] = $rows['zipcode'];
  3306. $post['type'] = 2;
  3307. if($this->customer->insert($post))
  3308. {
  3309. $this->fullordersmt->save(array('black'=>1),$bd);
  3310. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  3311. }
  3312. else
  3313. {
  3314. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3315. }
  3316. }
  3317. }
  3318. public function _ryf()
  3319. {
  3320. $post = $this->input->post(NULL, TRUE);
  3321. if(isset($post['bd']))
  3322. {
  3323. $bd = $this->input->post('bd',true);
  3324. $d = $this->fullordersmt->read($bd);
  3325. if($d['state'] == 207 || $d['state'] == 207)//订单状态为等待发货或等待部分发货才可更改为允许发货
  3326. {
  3327. if($d['print'] < 3)//打印状态为未打印
  3328. {
  3329. $print = 1;//未打印
  3330. $libraryconfirm = 1;//不允许出库
  3331. $a = "订单未打印,";
  3332. }
  3333. else//已打印订单
  3334. {
  3335. $libraryconfirm = 2;//允许出库
  3336. $a = "";
  3337. }
  3338. if($this->fullordersmt->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  3339. {
  3340. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  3341. }
  3342. else
  3343. {
  3344. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3345. }
  3346. }
  3347. if($this->fullordersmt->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  3348. {
  3349. echo json_encode(array('msg'=>'操作失败!订单未非发货状态','success'=>false));exit;
  3350. }
  3351. else
  3352. {
  3353. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3354. }
  3355. }
  3356. }
  3357. public function _fsstate()
  3358. {
  3359. $post = $this->input->post(NULL, TRUE);
  3360. if(isset($post['s']))
  3361. {
  3362. $id_arr = $this->input->post('s');
  3363. $id_arr = explode(',',$id_arr);
  3364. if(!$id_arr)
  3365. {
  3366. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  3367. }
  3368. foreach ($id_arr as $v)
  3369. {
  3370. $data = $this->fullordersmt->read($v);
  3371. $warehouse = $this->warehouse->read($data['type']);
  3372. $fs = $this->notice->get_ordertatus($data['state']);
  3373. if($fs)
  3374. {
  3375. $ck = $this->_email($fs['content'],$data,$warehouse['company']);
  3376. if($ck == 1)
  3377. {
  3378. $this->fullordersmt->save(array('fscontent'=>date('Y-m-d H:i:s',time()).'已发送:'.$fs['title'].' - '),$v);
  3379. }
  3380. }
  3381. }
  3382. echo json_encode(array('msg'=>'发送完成!','success'=>true));exit;
  3383. }
  3384. }
  3385. public function _power()
  3386. {
  3387. $user = $this->user->get_api($_SESSION['api']);
  3388. $post = $this->input->post(NULL, TRUE);
  3389. if(isset($post['id']))
  3390. {
  3391. $id = $this->input->post('id',true);
  3392. $fullorder = $this->fullordersmt->read($id);
  3393. $express = $this->express->read($fullorder['express']);
  3394. $warehouse = $this->warehouse->read($fullorder['type']);
  3395. if(($warehouse['zd'] == '1' || stripos($fullorder['whlabel'],'z|') !== false) && $fullorder['library'] == '2')
  3396. {
  3397. echo json_encode(array('msg'=>'需要先退库释放库存后才可重置!','success'=>false));exit;
  3398. }
  3399. /**
  3400. if($fullorder['print'] == '3' && isset($express['iscode']) && ($express['iscode'] == 'ARAMEX' || $express['iscode'] == 'TOLL' || $express['iscode'] == 'FEDEX'))
  3401. {
  3402. $lj = $this->ali->get_lj($fullorder['number'],2,'订单修改');
  3403. if($lj != '1' && $lj != '订单不存在')
  3404. {
  3405. echo json_encode(array('msg'=>$lj,'success'=>false));exit;
  3406. }
  3407. }
  3408. **/
  3409. $this->db->trans_begin();
  3410. $this->fullordersmt->save(array('library'=>1,'librarytime'=>0,'libraryconfirm'=>2,'print'=>1,'printtime'=>0,'printnumber'=>0,'retreattime'=>0,'librarynot'=>'订单未打印,未审核或未通过','review'=>1,'reviewtime'=>0,'state'=>207,'waybill'=>'','waybill2'=>'','oldwaybill'=>'-'.date('Ymd',$fullorder['printtime']).'/'.$fullorder['waybill']),$id);
  3411. if($fullorder['merge'] != '0')
  3412. {
  3413. $hdata = $this->fullordersmt->find_all("merge = '".$fullorder['merge']."' and id != '".$id."'");
  3414. foreach ($hdata as $v)
  3415. {
  3416. $this->fullordersmt->save(array('library'=>1,'librarytime'=>0,'libraryconfirm'=>2,'print'=>1,'printtime'=>0,'printnumber'=>0,'retreattime'=>0,'librarynot'=>'订单未打印,未审核或未通过','review'=>1,'reviewtime'=>0,'state'=>207,'waybill'=>'','waybill2'=>'','waybillid'=>'','oldwaybill'=>'-'.date('Ymd',$fullorder['printtime']).'/'.$fullorder['waybill'],'yhs'=>0,'failed'=>''),$v['id']);
  3417. }
  3418. }
  3419. $warehouse = $this->warehouse->read($fullorder['warehouse']);
  3420. $typeclass = $this->typeclass->read($fullorder['state']);
  3421. $express = $this->express->read($fullorder['express']);
  3422. $printtype = array(1=>'运单',2=>'发货单',3=>'不打印单据');
  3423. $teset['number']=$fullorder['number'];
  3424. $teset['orderinfo']=$fullorder['orderinfo'];
  3425. $teset['shop']=$fullorder['shop'];
  3426. $teset['user']=$user['userid'];
  3427. $teset['ip']=$this->input->ip_address();
  3428. $teset['time']=time();
  3429. $teset['warehouse']=(isset($warehouse['title']))?$warehouse['title']:'未选择';
  3430. $teset['state']=(isset($typeclass['title']))?$typeclass['title']:'未选择';
  3431. $teset['express']=(isset($express['title']))?$express['servicename']:'未选择';
  3432. $teset['printtype']=(isset($printtype[$fullorder['printtype']]))?$printtype[$fullorder['printtype']]:'未选择';
  3433. $teset['reviewtime']=($fullorder['reviewtime'] > '0')?date('Y-m-d H:i:s',$fullorder['reviewtime']):'无';
  3434. $teset['printtime']=($fullorder['printtime'] > '0')?date('Y-m-d H:i:s',$fullorder['printtime']):'无';
  3435. $teset['librarytime']=($fullorder['librarytime'] > '0')?date('Y-m-d H:i:s',$fullorder['librarytime']):'无';
  3436. $teset['shipremarks']=$fullorder['shipremarks'];
  3437. $teset['fpdata']=$fullorder['fpdata'];
  3438. if(!$this->fullreset->insert($teset))
  3439. {
  3440. echo json_encode(array('msg'=>'重置失败,请重试','success'=>true));exit;
  3441. }
  3442. if ($this->db->trans_status() === TRUE)
  3443. {
  3444. $this->db->trans_commit();
  3445. $th_info = $this->retreatlogs->getInfoByNumber($fullorder['number']);
  3446. if(!empty($th_info)){
  3447. $this->retreatlogs->save(array('cz_time'=>time()),$th_info['id']);
  3448. }
  3449. echo json_encode(array('msg'=>'重置成功','success'=>true));exit;
  3450. }
  3451. else
  3452. {
  3453. $this->db->trans_rollback();
  3454. echo json_encode(array('msg'=>'重置失败,请重试','success'=>false));exit;
  3455. }
  3456. }
  3457. }
  3458. public function _expresstype()
  3459. {
  3460. $post = $this->input->post(NULL, TRUE);
  3461. if(isset($post['id']))
  3462. {
  3463. $id = $this->input->post('id',true);
  3464. $data = $this->express->read($id);
  3465. echo json_encode(array('msg'=>$data['type'],'success'=>true));exit;
  3466. }
  3467. }
  3468. public function _email($content,$data,$shopname)
  3469. {
  3470. $express = $this->express->read($data['express']);
  3471. $t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
  3472. $h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['servicename'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
  3473. $content = str_replace($t,$h,$content);
  3474. $this->load->library('email');
  3475. $config['protocol'] = 'smtp';
  3476. $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
  3477. $config['smtp_port'] = 465;
  3478. $config['smtp_user'] = 'service@email.supernovahair.com';
  3479. $config['smtp_pass'] = 'LONGyihair374';
  3480. $config['smtp_crypto'] = 'ssl';
  3481. $config['crlf'] = "\r\n";
  3482. $config['newline'] = "\r\n";
  3483. $this->email->initialize($config);
  3484. $this->email->from('service@email.supernovahair.com',$shopname);
  3485. $this->email->to($data['email']);//收件
  3486. $this->email->subject('The product you purchased has a new progress');//标题
  3487. $this->email->message($content);//内容
  3488. if ( ! $this->email->send())
  3489. {
  3490. return 2;
  3491. }
  3492. else
  3493. {
  3494. return 1;
  3495. }
  3496. }
  3497. public function _error()
  3498. {
  3499. if(isset($_SESSION['api']))
  3500. {
  3501. $user = $this->user->get_api($_SESSION['api']);
  3502. $usp = $user;
  3503. $fgshop = "";$sid = "";
  3504. $user = explode('|',trim($user['shop'],'|'));
  3505. foreach ($user as $value)
  3506. {
  3507. $fgshop .= " shop = ".$value." or";
  3508. $sid .= " id = ".$value." or";
  3509. }
  3510. }
  3511. $post = $this->input->post(NULL, TRUE);
  3512. if(isset($post['page']))
  3513. {
  3514. $page = $this->input->post('page',true);
  3515. $perpage = $this->input->post('perpage',true);
  3516. $orderinfo = $this->input->post('orderinfo',true);
  3517. $waybill = $this->input->post('waybill',true);
  3518. $number = $this->input->post('number',true);
  3519. $timetk = $this->input->post('timetk',true);
  3520. $timetj = $this->input->post('timetj',true);
  3521. $timetk = strtotime($timetk);
  3522. $timetj = strtotime($timetj);
  3523. $where = "failed !='' and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3524. if($orderinfo)
  3525. {
  3526. $where .= " and orderinfo = '$orderinfo'";
  3527. }
  3528. if($waybill)
  3529. {
  3530. $where .= " and waybill = '$waybill'";
  3531. }
  3532. if($number)
  3533. {
  3534. $where .= " and number = '$number'";
  3535. }
  3536. if($timetk && $timetj)
  3537. {
  3538. $timetj = $timetj+24*3600;
  3539. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3540. }
  3541. //数据排序
  3542. $order_str = "dtime desc";
  3543. if(empty($page))
  3544. {
  3545. $start = 0;
  3546. $perpage = 1;
  3547. }
  3548. else
  3549. {
  3550. $start = ($page - 1)*$perpage;
  3551. }
  3552. $info_list = $this->fullordersmt->find_all($where,'id,shop,type,orderinfo,number,express,failed,operation',$order_str,$start,$perpage);
  3553. //格式化数据
  3554. foreach ($info_list as $key=>$value)
  3555. {
  3556. $ud = $this->fullordersmt->read($value['id']);
  3557. $shop = $this->shop->read($value['shop']);
  3558. $info_list[$key]['shop'] = $shop['shopname'];
  3559. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'>".$value['orderinfo']."<p>";
  3560. $warehouse = $this->warehouse->read($value['type']);
  3561. $warehousetitle = $warehouse['title'];
  3562. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  3563. $info_list[$key]['type'] = $warehousetitle;
  3564. if($value['express'] != 0)
  3565. {
  3566. $express = $this->express->read($value['express']);
  3567. $expressservicename = $express['servicename'];
  3568. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  3569. $info_list[$key]['express'] = $expressservicename;
  3570. }
  3571. else
  3572. {
  3573. $info_list[$key]['express'] = "无";
  3574. }
  3575. $x = "";
  3576. if($ud['review'] >4 && $ud['print'] == 1)
  3577. {
  3578. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  3579. }
  3580. else if($ud['review'] >4 && $ud['print'] == 3 && $ud['libraryconfirm'] == 1)
  3581. {
  3582. $x = "<p class='ckn'><b class='fojzof' data-type='10' data-id='".$value['id']."'>清除错误</b></p>";
  3583. }
  3584. else
  3585. {
  3586. $x = "<p class='ckn'><b class='fojzof' data-type='9' data-id='".$value['id']."'>关闭</b></p>";
  3587. }
  3588. $info_list[$key]['operation'] = $x;
  3589. }
  3590. $total = $this->fullordersmt->find_count($where);
  3591. $pagenum = ceil($total/$perpage);
  3592. $over = $total-($start+$perpage);
  3593. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3594. echo json_encode($rows);exit;
  3595. }
  3596. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3597. $this->data['wlshop'] = $wlshop;
  3598. $this->data['express'] = $this->express->find_all();
  3599. $user = $this->user->get_api($_SESSION['api']);
  3600. $powerid = $this->power->read($user['power']);
  3601. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3602. $pid = '';
  3603. foreach ($powertext as $v)
  3604. {
  3605. $pid .= " id = ".$v." or";
  3606. }
  3607. $fullorderexcel = $this->fullorderexcel->find_all("type = '100004' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3608. $this->data['fullorderexcel'] = $fullorderexcel;
  3609. $this->_Template('fullordersmt_error',$this->data);
  3610. }
  3611. //关闭订单详情时保存备注
  3612. public function _bcbz()
  3613. {
  3614. $post = $this->input->post(NULL, TRUE);
  3615. if(isset($post['id']))
  3616. {
  3617. $fpcount = $this->input->post('fpcount',true);
  3618. if(!$fpcount)
  3619. {
  3620. echo json_encode(array('msg'=>'未设置商品信息!','success'=>false));exit;
  3621. }
  3622. $post['edittime'] = time();
  3623. $fpdata = $this->input->post('fpdata');
  3624. $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
  3625. $post['fpdata'] = $fpdata;
  3626. $post['state'] = $this->input->post('state');
  3627. $post['type'] = $this->input->post('warehouse');
  3628. $post['ioss'] = $this->input->post('ioss');
  3629. $rtime = $this->input->post('rtime',true);
  3630. if($rtime)
  3631. {
  3632. $post['rtime'] = strtotime($rtime);
  3633. }
  3634. $id = $this->input->post('id',TRUE);
  3635. $whlabel = $this->input->post('whlabel',true);
  3636. $data = $this->fullordersmt->read($id);
  3637. $editstate = $post['state'];
  3638. if($data['library'] == 1)
  3639. {
  3640. if($data['print'] != 3 && $data['review'] < 5)
  3641. {
  3642. $post['libraryconfirm'] = 1;
  3643. $post['librarynot'] = "订单未打印";
  3644. }
  3645. else if($data['print'] != 3 && $data['review'] > 4)
  3646. {
  3647. $post['print'] = 1;
  3648. $post['libraryconfirm'] = 1;
  3649. $post['librarynot'] = "订单未打印,订单审核后修改";
  3650. }
  3651. else
  3652. {
  3653. $post['libraryconfirm'] = 1;
  3654. $post['librarynot'] = "订单打印后修改";
  3655. }
  3656. }
  3657. if($data['yhs'] == 1)
  3658. {
  3659. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  3660. }
  3661. if((($post['express'] == 2 || $post['express'] == 63 || $post['express'] == 64 || $post['express'] == 81) && $post['type'] != 5) || ($post['express'] != 2 && $post['express'] != 63 && $post['express'] != 64 && $post['express'] != 81 && $post['type'] == 5))
  3662. {
  3663. echo json_encode(array('msg'=>'此快递方式必须选择美国仓!','success'=>false));exit;
  3664. }
  3665. if(($post['express'] == '5' || $post['express'] == '24' || $post['express'] == '31') && $data['country'] != 192)
  3666. {
  3667. echo json_encode(array('msg'=>'非美国无法选择Fedex!','success'=>false));exit;
  3668. }
  3669. if(($post['express'] == '28' || $post['express'] == '7') && $data['country'] != 191)
  3670. {
  3671. echo json_encode(array('msg'=>'非英国无法选择CNE和GES!','success'=>false));exit;
  3672. }
  3673. $express = $this->express->read($post['express']);
  3674. if($express['ioss'] == 1 && $post['ioss'] == '')
  3675. {
  3676. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  3677. }
  3678. if(isset($post['address']) && (strlen($post['address']) > $express['addresssize'] || strlen($post['address2']) > $express['addresssize']))
  3679. {
  3680. echo json_encode(array('msg'=>'此快递地址不可超出'.$express['addresssize'].'个字符','success'=>false));exit;
  3681. }
  3682. if($data['type'] != '5' && $post['type'] == '5' && $editstate != '207')
  3683. {
  3684. echo json_encode(array('msg'=>'等待发货状态才可选择美仓!','success'=>false));exit;
  3685. }
  3686. if($data['library'] == 2 && $data['print'] == 3 && $data['waybill'] != $post['waybill'])
  3687. {
  3688. echo json_encode(array('msg'=>'不允许修改运单号','success'=>true));exit;
  3689. }
  3690. //南非 限制邮箱
  3691. if($post['country'] == 166){
  3692. if(empty($post['email'])){
  3693. echo json_encode(array('msg'=>'惠程安迈世发货需要有邮箱!','success'=>false));exit;
  3694. }else{
  3695. if(!$this->logic_order->checkEmail($post['email'])){
  3696. echo json_encode(array('msg'=>'邮箱格式不正确!','success'=>false));exit;
  3697. }
  3698. }
  3699. }
  3700. if(empty($post['zsbjz']*1)){
  3701. echo json_encode(array('msg'=>'申报金额不可为0!','success'=>false));exit;
  3702. }
  3703. if(empty($post['dtsbjz']*1)){
  3704. echo json_encode(array('msg'=>'单条申报价值不能为0!','success'=>false));exit;
  3705. }
  3706. $thisdata = $data;
  3707. $warehouse = $this->warehouse->read($thisdata['type']);
  3708. $warehousenew = $this->warehouse->read($post['type']);
  3709. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  3710. {
  3711. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  3712. }
  3713. /**
  3714. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  3715. {
  3716. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  3717. }
  3718. **/
  3719. if($data['shop'] == '9' && $post['type'] != '7' && $post['type'] != '8' && $post['type'] != '9')
  3720. {
  3721. echo json_encode(array('msg'=>'仓库选择错误!','success'=>false));exit;
  3722. }
  3723. //减少代码复用吧
  3724. $lo_ret = $this->logic_order->checkEditExpress($post,['plat'=>'fullordersmt']);
  3725. if($lo_ret['code'] != 1){
  3726. echo json_encode(array('msg'=>$lo_ret['msg'],'success'=>false));exit;
  3727. }
  3728. /**
  3729. if($warehousenew['zd'] == '1' && $editstate != $thisdata['state'] && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  3730. {
  3731. echo json_encode(array('msg'=>'如需更改订单状态,请先把仓库选择为非开启库存模式仓库或等待订单出库!','success'=>false));exit;
  3732. }
  3733. if($warehousenew['zd'] == '1' && $editstate != '207' && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  3734. {
  3735. echo json_encode(array('msg'=>'非待发货状态,不允许修改为开启库存模式仓库','success'=>false));exit;
  3736. }
  3737. **/
  3738. //开始注释 xyxg
  3739. /**
  3740. $ft = array();
  3741. $ftdata = explode('|',rtrim($fpcount,'|'));
  3742. foreach ($ftdata as $va)
  3743. {
  3744. $ftitle = '';
  3745. $va = explode('-',trim($va,'-'));
  3746. foreach ($va as $v)
  3747. {
  3748. $v = $this->typeclass->read($v);
  3749. $ftitle .= $v['title'].' ';
  3750. }
  3751. $ft[] = rtrim($ftitle,' ');
  3752. }
  3753. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  3754. {
  3755. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  3756. if($tskcyz['t'] > '0')
  3757. {
  3758. echo $tskcyz['m'];exit;
  3759. }
  3760. }
  3761. $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']);//旧状态、新状态、仓库占单设置、仓库预设设置、新仓库、新产品简化数字、旧产品数字、旧产品名称、订单号、订单店铺、旧订单仓库、旧产品简化数字
  3762. if($kcyz['t'] > '0')
  3763. {
  3764. echo $kcyz['m'];exit;
  3765. }
  3766. else
  3767. {
  3768. if($this->fullordersmt->save($post,$id))
  3769. {
  3770. echo json_encode(array('msg'=>'保存成功','id'=>$id,'a'=>$kcyz,'success'=>true));exit;
  3771. }
  3772. else
  3773. {
  3774. echo json_encode(array('msg'=>'保存失败,请重试','success'=>false));exit;
  3775. }
  3776. }
  3777. //结束注释
  3778. **/
  3779. $warehouse = $this->warehouse->read($post['type']);
  3780. if($data['library'] == 1 || ($data['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  3781. {
  3782. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  3783. if($kcyz['t'] > '0')
  3784. {
  3785. echo $kcyz['m'];exit;
  3786. }
  3787. else if($kcyz['fpdata'] != '')
  3788. {
  3789. $post['whlabel'] = $kcyz['whlabel'];
  3790. $post['fpdata'] = $kcyz['fpdata'];
  3791. }
  3792. }
  3793. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  3794. $post['sfxh'] = $fl['sfxh'];
  3795. $post['ckfl'] = $fl['ckfl'];
  3796. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  3797. if($this->fullordersmt->save($post,$id))
  3798. {
  3799. echo json_encode(array('msg'=>'保存成功','id'=>$id,'success'=>true));exit;
  3800. }
  3801. else
  3802. {
  3803. echo json_encode(array('msg'=>'保存失败,请重试','success'=>false));exit;
  3804. }
  3805. }
  3806. }
  3807. //验证地址
  3808. public function _yzaddress()
  3809. {
  3810. $post = $this->input->post(NULL, TRUE);
  3811. if(isset($post['address']))
  3812. {
  3813. $address = $this->input->post('address',true);
  3814. $address2 = $this->input->post('address2',true);
  3815. $city = $this->input->post('city',true);
  3816. $province = $this->input->post('province',true);
  3817. $zipcode = $this->input->post('zipcode',true);
  3818. $barcode = $this->usps->get_address(array('address'=>$address,'address2'=>$address2,'city'=>$city,'province'=>$province,'zipcode'=>$zipcode));
  3819. echo $barcode;
  3820. }
  3821. }
  3822. //订单退货
  3823. public function _return()
  3824. {
  3825. $post = $this->input->post(NULL, TRUE);
  3826. if(isset($post['orderinfo']))
  3827. {
  3828. $orderinfo = $this->input->post('orderinfo',true);
  3829. $data = $this->fullordersmt->get_orderinfo($orderinfo);
  3830. $fu = 'fullordersmt';
  3831. $bctime = date('Ymd',time());
  3832. if($data['returndata'] != "")
  3833. {
  3834. echo json_encode(array('msg'=>'请求失败,已有退货信息!','success'=>false));exit;
  3835. }
  3836. if($data['library'] != 2){
  3837. echo json_encode(array('msg'=>'此单不是出库状态,不允许退货','success'=>false));exit;
  3838. }
  3839. $barcode = $this->usps->get_return($data);
  3840. if(isset($barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription']))
  3841. {
  3842. echo json_encode(array('msg'=>$barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription'],'success'=>false));exit;
  3843. }
  3844. else
  3845. {
  3846. $pdf = $this->_pdf($barcode['ReturnLabel'],'t-'.$barcode['TrackingNumber'],$bctime);
  3847. $read = 'PostalRouting:'.$barcode['PostalRouting'].' - TrackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['TrackingNumber'].'.pdf" target="_blank">'.$barcode['TrackingNumber'].'</a>';
  3848. $this->$fu->save(array('returndata'=>$read),$data['id']);
  3849. echo json_encode(array('msg'=>'退货成功!','data'=>$read,'success'=>true));exit;
  3850. }
  3851. }
  3852. }
  3853. public function _pdf($pdf,$title,$bctime)
  3854. {
  3855. $pdf_path = './data/pdf/'.$bctime.'/';
  3856. $file_base64 = $pdf;
  3857. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  3858. $file_base64 = base64_decode($file_base64);
  3859. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  3860. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  3861. return $bctime;
  3862. }
  3863. //管理
  3864. public function _aaa()
  3865. {
  3866. $dt = 0;
  3867. if(isset($_SESSION['api']))
  3868. {
  3869. $user = $this->user->get_api($_SESSION['api']);
  3870. $usp = $user;
  3871. $fgshop = "";$sid = "";
  3872. $user = explode('|',trim($user['shop'],'|'));
  3873. foreach ($user as $value)
  3874. {
  3875. $fgshop .= " shop = ".$value." or";
  3876. $sid .= " id = ".$value." or";
  3877. }
  3878. }
  3879. $post = $this->input->post(NULL, TRUE);
  3880. if(isset($post['page']))
  3881. {
  3882. $page = $this->input->post('page',true);
  3883. $perpage = $this->input->post('perpage',true);
  3884. $warehouse = $this->input->post('warehouse',true);
  3885. $timetk = $this->input->post('timetkk',true);
  3886. $timetj = $this->input->post('timetjj',true);
  3887. $shop = $this->input->post('shop',true);
  3888. $source = $this->input->post('source',true);
  3889. $state = $this->input->post('state',true);
  3890. $review = $this->input->post('review',true);
  3891. $type = $this->input->post('type',true);
  3892. $express = $this->input->post('express',true);
  3893. $orderinfo = $this->input->post('orderinfo',true);
  3894. $user = $this->input->post('user',true);
  3895. $client = $this->input->post('name',true);
  3896. $fullname = $this->input->post('fullname',true);
  3897. $waybill = $this->input->post('waybill',true);
  3898. $number = $this->input->post('number',true);
  3899. $email = $this->input->post('email',true);
  3900. $dlz = $this->input->post('dlz',true);
  3901. $print = $this->input->post('print',true);
  3902. $library = $this->input->post('library',true);
  3903. $xztime = $this->input->post('xztime',true);
  3904. $timetk = strtotime($timetk)-1;
  3905. $timetj = strtotime($timetj);
  3906. $px = $this->input->post('px',true);
  3907. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3908. if($warehouse)
  3909. {
  3910. $where .= " and type = '$warehouse'";
  3911. }
  3912. if($timetk && $timetj)
  3913. {
  3914. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3915. }
  3916. if($shop)
  3917. {
  3918. $where .= " and shop = '$shop'";
  3919. }
  3920. if($source)
  3921. {
  3922. $where .= " and source = '$source'";
  3923. }
  3924. if($state)
  3925. {
  3926. $where .= " and state = '$state'";
  3927. }
  3928. if($review)
  3929. {
  3930. $where .= " and review = '$review'";
  3931. }
  3932. if($type)
  3933. {
  3934. $where .= " and type = '$type'";
  3935. }
  3936. if($express)
  3937. {
  3938. $where .= " and express = '$express'";
  3939. }
  3940. if($orderinfo)
  3941. {
  3942. $where .= " and orderinfo = '$orderinfo'";
  3943. }
  3944. if($user)
  3945. {
  3946. $where .= " and user = '$user'";
  3947. }
  3948. if($client)
  3949. {
  3950. $where .= " and client like '%$client%'";
  3951. }
  3952. if($waybill)
  3953. {
  3954. $where .= " and waybill = '$waybill'";
  3955. }
  3956. if($number)
  3957. {
  3958. $where .= " and number = '$number'";
  3959. }
  3960. if($email)
  3961. {
  3962. $where .= " and email = '$email'";
  3963. }
  3964. if($library)
  3965. {
  3966. $where .= " and library = '$library'";
  3967. }
  3968. if($print)
  3969. {
  3970. $where .= " and print = '$print'";
  3971. }
  3972. if($dlz != '')
  3973. {
  3974. $where .= " and dlz = '$dlz'";
  3975. }
  3976. if($fullname)
  3977. {
  3978. $where .= " and fullname = '$fullname'";
  3979. }
  3980. //数据排序
  3981. if($px)
  3982. {
  3983. $order_str = $px." desc";
  3984. }
  3985. else
  3986. {
  3987. $order_str = "numberpx desc";
  3988. }
  3989. if(empty($page))
  3990. {
  3991. $start = 0;
  3992. $perpage = 1;
  3993. }
  3994. else
  3995. {
  3996. $start = ($page - 1)*$perpage;
  3997. }
  3998. //取得信息列表id,shop,type,source,user,orderinfo,number,name,state,buytime,clientremarks,review,print,library,libraryconfirm,express,waybill,orderremarks,black
  3999. $info_list = $this->fullordersmt1->find_all($where,'id,shop,type,orderinfo,number,fullname,state,buytime,review,libraryconfirm,express,waybill,orderremarks,library,black,clientremarks,waybillid',$order_str,$start,$perpage);
  4000. //格式化数据
  4001. foreach ($info_list as $key=>$value)
  4002. {
  4003. $ud = $this->fullordersmt1->read($value['id']);
  4004. $ud['address'] = str_replace("'","’",$ud['address']);
  4005. $ud['name'] = str_replace("'","’",$ud['name']);
  4006. $customer = $ud['source'] != 1?$this->customersmt1->get_fullname($ud['fullname']):$this->customersmt1->get_shopdata($value['shop'],$ud['name'],$ud['address']);
  4007. //$a = array_column($customer, 'email'); //三维找其中健的数组
  4008. //$a = array_flip($a); //键和值调换
  4009. $currency = $this->country->read($ud['country']);
  4010. $name = ($ud['source'] == 1)?$ud['name']:$value['fullname'];
  4011. $lkh = "<p>".$name."</p><p style='color:#8f54fb'>".$currency['ename']."</p>";
  4012. if($customer)
  4013. {
  4014. if($customer['type'] == 1 && $customer['num'] > 1)
  4015. {
  4016. $lkh .= "<p style='color:#FF3333'>老客户</p>";
  4017. }
  4018. else if($customer['type'] == 2)
  4019. {
  4020. $hmsp = $this->shop->read($customer[0]['shop']);
  4021. $lkh .= "<p style='color:#9900CC'>黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  4022. }
  4023. }
  4024. $info_list[$key]['fullname'] = $lkh;
  4025. $shop = $this->shop->read($value['shop']);
  4026. $info_list[$key]['shop'] = $shop['shopname'];
  4027. //$info_list[$key]['user'] = $shop['shopuser'];
  4028. $warehouse = $this->warehouse->read($value['type']);
  4029. $warehousetitle = $warehouse['title'];
  4030. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  4031. $info_list[$key]['type'] = $warehousetitle;
  4032. $typeclass = $this->typeclass->read($value['state']);
  4033. if($ud['source'] != 1)
  4034. {
  4035. $info_list[$key]['state'] = "<a href='https://trade.aliexpress.com/order_detail.htm?orderId=".$value['orderinfo']."' target='_blank'>".$typeclass['title']."</a>";
  4036. }
  4037. else
  4038. {
  4039. $info_list[$key]['state'] = $typeclass['title'];
  4040. }
  4041. if(!$value['buytime'])
  4042. {
  4043. $info_list[$key]['buytime'] = '<p>无</p>';
  4044. }
  4045. else
  4046. {
  4047. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']-$dt).'</p><p>'.date('H:i:s',$value['buytime']-$dt).'</p>';
  4048. }
  4049. if($value['review'] == 1)
  4050. {
  4051. $info_list[$key]['review'] = "未送审";
  4052. }
  4053. else if($value['review'] == 2)
  4054. {
  4055. $info_list[$key]['review'] = "<font style='color:#555'>待审核</font>";
  4056. }
  4057. else if($value['review'] == 3)
  4058. {
  4059. $info_list[$key]['review'] = "<font style='color:#f90f4b'>不通过</font>";
  4060. }
  4061. else if($value['review'] == 4)
  4062. {
  4063. $info_list[$key]['review'] = "取消重审";
  4064. }
  4065. else if($value['review'] == 5)
  4066. {
  4067. $info_list[$key]['review'] = "<font style='color:#2f80f9'>审核通过</font>";
  4068. }
  4069. else if($value['review'] == 6)
  4070. {
  4071. $info_list[$key]['review'] = "<font style='color:#2f80f9'>自动通过</font>";
  4072. }
  4073. if($ud['dlz'] == 1)
  4074. {
  4075. $dlz = "<p>发货声明成功</p>";
  4076. }
  4077. else if($ud['dlz'] == 3)
  4078. {
  4079. $dlz = "<p>不需要发货声明</p>";
  4080. }
  4081. else if($ud['dlz'] == 2)
  4082. {
  4083. $dlz = "<p style='color:#C3C'>发货声明失败</p>";
  4084. }
  4085. else
  4086. {
  4087. $dlz = "";
  4088. }
  4089. if($value['waybill'] != "")
  4090. {
  4091. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz;
  4092. if( !empty($value['waybillid'])){
  4093. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz."<p>".$value['waybillid']."</p>";
  4094. }
  4095. }
  4096. if($value['express'] != 0)
  4097. {
  4098. $express = $this->express->read($value['express']);
  4099. $expressservicename = $express['servicename'];
  4100. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  4101. $info_list[$key]['express'] = $expressservicename;
  4102. }
  4103. else
  4104. {
  4105. $info_list[$key]['express'] = "无";
  4106. }
  4107. $x = "";
  4108. if($value['libraryconfirm'] == 2 && $value['review'] > 4 && $ud['library'] == 1)
  4109. {
  4110. $x = "<p class='ckn'><b class='fojz' data-type='1'>禁止发货</b></p>";
  4111. }
  4112. else if(($value['review'] > 4) && $ud['print'] != 1 && $value['libraryconfirm'] == 1)
  4113. {
  4114. $x = "<p class='ckn'><b class='fojzof' data-type='6' data-id='".$value['id']."'>允许发货</b></p>";
  4115. }
  4116. if(($value['review'] > 4) && $ud['print'] == 2)
  4117. {
  4118. $x = "<p class='ckn'><b class='fojzof' data-type='7' data-id='".$value['id']."'>禁止打印</b></p>";
  4119. }
  4120. else if($value['review'] >4 && $ud['print'] == 1)
  4121. {
  4122. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  4123. }
  4124. if($value['waybill'] == "" && $value['review'] > 4)
  4125. {
  4126. $x .= "<p><b class='kn' data-type='2'>填写运单号</b></p>";
  4127. }
  4128. else if($value['waybill'] != "" && $value['review'] > 4)
  4129. {
  4130. $x .= "<p><b class='kn' data-type='2'>修改运单</b></p>";
  4131. }
  4132. 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)
  4133. {
  4134. $x .= "<p><b class='focz' data-type='2' data-id='".$value['id']."'>提交审核</b></p>";
  4135. }
  4136. $x .= "<p><b class='window' data-h='/customersmt/edit/".$customer['id']."' data-t='客户信息 - 修改'>客户信息</b></p>";
  4137. $info_list[$key]['black'] = $x;
  4138. $tly = "";
  4139. if($value['clientremarks'] != "")
  4140. {
  4141. $tly = "<p style='color:#FF3333'>有客户留言</p>";
  4142. }
  4143. if($value['review'] > 4 && $usp['vip'] != 1)
  4144. {
  4145. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/readonly/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  4146. }
  4147. else
  4148. {
  4149. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/b/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  4150. }
  4151. if($value['library'] == 1 && $ud['printtype'] == 3)
  4152. {
  4153. $info_list[$key]['library'] = "不需要";
  4154. }
  4155. else if($value['library'] == 1 && $ud['printtype'] != 3)
  4156. {
  4157. $info_list[$key]['library'] = "未出库";
  4158. }
  4159. else if($value['library'] == 2)
  4160. {
  4161. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  4162. }
  4163. else if($value['library'] == 3)
  4164. {
  4165. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  4166. }
  4167. unset($info_list[$key]['waybillid']);
  4168. }
  4169. $total = $this->fullordersmt1->find_count($where);
  4170. $pagenum = ceil($total/$perpage);
  4171. $over = $total-($start+$perpage);
  4172. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4173. echo json_encode($rows);exit;
  4174. }
  4175. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4176. $this->data['wlshop'] = $wlshop;
  4177. $this->data['express'] = $this->express->find_all();
  4178. $user = $this->user->get_api($_SESSION['api']);
  4179. $powerid = $this->power->read($user['power']);
  4180. $powertext = explode('|',trim($powerid['excelid'],'|'));
  4181. $pid = '';
  4182. foreach ($powertext as $v)
  4183. {
  4184. $pid .= " id = ".$v." or";
  4185. }
  4186. $fullorderexcel = $this->fullorderexcel->find_all("type = '100004' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  4187. $this->data['fullorderexcel'] = $fullorderexcel;
  4188. $error = $this->fullordersmt1->find_count("print = 1 and failed !='' and mergeid = 0 and waybill = '' and (".rtrim($fgshop,'or').")");
  4189. $this->data['error'] = $error;
  4190. $this->_Template('fullordersmt_a',$this->data);
  4191. }
  4192. public function _bbb($arg_array)
  4193. {
  4194. $post = $this->input->post(NULL, TRUE);
  4195. if(isset($post['id']))
  4196. {
  4197. $id = $this->input->post('id',true);
  4198. $data = $this->fullordersmt1->read($id);
  4199. $post['type'] = $this->input->post('warehouse',true);
  4200. $post['country'] = $this->input->post('country',true);
  4201. $currency = $this->country->read($post['country']);
  4202. $post['al'] = $currency['lb'];
  4203. $post['freight'] = $this->input->post('freight',true);
  4204. $post['expressmoney'] = $this->input->post('expressmoney',true);
  4205. $post['shouldmoney'] = $this->input->post('shouldmoney',true);
  4206. $post['orderremarks'] = $this->input->post('orderremarks',true);
  4207. $shipremarks = $this->input->post('shipremarks');
  4208. $shipremarks = str_replace(array('%26','%2B'),array('&','+'),$shipremarks);
  4209. $post['shipremarks'] = preg_replace('/( | | |\s)/',' ',$shipremarks);
  4210. $post['email'] = $this->input->post('email',true);
  4211. $name = $this->input->post('name',true);
  4212. $post['name'] = str_replace("'","’",$name);
  4213. $post['phone'] = $this->input->post('phone',true);
  4214. $post['country'] = $this->input->post('country',true);
  4215. $post['province'] = $this->input->post('province',true);
  4216. $post['city'] = $this->input->post('city',true);
  4217. $post['zipcode'] = $this->input->post('zipcode',true);
  4218. $post['street'] = $this->input->post('street',true);
  4219. $address = $this->input->post('address',true);
  4220. $post['address'] = str_replace("'","’",$address);
  4221. $post['express'] = $this->input->post('express',true);
  4222. $post['printtype'] = $this->input->post('printtype',true);
  4223. $post['fpdata'] = $this->input->post('fpdata');
  4224. $post['waybill'] = $this->input->post('waybill',true);
  4225. $post['msg'] = $this->input->post('msg',true);
  4226. $post['zsbjz'] = $this->input->post('zsbjz',true);
  4227. $post['refundy'] = $this->input->post('refundy',true);
  4228. $post['refundj'] = $this->input->post('refundj',true);
  4229. $rtime = $this->input->post('rtime',true);
  4230. $post['rtime'] = strtotime($rtime);
  4231. $post['rpaypal'] = $this->input->post('rpaypal',true);
  4232. $post['rtext'] = $this->input->post('rtext',true);
  4233. $editstate = $this->input->post('state',true);
  4234. $post['review'] = 1;
  4235. if($post['zsbjz'] < '0.01')
  4236. {
  4237. echo json_encode(array('msg'=>'总申报价错误!','success'=>false));exit;
  4238. }
  4239. if($data['library'] == 1)
  4240. {
  4241. if($data['print'] != 3 && $data['review'] < 5)
  4242. {
  4243. $post['libraryconfirm'] = 1;
  4244. $post['librarynot'] = "订单未打印";
  4245. }
  4246. else if($data['print'] != 3 && $data['review'] > 4)
  4247. {
  4248. $post['print'] = 1;
  4249. $post['libraryconfirm'] = 1;
  4250. $post['librarynot'] = "订单未打印,订单审核后修改";
  4251. }
  4252. else
  4253. {
  4254. $post['libraryconfirm'] = 1;
  4255. $post['librarynot'] = "订单打印后修改";
  4256. }
  4257. }
  4258. if($post['printtype'] == 1)//如果是运单
  4259. {
  4260. $post['productdescription'] = $this->input->post('productdescription',true);
  4261. $post['customs'] = $this->input->post('customs',true);
  4262. }
  4263. /**
  4264. if($editstate == 216 && $data['state'] != 216)
  4265. {
  4266. echo json_encode(array('msg'=>'不可修改为完成状态','success'=>false));exit;
  4267. }
  4268. **/
  4269. if($editstate == 216 && preg_match('/\d/is',$post['waybill']) != true)
  4270. {
  4271. echo json_encode(array('msg'=>'当前信息不可修改订单状态','success'=>false));exit;
  4272. }
  4273. else
  4274. {
  4275. if($data['review'] == 1 && $data['source'] != 1)
  4276. {
  4277. $review = 6;
  4278. }
  4279. else if($data['review'] == 3 || ($data['review'] == 1 && $data['source'] == 1))
  4280. {
  4281. $review = 2;
  4282. }
  4283. else
  4284. {
  4285. $review = $data['review'];
  4286. }
  4287. $post['review'] = $review;
  4288. $post['state'] = $editstate;
  4289. $post['reviewtime'] = time();
  4290. }
  4291. if($this->fullordersmt1->save($post,$id))
  4292. {
  4293. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  4294. }
  4295. else
  4296. {
  4297. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  4298. }
  4299. }
  4300. $arg_array = $arg_array[0];$fpdata = array();
  4301. $fullordersmt = $this->fullordersmt1->read($arg_array);
  4302. $fullordersmt['parameter'] = str_replace(",","---",$fullordersmt['parameter']);
  4303. $country = $this->country->find_all('1=1','id,name','name asc');//所有国家信息
  4304. $express = $this->express->find_all('1=1');//所有快递配置信息
  4305. $this->data['fullordersmt'] = $fullordersmt;
  4306. $this->data['country'] = $country;
  4307. $this->data['express'] = $express;
  4308. $this->data['dtime'] = date('Y-m-d H:i:s',$fullordersmt['dtime']);
  4309. if(stripos($fullordersmt['fpdata'],';') !== false)
  4310. {
  4311. $fpdata = explode(';',rtrim($fullordersmt['fpdata'],';'));
  4312. foreach ($fpdata as $k=>$v)
  4313. {
  4314. $fpdata[$k] = explode('|',$v);
  4315. }
  4316. }
  4317. $this->data['fpdata'] = $fpdata;
  4318. $shop = $this->shop->read($fullordersmt['shop']);
  4319. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  4320. $is = 0;
  4321. if($shop['type'] == 269)//判断是否独立站,269是独立站
  4322. {
  4323. $is = 1;
  4324. }
  4325. $this->data['is'] = $is;
  4326. if(isset($_SESSION['api']))
  4327. {
  4328. $user = $this->user->get_api($_SESSION['api']);
  4329. if($user['vip'] == 1)
  4330. {
  4331. $vip = 1;
  4332. }
  4333. else
  4334. {
  4335. $vip = 0;
  4336. }
  4337. }
  4338. else
  4339. {
  4340. $vip = 0;
  4341. }
  4342. $this->data['power'] = $vip;
  4343. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  4344. $downwaybill = '';
  4345. if($fullordersmt['printtype'] == 1)
  4346. {
  4347. if($fullordersmt['waybill'] != '')
  4348. {
  4349. $downwaybill .= '<a href="/data/pdf/'.date('Ymd',$fullordersmt['printtime']).'/y-'.$fullordersmt['waybill'].'.pdf" target="_blank">'.$fullordersmt['waybill'].'</a>、';
  4350. }
  4351. }
  4352. $oldwaybill = explode('-',ltrim($fullordersmt['oldwaybill'],'-'));
  4353. if(isset($oldwaybill[0][1]))
  4354. {
  4355. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  4356. foreach ($oldwaybill as $v)
  4357. {
  4358. $dw = explode('/',$v);
  4359. if(isset($dw[1]))
  4360. {
  4361. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  4362. }
  4363. }
  4364. }
  4365. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  4366. /** 历史打印时间 **/
  4367. $printtime = '';
  4368. if($fullordersmt['oldprinttime'])
  4369. {
  4370. $pte = explode('-',rtrim($fullordersmt['oldprinttime'],'-'));
  4371. foreach ($pte as $v)
  4372. {
  4373. $printtime .= date('Y-m-d H:i:s',$v).'、';
  4374. }
  4375. }
  4376. $this->data['printtime'] = rtrim($printtime,'、');
  4377. $this->_Template('fullordersmt_b',$this->data);
  4378. }
  4379. public function _cf() //速卖通订单拆分
  4380. {
  4381. $post = $this->input->post(NULL, TRUE);
  4382. if(isset($post['id']))
  4383. {
  4384. $id = $this->input->post('id',true);
  4385. $b = $this->fullordersmt->read($id);
  4386. $order = array();
  4387. if($b['merge'] == $b['id'])
  4388. {
  4389. $data = $this->fullordersmt->find_all("merge = '".$b['merge']."'");
  4390. foreach ($data as $v)
  4391. {
  4392. $a = $this->fullordersmthb->get_orderinfo($v['orderinfo']);
  4393. if($a)
  4394. {
  4395. $this->fullordersmt->save($a,$v['id']);
  4396. }
  4397. $order[] = $v['id'];
  4398. }
  4399. echo json_encode(array('msg'=>'拆分成功!','d'=>$order,'success'=>true));exit;
  4400. }
  4401. else
  4402. {
  4403. echo json_encode(array('msg'=>'拆分条件错误!','success'=>false));exit;
  4404. }
  4405. }
  4406. }
  4407. public function _epod()
  4408. {
  4409. $post = $this->input->post(NULL, TRUE);
  4410. if(isset($post['number']))
  4411. {
  4412. $number = $this->input->post('number',true);
  4413. $data = $this->fullordersmt->get_number($number);
  4414. if(is_file('./data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf'))
  4415. {
  4416. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].'/data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf','success'=>true));exit;
  4417. }
  4418. else
  4419. {
  4420. $epod = $this->dhl->get_epod($data);
  4421. if($epod['c'] == 1)
  4422. {
  4423. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].$epod['d'],'success'=>true));exit;
  4424. }
  4425. else
  4426. {
  4427. echo json_encode(array('msg'=>$epod['d'],'success'=>false));exit;
  4428. }
  4429. }
  4430. }
  4431. }
  4432. public function _ddcf()
  4433. {
  4434. $post = $this->input->post(NULL, TRUE);
  4435. if(isset($post['number']))
  4436. {
  4437. $number = $this->input->post('number',true);
  4438. $data = $this->fullordersmt->get_number($number);
  4439. if(!$data)
  4440. {
  4441. echo json_encode(array('msg'=>'没有找到此订单','success'=>false));exit;
  4442. }
  4443. if($data['review'] != 1 && $data['review'] != 2)
  4444. {
  4445. echo json_encode(array('msg'=>'必须是 待审核 状态才能拆分','success'=>false));exit;
  4446. }
  4447. $cfnum = explode('-',trim($number,'-'));
  4448. if((count($cfnum)> 3 && stripos($pd[$x],'-PF-') !== false) || (count($cfnum)> 4 && stripos($pd[$x],'-PF-') === false))
  4449. {
  4450. echo json_encode(array('msg'=>'只能在原单操作拆分','success'=>false));exit;
  4451. }
  4452. $num = $this->fullordersmt->find_count("number like '".$number."%'");
  4453. $data['number'] = $data['number'].'-'.$num;
  4454. $data['orderinfo'] = $data['shop'].date('ymdHis',time()).rand(0,1);
  4455. $data['shouldmoney'] = 0;
  4456. $data['budget'] = 0;
  4457. $data['shipremarks'] = '';
  4458. $data['source'] = 1;
  4459. unset($data['id']);
  4460. unset($data['jweight']);
  4461. unset($data['fpcount']);
  4462. unset($data['returndata']);
  4463. unset($data['waybill']);
  4464. unset($data['oldwaybill']);
  4465. unset($data['printtime']);
  4466. if($this->fullordersmt->insert($data))
  4467. {
  4468. echo json_encode(array('msg'=>'拆分成功!新订单编号:'.$data['number'],'success'=>true));exit;
  4469. }
  4470. else
  4471. {
  4472. echo json_encode(array('msg'=>'拆分失败,请重试','success'=>false));exit;
  4473. }
  4474. }
  4475. }
  4476. }