Fullordersmt.php 150 KB

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