Fullordersmt.php 149 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425
  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. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>2),$id);
  2283. echo json_encode(array('msg'=>'声明失败:'.$result['error_msg'],'success'=>false));exit;
  2284. }
  2285. }
  2286. else
  2287. {
  2288. if($this->fullordersmt->save(array('waybill'=>$msg),$id))
  2289. {
  2290. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  2291. }
  2292. else
  2293. {
  2294. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));
  2295. }
  2296. }
  2297. }
  2298. }
  2299. }
  2300. public function _merge()
  2301. {
  2302. $user = $this->user->get_api($_SESSION['api']);
  2303. if($user)
  2304. {
  2305. $fgshop = "";$sid = "";
  2306. $user = explode('|',trim($user['shop'],'|'));
  2307. foreach ($user as $value)
  2308. {
  2309. $fgshop .= " shop = ".$value." or";
  2310. $sid .= " id = ".$value." or";
  2311. }
  2312. }
  2313. $post = $this->input->post(NULL, TRUE);
  2314. if(isset($post['type']))
  2315. {
  2316. $post = array();
  2317. $type = $this->input->post('type');
  2318. $id = $this->input->post('id');
  2319. $u = $this->fullordersmt->read($id);
  2320. $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');
  2321. if(count($rows)>1)
  2322. {
  2323. $this->db->trans_begin();
  2324. $hd = $this->fullordersmthb->get_orderinfo($u['orderinfo']);
  2325. if(!$hd)
  2326. {
  2327. $this->fullordersmthb->insert($u);
  2328. }
  2329. //相加
  2330. $post['shouldmoney'] = $u['shouldmoney'];//购买应收金额
  2331. $post['budget'] = $u['budget'];//预估到帐金额
  2332. $post['expressmoney']= $u['expressmoney'];//物流金额
  2333. //$post['refundy'] = $u['refundy'];//补/退原额
  2334. //$post['refundj'] = $u['refundj'];//补/退净额
  2335. $post['cost'] = $u['cost'];//成本金额
  2336. //$post['zzl'] = $u['zzl'];//总重量
  2337. //$post['zsbjz'] = $u['zsbjz'];//总申报价值
  2338. $post['ts'] = $u['ts'];//条数
  2339. $post['cost'] = $u['cost'];//成本金额
  2340. //追加
  2341. $post['rpaypal'] = $u['rpaypal'];//补/退交易号
  2342. $post['rtext'] = $u['rtext'];//补/退原因
  2343. $post['pay'] = $u['pay'];//付款方式
  2344. $post['paypal'] = $u['paypal'];//交易号
  2345. $post['clientremarks'] = $u['clientremarks'];//客户留言
  2346. $post['product'] = $u['product'];//商品名称
  2347. //$post['issku'] = $u['issku'];//sku
  2348. //$post['orderremarks'] = $u['orderremarks'];//订单备注
  2349. $post['shipremarks'] = $u['shipremarks'];//仓库品名
  2350. //产品追加
  2351. $post['fpdata'] = $u['fpdata'];//产品内容
  2352. $post['whlabel'] = $u['whlabel'];//产品对应库存码
  2353. $merge = $u['id'];
  2354. $d = array($id);$order = '';
  2355. $zsl = 0;$zccsl = 0;
  2356. foreach ($rows as $v)
  2357. {
  2358. if($v['id'] != $id && $v['shop'] = $u['shop'])
  2359. {
  2360. $hd = $this->fullordersmthb->get_orderinfo($v['orderinfo']);
  2361. if(!$hd)
  2362. {
  2363. $this->fullordersmthb->insert($v);
  2364. }
  2365. $post['shouldmoney'] += $v['shouldmoney'];//购买应收金额
  2366. $post['budget'] += $v['budget'];//预估到帐金额
  2367. $post['expressmoney'] += $v['expressmoney'];//物流金额
  2368. //$post['refundy'] += $v['refundy'];//补/退原额
  2369. //$post['refundj'] += $v['refundj'];//补/退净额
  2370. $post['cost'] += $v['cost'];//成本金额
  2371. //$post['zzl'] += $v['zzl'];//总重量
  2372. //$post['zsbjz'] += $v['zsbjz'];//总申报价值
  2373. $post['ts'] += $v['ts'];//条数
  2374. //$post['rpaypal'] .= $v['rpaypal'];//补/退交易号
  2375. //$post['rtext'] .= $v['rtext'];//补/退原因
  2376. //$post['pay'] .= (stripos($post['pay'],$v['pay']) !== false)?'':';'.$v['pay'];//付款方式
  2377. //$post['paypal'] .= $v['paypal'];//交易号
  2378. $post['clientremarks'] .= $v['clientremarks'];//客户留言
  2379. $post['product'] .= $v['product'];//商品名称
  2380. //$post['issku'] .= $v['issku'];//sku
  2381. //$post['orderremarks'] .= $v['orderremarks'];//订单备注
  2382. $post['shipremarks'] .= $v['shipremarks'];//仓库品名
  2383. $post['fpdata'] .= $v['fpdata'];//产品内容
  2384. $post['whlabel'] .= $v['whlabel'];//产品对应库存码
  2385. $d[] = $v['id'];
  2386. $order .= $v['orderinfo'].'('.$v['number'].')、';
  2387. $wl = $this->whlabel->find_all("zd = '".$v['number']."'");//查找是否有占用库存情况
  2388. $i = 0;
  2389. if($wl)//如果有那么清除所有占用
  2390. {
  2391. foreach ($wl as $v)
  2392. {
  2393. if($v['sku'] == 'Preset' && $v['state'] == '9')
  2394. {
  2395. $this->whlabel->remove($v['id']);//删除预设
  2396. $i++;
  2397. }
  2398. else
  2399. {
  2400. $this->whlabel->save(array('zd'=>''),$v['id']);//专属
  2401. $i++;
  2402. }
  2403. }
  2404. }
  2405. $zsl += count($wl);
  2406. $zccsl += $i;
  2407. $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']);
  2408. }
  2409. }
  2410. //计算出单条价值
  2411. /**
  2412. if($post['zsbjz'] < 1 || $post['ts'] < 1)
  2413. {
  2414. $post['dtsbjz'] = 0;
  2415. }
  2416. else
  2417. {
  2418. $post['dtsbjz'] = $post['zsbjz']/$post['ts'];//单条申报价
  2419. }
  2420. **/
  2421. $post['orderremarks'] = ' 《合并信息》:由'.rtrim($order,'、').'合并而来; '.$u['orderremarks'];;
  2422. $post['merge'] = $id;
  2423. //$post['mergeid'] = 1;
  2424. $this->fullordersmt->save($post,$id);
  2425. if ($this->db->trans_status() === FALSE || $zsl != $zccsl)
  2426. {
  2427. $this->db->trans_commit();
  2428. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2429. }
  2430. else
  2431. {
  2432. $this->db->trans_commit();
  2433. echo json_encode(array('msg'=>'操作成功','d'=>($d),'b'=>$id,'success'=>true));
  2434. }
  2435. }
  2436. else
  2437. {
  2438. echo json_encode(array('msg'=>'缺少可合并单','success'=>false));exit;
  2439. }
  2440. }
  2441. }
  2442. public function _split()
  2443. {
  2444. $user = $this->user->get_api($_SESSION['api']);
  2445. if($user)
  2446. {
  2447. $fgshop = "";$sid = "";
  2448. $user = explode('|',trim($user['shop'],'|'));
  2449. foreach ($user as $value)
  2450. {
  2451. $fgshop .= " shop = ".$value." or";
  2452. $sid .= " id = ".$value." or";
  2453. }
  2454. }
  2455. $post = $this->input->post(NULL, TRUE);
  2456. if(isset($post['id']))
  2457. {
  2458. $id = $this->input->post('id');
  2459. $data = $this->fullordersmt->find_all("merge = '$id' and print !=3 and library =1 and (".rtrim($fgshop,'or').")");
  2460. $datanum = $this->fullordersmt->find_count("merge = '$id' and (".rtrim($fgshop,'or').")");
  2461. if($data && count($data) == $datanum)
  2462. {
  2463. foreach ($data as $k=>$v)
  2464. {
  2465. unset($data[$k]['id']);
  2466. unset($data[$k]['express']);
  2467. unset($data[$k]['printtype']);
  2468. unset($data[$k]['review']);
  2469. unset($data[$k]['reviewtime']);
  2470. $t = $this->fullordersmt->get_orderinfo($v['orderinfo']);
  2471. $this->fullordersmt->save($v,$t['id']);
  2472. }
  2473. echo json_encode(array('msg'=>'拆分成功!','success'=>true));
  2474. }
  2475. else
  2476. {
  2477. echo json_encode(array('msg'=>'有订单不符合条件,请重试','success'=>false));exit;
  2478. }
  2479. }
  2480. }
  2481. //评价管理
  2482. public function _evaluate()
  2483. {
  2484. $user = $this->user->get_api($_SESSION['api']);
  2485. if($user)
  2486. {
  2487. $fgshop = "";$sid = "";
  2488. $user = explode('|',trim($user['shop'],'|'));
  2489. foreach ($user as $value)
  2490. {
  2491. $fgshop .= " shop = ".$value." or";
  2492. $sid .= " id = ".$value." or";
  2493. }
  2494. }
  2495. $post = $this->input->post(NULL, TRUE);
  2496. if(isset($post['page']))
  2497. {
  2498. $page = $this->input->post('page',true);
  2499. $perpage = $this->input->post('perpage',true);
  2500. $shop = $this->input->post('shop',true);
  2501. $where = "1=1 and evaluate = 0 and (".rtrim($fgshop,'or').")";
  2502. if($shop)
  2503. {
  2504. $where .= " and shop = '$shop'";
  2505. }
  2506. //数据排序
  2507. $order_str = "id desc";
  2508. if(empty($page))
  2509. {
  2510. $start = 0;
  2511. $perpage = 1;
  2512. }
  2513. else
  2514. {
  2515. $start = ($page - 1)*$perpage;
  2516. }
  2517. //取得信息列表
  2518. $info_list = $this->fullordersmt->find_all($where,'id,shop,orderinfo,number,operation',$order_str,$start,$perpage);
  2519. //格式化数据
  2520. foreach ($info_list as $key=>$value)
  2521. {
  2522. $shop = $this->shop->read($value['shop']);
  2523. $info_list[$key]['shop'] = $shop['shopname'];
  2524. $info_list[$key]['operation'] = "评价";
  2525. }
  2526. $total = $this->fullordersmt->find_count($where);
  2527. $pagenum = ceil($total/$perpage);
  2528. $over = $total-($start+$perpage);
  2529. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2530. echo json_encode($rows);exit;
  2531. }
  2532. $this->_Template('fullordersmt_evaluate',$this->data);
  2533. }
  2534. //订单消息
  2535. public function _state()
  2536. {
  2537. $user = $this->user->get_api($_SESSION['api']);
  2538. if($user)
  2539. {
  2540. $fgshop = "";$sid = "";
  2541. $user = explode('|',trim($user['shop'],'|'));
  2542. foreach ($user as $value)
  2543. {
  2544. $fgshop .= " shop = ".$value." or";
  2545. $sid .= " id = ".$value." or";
  2546. }
  2547. }
  2548. $post = $this->input->post(NULL, TRUE);
  2549. if(isset($post['page']))
  2550. {
  2551. $page = $this->input->post('page',true);
  2552. $perpage = $this->input->post('perpage',true);
  2553. $timetk = $this->input->post('timetk',true);
  2554. $timetj = $this->input->post('timetj',true);
  2555. $shop = $this->input->post('shop',true);
  2556. $source = $this->input->post('source',true);
  2557. $state = $this->input->post('state',true);
  2558. $review = $this->input->post('review',true);
  2559. $expressstate = $this->input->post('expressstate',true);
  2560. $express = $this->input->post('express',true);
  2561. $orderinfo = $this->input->post('orderinfo',true);
  2562. $user = $this->input->post('user',true);
  2563. $name = $this->input->post('name',true);
  2564. $waybill = $this->input->post('waybill',true);
  2565. $timetk = strtotime($timetk);
  2566. $timetj = strtotime($timetj);
  2567. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  2568. if($timetk && $timetj)
  2569. {
  2570. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2571. }
  2572. if($shop)
  2573. {
  2574. $where .= " and shop = '$shop'";
  2575. }
  2576. if($source)
  2577. {
  2578. $where .= " and source = '$source'";
  2579. }
  2580. if($state)
  2581. {
  2582. $where .= " and state = '$state'";
  2583. }
  2584. if($review)
  2585. {
  2586. $where .= " and review = '$review'";
  2587. }
  2588. if($expressstate != "")
  2589. {
  2590. $where .= " and expressstate = '$expressstate'";
  2591. }
  2592. if($express)
  2593. {
  2594. $where .= " and express = '$express'";
  2595. }
  2596. if($orderinfo)
  2597. {
  2598. $where .= " and orderinfo = '$orderinfo'";
  2599. }
  2600. if($user)
  2601. {
  2602. $where .= " and user = '$user'";
  2603. }
  2604. if($name)
  2605. {
  2606. $where .= " and name = '$name'";
  2607. }
  2608. if($waybill)
  2609. {
  2610. $where .= " and waybill = '$waybill'";
  2611. }
  2612. //数据排序
  2613. $order_str = "id desc";
  2614. if(empty($page))
  2615. {
  2616. $start = 0;
  2617. $perpage = 1;
  2618. }
  2619. else
  2620. {
  2621. $start = ($page - 1)*$perpage;
  2622. }
  2623. //取得信息列表
  2624. $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);
  2625. //格式化数据
  2626. foreach ($info_list as $key=>$value)
  2627. {
  2628. $ud = $this->fullordersmt->read($value['id']);
  2629. $shop = $this->shop->read($value['shop']);
  2630. $info_list[$key]['shop'] = $shop['shopname'];
  2631. $info_list[$key]['user'] = $shop['shopuser'];
  2632. $country = $this->country->read($value['country']);
  2633. $info_list[$key]['country'] = $country['name'];
  2634. $state = $this->typeclass->read($value['state']);
  2635. if($ud['source'] != '1')
  2636. {
  2637. $info_list[$key]['state'] = "<a href='https://trade.aliexpress.com/order_detail.htm?orderId=".$value['orderinfo']."' target='_blank'>".$state['title']."</a>";
  2638. }
  2639. else
  2640. {
  2641. $info_list[$key]['state'] = $state['title'];
  2642. }
  2643. if($value['library'] == 1)
  2644. {
  2645. $info_list[$key]['library'] = "未出库";
  2646. }
  2647. else if($value['library'] == 2)
  2648. {
  2649. $info_list[$key]['library'] = "已出库";
  2650. }
  2651. else if($value['library'] == 3)
  2652. {
  2653. $info_list[$key]['library'] = "已退库";
  2654. }
  2655. if($value['librarytime'] == '0')
  2656. {
  2657. $info_list[$key]['librarytime'] = '无';
  2658. }
  2659. else
  2660. {
  2661. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  2662. }
  2663. if($value['exstate'] == 0)
  2664. {
  2665. $info_list[$key]['exstate'] = "未取件";
  2666. }
  2667. else if($value['exstate'] == 1)
  2668. {
  2669. $info_list[$key]['exstate'] = "已揽收";
  2670. }
  2671. else if($value['exstate'] == 2)
  2672. {
  2673. $info_list[$key]['exstate'] = "在途中";
  2674. }
  2675. else if($value['exstate'] == 3)
  2676. {
  2677. $info_list[$key]['exstate'] = "派送中";
  2678. }
  2679. else if($value['exstate'] == 4)
  2680. {
  2681. $info_list[$key]['exstate'] = "签收";
  2682. }
  2683. if($value['express'])
  2684. {
  2685. $express = $this->express->read($value['express']);
  2686. $info_list[$key]['express'] = $express['servicename'];
  2687. }
  2688. else
  2689. {
  2690. $info_list[$key]['express'] = '';
  2691. }
  2692. }
  2693. $total = $this->fullordersmt->find_count($where);
  2694. $pagenum = ceil($total/$perpage);
  2695. $over = $total-($start+$perpage);
  2696. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2697. echo json_encode($rows);exit;
  2698. }
  2699. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2700. $this->data['wlshop'] = $wlshop;
  2701. $this->data['express'] = $this->express->find_all();
  2702. $this->_Template('fullordersmt_state',$this->data);
  2703. }
  2704. //审核订单
  2705. public function _review()
  2706. {
  2707. $user = $this->user->get_api($_SESSION['api']);
  2708. $fgshop = "";
  2709. if($user)
  2710. {
  2711. $fgshop = "";$sid = "";
  2712. $user = explode('|',trim($user['shop'],'|'));
  2713. foreach ($user as $value)
  2714. {
  2715. $fgshop .= " shop = ".$value." or";
  2716. }
  2717. $fgshop = " and (".rtrim($fgshop,'or').")";
  2718. }
  2719. $post = $this->input->post(NULL, TRUE);
  2720. if(isset($post['page']))
  2721. {
  2722. $page = $this->input->post('page',true);
  2723. $perpage = $this->input->post('perpage',true);
  2724. $source = $this->input->post('source',true);
  2725. $warehouse = $this->input->post('warehouse',true);
  2726. $express = $this->input->post('express',true);
  2727. $user = $this->input->post('user',true);
  2728. $shop = $this->input->post('shop',true);
  2729. $review = $this->input->post('review',true);
  2730. $orderinfo = $this->input->post('orderinfo',true);
  2731. $number = $this->input->post('number',true);
  2732. $timetk = $this->input->post('timetk',true);
  2733. $timetj = $this->input->post('timetj',true);
  2734. $timetk = strtotime($timetk);
  2735. $timetj = strtotime($timetj);
  2736. $where = "mergeid = 0".$fgshop;
  2737. if($timetk && $timetj)
  2738. {
  2739. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2740. }
  2741. if($source)
  2742. {
  2743. $where .= " and source = '$source'";
  2744. }
  2745. if($shop)
  2746. {
  2747. $where .= " and shop = '$shop'";
  2748. }
  2749. if($warehouse)
  2750. {
  2751. $where .= " and type = '$warehouse'";
  2752. }
  2753. if($express)
  2754. {
  2755. $where .= " and express = '$express'";
  2756. }
  2757. if($user)
  2758. {
  2759. $where .= " and user = '$user'";
  2760. }
  2761. if($review)
  2762. {
  2763. $where .= " and review = '$review'";
  2764. }
  2765. if($orderinfo)
  2766. {
  2767. $where .= " and orderinfo = '$orderinfo'";
  2768. }
  2769. if($number)
  2770. {
  2771. $where .= " and number = '$number'";
  2772. }
  2773. //数据排序
  2774. $order_str = "id desc";
  2775. if(empty($page))
  2776. {
  2777. $start = 0;
  2778. $perpage = 1;
  2779. }
  2780. else
  2781. {
  2782. $start = ($page - 1)*$perpage;
  2783. }
  2784. //取得信息列表
  2785. $info_list = $this->fullordersmt->find_all($where,'id,shop,user,type,orderinfo,number,client,express,buytime,shouldmoney,review,currencytitle,library');
  2786. //格式化数据
  2787. foreach ($info_list as $key=>$value)
  2788. {
  2789. $lr = $this->fullordersmt->read($value['id']);
  2790. $shop = $this->shop->read($value['shop']);
  2791. $info_list[$key]['shop'] = $shop['shopname'];
  2792. $info_list[$key]['user'] = $shop['shopuser'];
  2793. $warehouse = $this->warehouse->read($value['type']);
  2794. $info_list[$key]['type'] = $warehouse['title'];
  2795. $express = $this->express->read($value['express']);
  2796. $info_list[$key]['express'] = $express['servicename'];
  2797. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  2798. if($value['review'] == 1)
  2799. {
  2800. $info_list[$key]['review'] = "未送审";
  2801. }
  2802. else if($value['review'] == 2)
  2803. {
  2804. $info_list[$key]['review'] = "待审核";
  2805. }
  2806. else if($value['review'] == 3)
  2807. {
  2808. $info_list[$key]['review'] = "不通过";
  2809. }
  2810. else if($value['review'] == 4)
  2811. {
  2812. $info_list[$key]['review'] = "取消重审";
  2813. }
  2814. else if($value['review'] == 5)
  2815. {
  2816. $info_list[$key]['review'] = "审核通过";
  2817. }
  2818. else if($value['review'] == 6)
  2819. {
  2820. $info_list[$key]['review'] = "自动通过";
  2821. }
  2822. if($value['review'] == 2)
  2823. {
  2824. $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>";
  2825. }
  2826. else if($value['review'] == 3)
  2827. {
  2828. $info_list[$key]['library'] = "<p><b class='fullorderreview' data-type='5' data-id='".$value['id']."'>审核通过</b></p>";
  2829. }
  2830. else if($value['review'] == 5)
  2831. {
  2832. $info_list[$key]['library'] = "<p><b class='fullorderreview' data-type='3' data-id='".$value['id']."'>不通过</b></p>";
  2833. }
  2834. else
  2835. {
  2836. $info_list[$key]['library'] = "";
  2837. }
  2838. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$lr['currencytitle'];
  2839. $lr['hl'] = $lr['hl']==0?6.71:$lr['hl'];
  2840. $cost = $lr['cost']/$lr['hl'];
  2841. $currencytitle = $lr['budget']-$lr['refundj']-$cost-$lr['expressmoney'];
  2842. $info_list[$key]['currencytitle'] = sprintf("%.2f",$currencytitle).' '.$lr['currencytitle'];
  2843. }
  2844. $total = $this->fullordersmt->find_count($where);
  2845. $pagenum = ceil($total/$perpage);
  2846. $over = $total-($start+$perpage);
  2847. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2848. echo json_encode($rows);exit;
  2849. }
  2850. $this->_Template('fullordersmt_review',$this->data);
  2851. }
  2852. //导出资金统计excel
  2853. public function _fmexcel()
  2854. {
  2855. $user = $this->user->get_api($_SESSION['api']);
  2856. if($user)
  2857. {
  2858. $fgshop = "";$sid = "";
  2859. $user = explode('|',trim($user['shop'],'|'));
  2860. foreach ($user as $value)
  2861. {
  2862. $fgshop .= " shop = ".$value." or";
  2863. $sid .= " id = ".$value." or";
  2864. }
  2865. }
  2866. if(isset($_GET['excel']))
  2867. {
  2868. $timetk = $this->input->get('timetk',true);
  2869. $timetj = $this->input->get('timetj',true);
  2870. $shop = $this->input->get('shop',true);
  2871. $source = $this->input->get('source',true);
  2872. $state = $this->input->get('state',true);
  2873. $type = $this->input->get('type',true);
  2874. $orderinfo = $this->input->get('orderinfo',true);
  2875. $user = $this->input->get('user',true);
  2876. $name = $this->input->get('name',true);
  2877. $timetk = strtotime($timetk);
  2878. $timetj = strtotime($timetj);
  2879. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  2880. if($timetk && $timetj)
  2881. {
  2882. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  2883. }
  2884. if($shop)
  2885. {
  2886. $where .= " and shop = '$shop'";
  2887. }
  2888. if($source)
  2889. {
  2890. $where .= " and source = '$source'";
  2891. }
  2892. if($state)
  2893. {
  2894. if($state == 1)
  2895. {
  2896. $where .= " and state = '$state'";
  2897. }
  2898. }
  2899. if($type)
  2900. {
  2901. $where .= " and type = '$type'";
  2902. }
  2903. if($orderinfo)
  2904. {
  2905. $where .= " and orderinfo = '$orderinfo'";
  2906. }
  2907. if($user)
  2908. {
  2909. $where .= " and user = '$user'";
  2910. }
  2911. if($name)
  2912. {
  2913. $where .= " and name = '$name'";
  2914. }
  2915. //取得信息列表
  2916. $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');
  2917. //格式化数据
  2918. $i = 1;$shouldmoney = 0;$refund = 0;$budget = 0;$currency = 0;$hl=1;
  2919. foreach ($info_list as $key=>$value)
  2920. {
  2921. $info_list[$key]['id'] = $i;
  2922. if($value['currencytitle'] != "CNY")
  2923. {
  2924. $hl=$value['hl'];
  2925. }
  2926. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  2927. $budget=$budget+($value['budget']*$hl);
  2928. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  2929. $refund=$refund+($value['refund']*$hl);
  2930. $shop = $this->shop->read($value['shop']);
  2931. $info_list[$key]['shop'] = $shop['shopname'];
  2932. $info_list[$key]['user'] = $shop['shopuser'];
  2933. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  2934. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  2935. $country = $this->country->read($value['country']);
  2936. $info_list[$key]['country'] = $country['name'];
  2937. $express = $this->express->read($value['express']);
  2938. $info_list[$key]['express'] = $express['servicename'];
  2939. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  2940. $info_list[$key]['refund'] = $value['refund'].' '.$value['currencytitle'];
  2941. $info_list[$key]['budget'] = $value['budget'].' '.$value['currencytitle'];
  2942. $info_list[$key]['currency'] = sprintf("%.2f",$value['shouldmoney']-$value['budget']).' '.$value['currencytitle'];
  2943. $fpdata = array();
  2944. if(stripos($value['fpdata'],';') !== false)
  2945. {
  2946. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  2947. foreach ($fpdata as $ke=>$va)
  2948. {
  2949. $v = explode('|',rtrim($va,'|'));
  2950. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  2951. }
  2952. }
  2953. $info_list[$key]['fpdata'] = $fpdata;
  2954. $i++;
  2955. }
  2956. $data = array($shouldmoney.' CNY',$refund.' CNY',$currency.' CNY',$budget.' CNY');
  2957. $title = "订单资金信息";
  2958. $titlename = "<table border=1>
  2959. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  2960. <tr>
  2961. <td>NO.</td>
  2962. <td>店铺</td>
  2963. <td>负责人</td>
  2964. <td>编号</td>
  2965. <td>订单号</td>
  2966. <td>客户姓名</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>
  2977. <table border=1>
  2978. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  2979. <tr>
  2980. <td>产品</td>
  2981. <td>条数</td>
  2982. <td>数量</td>
  2983. </tr>
  2984. </table>
  2985. </td>
  2986. <td>总条数</td>
  2987. </tr>
  2988. </table>";
  2989. $filename = $title.".xls";
  2990. $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";
  2991. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  2992. }
  2993. }
  2994. //导出订单excel
  2995. public function _fdexcel()
  2996. {
  2997. if(isset($_GET['excel']))
  2998. {
  2999. $page = $this->input->post('page',true);
  3000. $perpage = $this->input->post('perpage',true);
  3001. $timetk = $this->input->post('timetk',true);
  3002. $timetj = $this->input->post('timetj',true);
  3003. $shop = $this->input->post('shop',true);
  3004. $source = $this->input->post('source',true);
  3005. $state = $this->input->post('state',true);
  3006. $review = $this->input->post('review',true);
  3007. $express = $this->input->post('express',true);
  3008. $orderinfo = $this->input->post('orderinfo',true);
  3009. $user = $this->input->post('user',true);
  3010. $name = $this->input->post('name',true);
  3011. $waybill = $this->input->post('waybill',true);
  3012. $timetk = strtotime($timetk);
  3013. $timetj = strtotime($timetj);
  3014. $where = "1=1 and mergeid = 0";
  3015. if($timetk && $timetj)
  3016. {
  3017. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3018. }
  3019. if($shop)
  3020. {
  3021. $where .= " and shop = '$shop'";
  3022. }
  3023. if($source)
  3024. {
  3025. $where .= " and source = '$source'";
  3026. }
  3027. if($state)
  3028. {
  3029. $where .= " and state = '$state'";
  3030. }
  3031. if($review)
  3032. {
  3033. $where .= " and review = '$review'";
  3034. }
  3035. if($express)
  3036. {
  3037. $where .= " and express = '$express'";
  3038. }
  3039. if($orderinfo)
  3040. {
  3041. $where .= " and orderinfo = '$orderinfo'";
  3042. }
  3043. if($user)
  3044. {
  3045. $where .= " and user = '$user'";
  3046. }
  3047. if($name)
  3048. {
  3049. $where .= " and name = '$name'";
  3050. }
  3051. if($waybill)
  3052. {
  3053. $where .= " and waybill = '$waybill'";
  3054. }
  3055. //取得信息列表
  3056. $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');
  3057. //格式化数据
  3058. $i = 1;$shouldmoney = 0;$hl=1;
  3059. foreach ($info_list as $key=>$value)
  3060. {
  3061. $info_list[$key]['id'] = $i;
  3062. if($value['source'] == 1)
  3063. {
  3064. $info_list[$key]['source'] = "线下订单";
  3065. }
  3066. else if($value['source'] == 2)
  3067. {
  3068. $info_list[$key]['source'] = "PC订单";
  3069. }
  3070. else if($value['source'] == 3)
  3071. {
  3072. $info_list[$key]['source'] = "手机订单";
  3073. }
  3074. if($value['currencytitle'] != "CNY")
  3075. {
  3076. $hl=$value['hl'];
  3077. }
  3078. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  3079. $shop = $this->shop->read($value['shop']);
  3080. $info_list[$key]['shop'] = $shop['shopname'];
  3081. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  3082. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  3083. $state = $this->typeclass->read($value['state']);
  3084. $info_list[$key]['state'] = $state['title'];
  3085. $country = $this->country->read($value['country']);
  3086. $info_list[$key]['country'] = $country['name'];
  3087. $express = $this->express->read($value['express']);
  3088. $info_list[$key]['express'] = $express['servicename'];
  3089. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  3090. $fpdata = array();
  3091. if(stripos($value['fpdata'],';') !== false)
  3092. {
  3093. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  3094. foreach ($fpdata as $ke=>$va)
  3095. {
  3096. $v = explode('|',rtrim($va,'|'));
  3097. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  3098. }
  3099. }
  3100. $info_list[$key]['fpdata'] = $fpdata;
  3101. $i++;
  3102. }
  3103. $data = array($shouldmoney.' CNY');
  3104. $title = "订单信息表";
  3105. $titlename = "<table border=1>
  3106. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  3107. <tr>
  3108. <td>NO.</td>
  3109. <td>店铺</td>
  3110. <td>编号</td>
  3111. <td>订单号</td>
  3112. <td>订单类型</td>
  3113. <td>客户姓名</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>
  3130. <table border=1>
  3131. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  3132. <tr>
  3133. <td>产品</td>
  3134. <td>条数</td>
  3135. <td>数量</td>
  3136. </tr>
  3137. </table>
  3138. </td>
  3139. <td>总条数</td>
  3140. </tr>
  3141. </table>";
  3142. $filename = $title.".xls";
  3143. $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";
  3144. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  3145. }
  3146. }
  3147. public function _black()
  3148. {
  3149. $post = $this->input->post(NULL, TRUE);
  3150. if(isset($post['bd']))
  3151. {
  3152. $bd = $this->input->post('bd',true);
  3153. $rows = $this->fullordersmt->read($bd);
  3154. $post['shop'] = $rows['shop'];
  3155. $post['source'] = 1;
  3156. $post['name'] = $rows['client'];
  3157. $post['email'] = $rows['email'];
  3158. $post['phone'] = $rows['phone'];
  3159. $post['country'] = $rows['country'];
  3160. $post['money'] = $rows['shouldmoney'];
  3161. $post['num'] = 1;
  3162. $post['time'] = $rows['dtime'];
  3163. $post['province'] = $rows['province'];
  3164. $post['city'] = $rows['city'];
  3165. $post['street'] = $rows['street'];
  3166. $post['address'] = $rows['address'];
  3167. $post['address2'] = $rows['address2'];
  3168. $post['zipcode'] = $rows['zipcode'];
  3169. $post['type'] = 2;
  3170. if($this->customer->insert($post))
  3171. {
  3172. $this->fullordersmt->save(array('black'=>1),$bd);
  3173. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  3174. }
  3175. else
  3176. {
  3177. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3178. }
  3179. }
  3180. }
  3181. public function _ryf()
  3182. {
  3183. $post = $this->input->post(NULL, TRUE);
  3184. if(isset($post['bd']))
  3185. {
  3186. $bd = $this->input->post('bd',true);
  3187. $d = $this->fullordersmt->read($bd);
  3188. if($d['state'] == 207 || $d['state'] == 207)//订单状态为等待发货或等待部分发货才可更改为允许发货
  3189. {
  3190. if($d['print'] < 3)//打印状态为未打印
  3191. {
  3192. $print = 1;//未打印
  3193. $libraryconfirm = 1;//不允许出库
  3194. $a = "订单未打印,";
  3195. }
  3196. else//已打印订单
  3197. {
  3198. $libraryconfirm = 2;//允许出库
  3199. $a = "";
  3200. }
  3201. if($this->fullordersmt->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  3202. {
  3203. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  3204. }
  3205. else
  3206. {
  3207. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3208. }
  3209. }
  3210. if($this->fullordersmt->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  3211. {
  3212. echo json_encode(array('msg'=>'操作失败!订单未非发货状态','success'=>false));exit;
  3213. }
  3214. else
  3215. {
  3216. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3217. }
  3218. }
  3219. }
  3220. public function _fsstate()
  3221. {
  3222. $post = $this->input->post(NULL, TRUE);
  3223. if(isset($post['s']))
  3224. {
  3225. $id_arr = $this->input->post('s');
  3226. $id_arr = explode(',',$id_arr);
  3227. if(!$id_arr)
  3228. {
  3229. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  3230. }
  3231. foreach ($id_arr as $v)
  3232. {
  3233. $data = $this->fullordersmt->read($v);
  3234. $warehouse = $this->warehouse->read($data['type']);
  3235. $fs = $this->notice->get_ordertatus($data['state']);
  3236. if($fs)
  3237. {
  3238. $ck = $this->_email($fs['content'],$data,$warehouse['company']);
  3239. if($ck == 1)
  3240. {
  3241. $this->fullordersmt->save(array('fscontent'=>date('Y-m-d H:i:s',time()).'已发送:'.$fs['title'].' - '),$v);
  3242. }
  3243. }
  3244. }
  3245. echo json_encode(array('msg'=>'发送完成!','success'=>true));exit;
  3246. }
  3247. }
  3248. public function _power()
  3249. {
  3250. $user = $this->user->get_api($_SESSION['api']);
  3251. $post = $this->input->post(NULL, TRUE);
  3252. if(isset($post['id']))
  3253. {
  3254. $id = $this->input->post('id',true);
  3255. $fullorder = $this->fullordersmt->read($id);
  3256. $express = $this->express->read($fullorder['express']);
  3257. $warehouse = $this->warehouse->read($fullorder['type']);
  3258. if(($warehouse['zd'] == '1' || stripos($fullorder['whlabel'],'z|') !== false) && $fullorder['library'] == '2')
  3259. {
  3260. echo json_encode(array('msg'=>'需要先退库释放库存后才可重置!','success'=>false));exit;
  3261. }
  3262. /**
  3263. if($fullorder['print'] == '3' && isset($express['iscode']) && ($express['iscode'] == 'ARAMEX' || $express['iscode'] == 'TOLL' || $express['iscode'] == 'FEDEX'))
  3264. {
  3265. $lj = $this->ali->get_lj($fullorder['number'],2,'订单修改');
  3266. if($lj != '1' && $lj != '订单不存在')
  3267. {
  3268. echo json_encode(array('msg'=>$lj,'success'=>false));exit;
  3269. }
  3270. }
  3271. **/
  3272. $this->db->trans_begin();
  3273. $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);
  3274. if($fullorder['merge'] != '0')
  3275. {
  3276. $hdata = $this->fullordersmt->find_all("merge = '".$fullorder['merge']."' and id != '".$id."'");
  3277. foreach ($hdata as $v)
  3278. {
  3279. $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']);
  3280. }
  3281. }
  3282. $warehouse = $this->warehouse->read($fullorder['warehouse']);
  3283. $typeclass = $this->typeclass->read($fullorder['state']);
  3284. $express = $this->express->read($fullorder['express']);
  3285. $printtype = array(1=>'运单',2=>'发货单',3=>'不打印单据');
  3286. $teset['number']=$fullorder['number'];
  3287. $teset['orderinfo']=$fullorder['orderinfo'];
  3288. $teset['shop']=$fullorder['shop'];
  3289. $teset['user']=$user['userid'];
  3290. $teset['ip']=$this->input->ip_address();
  3291. $teset['time']=time();
  3292. $teset['warehouse']=(isset($warehouse['title']))?$warehouse['title']:'未选择';
  3293. $teset['state']=(isset($typeclass['title']))?$typeclass['title']:'未选择';
  3294. $teset['express']=(isset($express['title']))?$express['servicename']:'未选择';
  3295. $teset['printtype']=(isset($printtype[$fullorder['printtype']]))?$printtype[$fullorder['printtype']]:'未选择';
  3296. $teset['reviewtime']=($fullorder['reviewtime'] > '0')?date('Y-m-d H:i:s',$fullorder['reviewtime']):'无';
  3297. $teset['printtime']=($fullorder['printtime'] > '0')?date('Y-m-d H:i:s',$fullorder['printtime']):'无';
  3298. $teset['librarytime']=($fullorder['librarytime'] > '0')?date('Y-m-d H:i:s',$fullorder['librarytime']):'无';
  3299. $teset['shipremarks']=$fullorder['shipremarks'];
  3300. $teset['fpdata']=$fullorder['fpdata'];
  3301. if(!$this->fullreset->insert($teset))
  3302. {
  3303. echo json_encode(array('msg'=>'重置失败,请重试','success'=>true));exit;
  3304. }
  3305. if ($this->db->trans_status() === TRUE)
  3306. {
  3307. $this->db->trans_commit();
  3308. echo json_encode(array('msg'=>'重置成功','success'=>true));exit;
  3309. }
  3310. else
  3311. {
  3312. $this->db->trans_rollback();
  3313. echo json_encode(array('msg'=>'重置失败,请重试','success'=>false));exit;
  3314. }
  3315. }
  3316. }
  3317. public function _expresstype()
  3318. {
  3319. $post = $this->input->post(NULL, TRUE);
  3320. if(isset($post['id']))
  3321. {
  3322. $id = $this->input->post('id',true);
  3323. $data = $this->express->read($id);
  3324. echo json_encode(array('msg'=>$data['type'],'success'=>true));exit;
  3325. }
  3326. }
  3327. public function _email($content,$data,$shopname)
  3328. {
  3329. $express = $this->express->read($data['express']);
  3330. $t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
  3331. $h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['servicename'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
  3332. $content = str_replace($t,$h,$content);
  3333. $this->load->library('email');
  3334. $config['protocol'] = 'smtp';
  3335. $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
  3336. $config['smtp_port'] = 465;
  3337. $config['smtp_user'] = 'service@email.supernovahair.com';
  3338. $config['smtp_pass'] = 'LONGyihair374';
  3339. $config['smtp_crypto'] = 'ssl';
  3340. $config['crlf'] = "\r\n";
  3341. $config['newline'] = "\r\n";
  3342. $this->email->initialize($config);
  3343. $this->email->from('service@email.supernovahair.com',$shopname);
  3344. $this->email->to($data['email']);//收件
  3345. $this->email->subject('The product you purchased has a new progress');//标题
  3346. $this->email->message($content);//内容
  3347. if ( ! $this->email->send())
  3348. {
  3349. return 2;
  3350. }
  3351. else
  3352. {
  3353. return 1;
  3354. }
  3355. }
  3356. public function _error()
  3357. {
  3358. if(isset($_SESSION['api']))
  3359. {
  3360. $user = $this->user->get_api($_SESSION['api']);
  3361. $usp = $user;
  3362. $fgshop = "";$sid = "";
  3363. $user = explode('|',trim($user['shop'],'|'));
  3364. foreach ($user as $value)
  3365. {
  3366. $fgshop .= " shop = ".$value." or";
  3367. $sid .= " id = ".$value." or";
  3368. }
  3369. }
  3370. $post = $this->input->post(NULL, TRUE);
  3371. if(isset($post['page']))
  3372. {
  3373. $page = $this->input->post('page',true);
  3374. $perpage = $this->input->post('perpage',true);
  3375. $orderinfo = $this->input->post('orderinfo',true);
  3376. $waybill = $this->input->post('waybill',true);
  3377. $number = $this->input->post('number',true);
  3378. $timetk = $this->input->post('timetk',true);
  3379. $timetj = $this->input->post('timetj',true);
  3380. $timetk = strtotime($timetk);
  3381. $timetj = strtotime($timetj);
  3382. $where = "failed !='' and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3383. if($orderinfo)
  3384. {
  3385. $where .= " and orderinfo = '$orderinfo'";
  3386. }
  3387. if($waybill)
  3388. {
  3389. $where .= " and waybill = '$waybill'";
  3390. }
  3391. if($number)
  3392. {
  3393. $where .= " and number = '$number'";
  3394. }
  3395. if($timetk && $timetj)
  3396. {
  3397. $timetj = $timetj+24*3600;
  3398. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3399. }
  3400. //数据排序
  3401. $order_str = "dtime desc";
  3402. if(empty($page))
  3403. {
  3404. $start = 0;
  3405. $perpage = 1;
  3406. }
  3407. else
  3408. {
  3409. $start = ($page - 1)*$perpage;
  3410. }
  3411. $info_list = $this->fullordersmt->find_all($where,'id,shop,type,orderinfo,number,express,failed,operation',$order_str,$start,$perpage);
  3412. //格式化数据
  3413. foreach ($info_list as $key=>$value)
  3414. {
  3415. $ud = $this->fullordersmt->read($value['id']);
  3416. $shop = $this->shop->read($value['shop']);
  3417. $info_list[$key]['shop'] = $shop['shopname'];
  3418. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'>".$value['orderinfo']."<p>";
  3419. $warehouse = $this->warehouse->read($value['type']);
  3420. $warehousetitle = $warehouse['title'];
  3421. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  3422. $info_list[$key]['type'] = $warehousetitle;
  3423. if($value['express'] != 0)
  3424. {
  3425. $express = $this->express->read($value['express']);
  3426. $expressservicename = $express['servicename'];
  3427. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  3428. $info_list[$key]['express'] = $expressservicename;
  3429. }
  3430. else
  3431. {
  3432. $info_list[$key]['express'] = "无";
  3433. }
  3434. $x = "";
  3435. if($ud['review'] >4 && $ud['print'] == 1)
  3436. {
  3437. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  3438. }
  3439. else if($ud['review'] >4 && $ud['print'] == 3 && $ud['libraryconfirm'] == 1)
  3440. {
  3441. $x = "<p class='ckn'><b class='fojzof' data-type='10' data-id='".$value['id']."'>清除错误</b></p>";
  3442. }
  3443. else
  3444. {
  3445. $x = "<p class='ckn'><b class='fojzof' data-type='9' data-id='".$value['id']."'>关闭</b></p>";
  3446. }
  3447. $info_list[$key]['operation'] = $x;
  3448. }
  3449. $total = $this->fullordersmt->find_count($where);
  3450. $pagenum = ceil($total/$perpage);
  3451. $over = $total-($start+$perpage);
  3452. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3453. echo json_encode($rows);exit;
  3454. }
  3455. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3456. $this->data['wlshop'] = $wlshop;
  3457. $this->data['express'] = $this->express->find_all();
  3458. $user = $this->user->get_api($_SESSION['api']);
  3459. $powerid = $this->power->read($user['power']);
  3460. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3461. $pid = '';
  3462. foreach ($powertext as $v)
  3463. {
  3464. $pid .= " id = ".$v." or";
  3465. }
  3466. $fullorderexcel = $this->fullorderexcel->find_all("type = '100004' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3467. $this->data['fullorderexcel'] = $fullorderexcel;
  3468. $this->_Template('fullordersmt_error',$this->data);
  3469. }
  3470. //关闭订单详情时保存备注
  3471. public function _bcbz()
  3472. {
  3473. $post = $this->input->post(NULL, TRUE);
  3474. if(isset($post['id']))
  3475. {
  3476. $fpcount = $this->input->post('fpcount',true);
  3477. if(!$fpcount)
  3478. {
  3479. echo json_encode(array('msg'=>'未设置商品信息!','success'=>false));exit;
  3480. }
  3481. $post['edittime'] = time();
  3482. $fpdata = $this->input->post('fpdata');
  3483. $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
  3484. $post['fpdata'] = $fpdata;
  3485. $post['state'] = $this->input->post('state');
  3486. $post['type'] = $this->input->post('warehouse');
  3487. $post['ioss'] = $this->input->post('ioss');
  3488. $rtime = $this->input->post('rtime',true);
  3489. if($rtime)
  3490. {
  3491. $post['rtime'] = strtotime($rtime);
  3492. }
  3493. $id = $this->input->post('id',TRUE);
  3494. $whlabel = $this->input->post('whlabel',true);
  3495. $data = $this->fullordersmt->read($id);
  3496. $editstate = $post['state'];
  3497. if($data['library'] == 1)
  3498. {
  3499. if($data['print'] != 3 && $data['review'] < 5)
  3500. {
  3501. $post['libraryconfirm'] = 1;
  3502. $post['librarynot'] = "订单未打印";
  3503. }
  3504. else if($data['print'] != 3 && $data['review'] > 4)
  3505. {
  3506. $post['print'] = 1;
  3507. $post['libraryconfirm'] = 1;
  3508. $post['librarynot'] = "订单未打印,订单审核后修改";
  3509. }
  3510. else
  3511. {
  3512. $post['libraryconfirm'] = 1;
  3513. $post['librarynot'] = "订单打印后修改";
  3514. }
  3515. }
  3516. if($data['yhs'] == 1)
  3517. {
  3518. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  3519. }
  3520. 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))
  3521. {
  3522. echo json_encode(array('msg'=>'此快递方式必须选择美国仓!','success'=>false));exit;
  3523. }
  3524. if(($post['express'] == '5' || $post['express'] == '24' || $post['express'] == '31') && $data['country'] != 192)
  3525. {
  3526. echo json_encode(array('msg'=>'非美国无法选择Fedex!','success'=>false));exit;
  3527. }
  3528. if(($post['express'] == '28' || $post['express'] == '7') && $data['country'] != 191)
  3529. {
  3530. echo json_encode(array('msg'=>'非英国无法选择CNE和GES!','success'=>false));exit;
  3531. }
  3532. $express = $this->express->read($post['express']);
  3533. if($express['ioss'] == 1 && $post['ioss'] == '')
  3534. {
  3535. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  3536. }
  3537. if(isset($post['address']) && (strlen($post['address']) > $express['addresssize'] || strlen($post['address2']) > $express['addresssize']))
  3538. {
  3539. echo json_encode(array('msg'=>'此快递地址不可超出'.$express['addresssize'].'个字符','success'=>false));exit;
  3540. }
  3541. if($data['type'] != '5' && $post['type'] == '5' && $editstate != '207')
  3542. {
  3543. echo json_encode(array('msg'=>'等待发货状态才可选择美仓!','success'=>false));exit;
  3544. }
  3545. if($data['library'] == 2 && $data['print'] == 3 && $data['waybill'] != $post['waybill'])
  3546. {
  3547. echo json_encode(array('msg'=>'不允许修改运单号','success'=>true));exit;
  3548. }
  3549. //南非 限制邮箱
  3550. if($post['country'] == 166){
  3551. if(empty($post['email'])){
  3552. echo json_encode(array('msg'=>'惠程安迈世发货需要有邮箱!','success'=>false));exit;
  3553. }else{
  3554. if(!$this->logic_order->checkEmail($post['email'])){
  3555. echo json_encode(array('msg'=>'邮箱格式不正确!','success'=>false));exit;
  3556. }
  3557. }
  3558. }
  3559. if(empty($post['zsbjz']*1)){
  3560. echo json_encode(array('msg'=>'申报金额不可为0!','success'=>false));exit;
  3561. }
  3562. if(empty($post['dtsbjz']*1)){
  3563. echo json_encode(array('msg'=>'单条申报价值不能为0!','success'=>false));exit;
  3564. }
  3565. $thisdata = $data;
  3566. $warehouse = $this->warehouse->read($thisdata['type']);
  3567. $warehousenew = $this->warehouse->read($post['type']);
  3568. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  3569. {
  3570. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  3571. }
  3572. /**
  3573. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  3574. {
  3575. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  3576. }
  3577. **/
  3578. if($data['shop'] == '9' && $post['type'] != '7' && $post['type'] != '8' && $post['type'] != '9')
  3579. {
  3580. echo json_encode(array('msg'=>'仓库选择错误!','success'=>false));exit;
  3581. }
  3582. //减少代码复用吧
  3583. $lo_ret = $this->logic_order->checkEditExpress($post);
  3584. if($lo_ret['code'] != 1){
  3585. echo json_encode(array('msg'=>$lo_ret['msg'],'success'=>false));exit;
  3586. }
  3587. /**
  3588. if($warehousenew['zd'] == '1' && $editstate != $thisdata['state'] && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  3589. {
  3590. echo json_encode(array('msg'=>'如需更改订单状态,请先把仓库选择为非开启库存模式仓库或等待订单出库!','success'=>false));exit;
  3591. }
  3592. if($warehousenew['zd'] == '1' && $editstate != '207' && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  3593. {
  3594. echo json_encode(array('msg'=>'非待发货状态,不允许修改为开启库存模式仓库','success'=>false));exit;
  3595. }
  3596. **/
  3597. //开始注释 xyxg
  3598. /**
  3599. $ft = array();
  3600. $ftdata = explode('|',rtrim($fpcount,'|'));
  3601. foreach ($ftdata as $va)
  3602. {
  3603. $ftitle = '';
  3604. $va = explode('-',trim($va,'-'));
  3605. foreach ($va as $v)
  3606. {
  3607. $v = $this->typeclass->read($v);
  3608. $ftitle .= $v['title'].' ';
  3609. }
  3610. $ft[] = rtrim($ftitle,' ');
  3611. }
  3612. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  3613. {
  3614. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  3615. if($tskcyz['t'] > '0')
  3616. {
  3617. echo $tskcyz['m'];exit;
  3618. }
  3619. }
  3620. $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']);//旧状态、新状态、仓库占单设置、仓库预设设置、新仓库、新产品简化数字、旧产品数字、旧产品名称、订单号、订单店铺、旧订单仓库、旧产品简化数字
  3621. if($kcyz['t'] > '0')
  3622. {
  3623. echo $kcyz['m'];exit;
  3624. }
  3625. else
  3626. {
  3627. if($this->fullordersmt->save($post,$id))
  3628. {
  3629. echo json_encode(array('msg'=>'保存成功','id'=>$id,'a'=>$kcyz,'success'=>true));exit;
  3630. }
  3631. else
  3632. {
  3633. echo json_encode(array('msg'=>'保存失败,请重试','success'=>false));exit;
  3634. }
  3635. }
  3636. //结束注释
  3637. **/
  3638. $warehouse = $this->warehouse->read($post['type']);
  3639. if($data['library'] == 1 || ($data['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  3640. {
  3641. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  3642. if($kcyz['t'] > '0')
  3643. {
  3644. echo $kcyz['m'];exit;
  3645. }
  3646. else if($kcyz['fpdata'] != '')
  3647. {
  3648. $post['whlabel'] = $kcyz['whlabel'];
  3649. $post['fpdata'] = $kcyz['fpdata'];
  3650. }
  3651. }
  3652. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  3653. $post['sfxh'] = $fl['sfxh'];
  3654. $post['ckfl'] = $fl['ckfl'];
  3655. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  3656. if($this->fullordersmt->save($post,$id))
  3657. {
  3658. echo json_encode(array('msg'=>'保存成功','id'=>$id,'success'=>true));exit;
  3659. }
  3660. else
  3661. {
  3662. echo json_encode(array('msg'=>'保存失败,请重试','success'=>false));exit;
  3663. }
  3664. }
  3665. }
  3666. //验证地址
  3667. public function _yzaddress()
  3668. {
  3669. $post = $this->input->post(NULL, TRUE);
  3670. if(isset($post['address']))
  3671. {
  3672. $address = $this->input->post('address',true);
  3673. $address2 = $this->input->post('address2',true);
  3674. $city = $this->input->post('city',true);
  3675. $province = $this->input->post('province',true);
  3676. $zipcode = $this->input->post('zipcode',true);
  3677. $barcode = $this->usps->get_address(array('address'=>$address,'address2'=>$address2,'city'=>$city,'province'=>$province,'zipcode'=>$zipcode));
  3678. echo $barcode;
  3679. }
  3680. }
  3681. //订单退货
  3682. public function _return()
  3683. {
  3684. $post = $this->input->post(NULL, TRUE);
  3685. if(isset($post['orderinfo']))
  3686. {
  3687. $orderinfo = $this->input->post('orderinfo',true);
  3688. $data = $this->fullordersmt->get_orderinfo($orderinfo);
  3689. $fu = 'fullordersmt';
  3690. $bctime = date('Ymd',time());
  3691. if($data['returndata'] != "")
  3692. {
  3693. echo json_encode(array('msg'=>'请求失败,已有退货信息!','success'=>false));exit;
  3694. }
  3695. if($data['library'] != 2){
  3696. echo json_encode(array('msg'=>'此单不是出库状态,不允许退货','success'=>false));exit;
  3697. }
  3698. $barcode = $this->usps->get_return($data);
  3699. if(isset($barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription']))
  3700. {
  3701. echo json_encode(array('msg'=>$barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription'],'success'=>false));exit;
  3702. }
  3703. else
  3704. {
  3705. $pdf = $this->_pdf($barcode['ReturnLabel'],'t-'.$barcode['TrackingNumber'],$bctime);
  3706. $read = 'PostalRouting:'.$barcode['PostalRouting'].' - TrackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['TrackingNumber'].'.pdf" target="_blank">'.$barcode['TrackingNumber'].'</a>';
  3707. $this->$fu->save(array('returndata'=>$read),$data['id']);
  3708. echo json_encode(array('msg'=>'退货成功!','data'=>$read,'success'=>true));exit;
  3709. }
  3710. }
  3711. }
  3712. public function _pdf($pdf,$title,$bctime)
  3713. {
  3714. $pdf_path = './data/pdf/'.$bctime.'/';
  3715. $file_base64 = $pdf;
  3716. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  3717. $file_base64 = base64_decode($file_base64);
  3718. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  3719. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  3720. return $bctime;
  3721. }
  3722. //管理
  3723. public function _aaa()
  3724. {
  3725. $dt = 0;
  3726. if(isset($_SESSION['api']))
  3727. {
  3728. $user = $this->user->get_api($_SESSION['api']);
  3729. $usp = $user;
  3730. $fgshop = "";$sid = "";
  3731. $user = explode('|',trim($user['shop'],'|'));
  3732. foreach ($user as $value)
  3733. {
  3734. $fgshop .= " shop = ".$value." or";
  3735. $sid .= " id = ".$value." or";
  3736. }
  3737. }
  3738. $post = $this->input->post(NULL, TRUE);
  3739. if(isset($post['page']))
  3740. {
  3741. $page = $this->input->post('page',true);
  3742. $perpage = $this->input->post('perpage',true);
  3743. $warehouse = $this->input->post('warehouse',true);
  3744. $timetk = $this->input->post('timetkk',true);
  3745. $timetj = $this->input->post('timetjj',true);
  3746. $shop = $this->input->post('shop',true);
  3747. $source = $this->input->post('source',true);
  3748. $state = $this->input->post('state',true);
  3749. $review = $this->input->post('review',true);
  3750. $type = $this->input->post('type',true);
  3751. $express = $this->input->post('express',true);
  3752. $orderinfo = $this->input->post('orderinfo',true);
  3753. $user = $this->input->post('user',true);
  3754. $client = $this->input->post('name',true);
  3755. $fullname = $this->input->post('fullname',true);
  3756. $waybill = $this->input->post('waybill',true);
  3757. $number = $this->input->post('number',true);
  3758. $email = $this->input->post('email',true);
  3759. $dlz = $this->input->post('dlz',true);
  3760. $print = $this->input->post('print',true);
  3761. $library = $this->input->post('library',true);
  3762. $xztime = $this->input->post('xztime',true);
  3763. $timetk = strtotime($timetk)-1;
  3764. $timetj = strtotime($timetj);
  3765. $px = $this->input->post('px',true);
  3766. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3767. if($warehouse)
  3768. {
  3769. $where .= " and type = '$warehouse'";
  3770. }
  3771. if($timetk && $timetj)
  3772. {
  3773. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3774. }
  3775. if($shop)
  3776. {
  3777. $where .= " and shop = '$shop'";
  3778. }
  3779. if($source)
  3780. {
  3781. $where .= " and source = '$source'";
  3782. }
  3783. if($state)
  3784. {
  3785. $where .= " and state = '$state'";
  3786. }
  3787. if($review)
  3788. {
  3789. $where .= " and review = '$review'";
  3790. }
  3791. if($type)
  3792. {
  3793. $where .= " and type = '$type'";
  3794. }
  3795. if($express)
  3796. {
  3797. $where .= " and express = '$express'";
  3798. }
  3799. if($orderinfo)
  3800. {
  3801. $where .= " and orderinfo = '$orderinfo'";
  3802. }
  3803. if($user)
  3804. {
  3805. $where .= " and user = '$user'";
  3806. }
  3807. if($client)
  3808. {
  3809. $where .= " and client like '%$client%'";
  3810. }
  3811. if($waybill)
  3812. {
  3813. $where .= " and waybill = '$waybill'";
  3814. }
  3815. if($number)
  3816. {
  3817. $where .= " and number = '$number'";
  3818. }
  3819. if($email)
  3820. {
  3821. $where .= " and email = '$email'";
  3822. }
  3823. if($library)
  3824. {
  3825. $where .= " and library = '$library'";
  3826. }
  3827. if($print)
  3828. {
  3829. $where .= " and print = '$print'";
  3830. }
  3831. if($dlz != '')
  3832. {
  3833. $where .= " and dlz = '$dlz'";
  3834. }
  3835. if($fullname)
  3836. {
  3837. $where .= " and fullname = '$fullname'";
  3838. }
  3839. //数据排序
  3840. if($px)
  3841. {
  3842. $order_str = $px." desc";
  3843. }
  3844. else
  3845. {
  3846. $order_str = "numberpx desc";
  3847. }
  3848. if(empty($page))
  3849. {
  3850. $start = 0;
  3851. $perpage = 1;
  3852. }
  3853. else
  3854. {
  3855. $start = ($page - 1)*$perpage;
  3856. }
  3857. //取得信息列表id,shop,type,source,user,orderinfo,number,name,state,buytime,clientremarks,review,print,library,libraryconfirm,express,waybill,orderremarks,black
  3858. $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);
  3859. //格式化数据
  3860. foreach ($info_list as $key=>$value)
  3861. {
  3862. $ud = $this->fullordersmt1->read($value['id']);
  3863. $ud['address'] = str_replace("'","’",$ud['address']);
  3864. $ud['name'] = str_replace("'","’",$ud['name']);
  3865. $customer = $ud['source'] != 1?$this->customersmt1->get_fullname($ud['fullname']):$this->customersmt1->get_shopdata($value['shop'],$ud['name'],$ud['address']);
  3866. //$a = array_column($customer, 'email'); //三维找其中健的数组
  3867. //$a = array_flip($a); //键和值调换
  3868. $currency = $this->country->read($ud['country']);
  3869. $name = ($ud['source'] == 1)?$ud['name']:$value['fullname'];
  3870. $lkh = "<p>".$name."</p><p style='color:#8f54fb'>".$currency['ename']."</p>";
  3871. if($customer)
  3872. {
  3873. if($customer['type'] == 1 && $customer['num'] > 1)
  3874. {
  3875. $lkh .= "<p style='color:#FF3333'>老客户</p>";
  3876. }
  3877. else if($customer['type'] == 2)
  3878. {
  3879. $hmsp = $this->shop->read($customer[0]['shop']);
  3880. $lkh .= "<p style='color:#9900CC'>黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  3881. }
  3882. }
  3883. $info_list[$key]['fullname'] = $lkh;
  3884. $shop = $this->shop->read($value['shop']);
  3885. $info_list[$key]['shop'] = $shop['shopname'];
  3886. //$info_list[$key]['user'] = $shop['shopuser'];
  3887. $warehouse = $this->warehouse->read($value['type']);
  3888. $warehousetitle = $warehouse['title'];
  3889. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  3890. $info_list[$key]['type'] = $warehousetitle;
  3891. $typeclass = $this->typeclass->read($value['state']);
  3892. if($ud['source'] != 1)
  3893. {
  3894. $info_list[$key]['state'] = "<a href='https://trade.aliexpress.com/order_detail.htm?orderId=".$value['orderinfo']."' target='_blank'>".$typeclass['title']."</a>";
  3895. }
  3896. else
  3897. {
  3898. $info_list[$key]['state'] = $typeclass['title'];
  3899. }
  3900. if(!$value['buytime'])
  3901. {
  3902. $info_list[$key]['buytime'] = '<p>无</p>';
  3903. }
  3904. else
  3905. {
  3906. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']-$dt).'</p><p>'.date('H:i:s',$value['buytime']-$dt).'</p>';
  3907. }
  3908. if($value['review'] == 1)
  3909. {
  3910. $info_list[$key]['review'] = "未送审";
  3911. }
  3912. else if($value['review'] == 2)
  3913. {
  3914. $info_list[$key]['review'] = "<font style='color:#555'>待审核</font>";
  3915. }
  3916. else if($value['review'] == 3)
  3917. {
  3918. $info_list[$key]['review'] = "<font style='color:#f90f4b'>不通过</font>";
  3919. }
  3920. else if($value['review'] == 4)
  3921. {
  3922. $info_list[$key]['review'] = "取消重审";
  3923. }
  3924. else if($value['review'] == 5)
  3925. {
  3926. $info_list[$key]['review'] = "<font style='color:#2f80f9'>审核通过</font>";
  3927. }
  3928. else if($value['review'] == 6)
  3929. {
  3930. $info_list[$key]['review'] = "<font style='color:#2f80f9'>自动通过</font>";
  3931. }
  3932. if($ud['dlz'] == 1)
  3933. {
  3934. $dlz = "<p>发货声明成功</p>";
  3935. }
  3936. else if($ud['dlz'] == 3)
  3937. {
  3938. $dlz = "<p>不需要发货声明</p>";
  3939. }
  3940. else if($ud['dlz'] == 2)
  3941. {
  3942. $dlz = "<p style='color:#C3C'>发货声明失败</p>";
  3943. }
  3944. else
  3945. {
  3946. $dlz = "";
  3947. }
  3948. if($value['waybill'] != "")
  3949. {
  3950. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz;
  3951. if( !empty($value['waybillid'])){
  3952. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz."<p>".$value['waybillid']."</p>";
  3953. }
  3954. }
  3955. if($value['express'] != 0)
  3956. {
  3957. $express = $this->express->read($value['express']);
  3958. $expressservicename = $express['servicename'];
  3959. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  3960. $info_list[$key]['express'] = $expressservicename;
  3961. }
  3962. else
  3963. {
  3964. $info_list[$key]['express'] = "无";
  3965. }
  3966. $x = "";
  3967. if($value['libraryconfirm'] == 2 && $value['review'] > 4 && $ud['library'] == 1)
  3968. {
  3969. $x = "<p class='ckn'><b class='fojz' data-type='1'>禁止发货</b></p>";
  3970. }
  3971. else if(($value['review'] > 4) && $ud['print'] != 1 && $value['libraryconfirm'] == 1)
  3972. {
  3973. $x = "<p class='ckn'><b class='fojzof' data-type='6' data-id='".$value['id']."'>允许发货</b></p>";
  3974. }
  3975. if(($value['review'] > 4) && $ud['print'] == 2)
  3976. {
  3977. $x = "<p class='ckn'><b class='fojzof' data-type='7' data-id='".$value['id']."'>禁止打印</b></p>";
  3978. }
  3979. else if($value['review'] >4 && $ud['print'] == 1)
  3980. {
  3981. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  3982. }
  3983. if($value['waybill'] == "" && $value['review'] > 4)
  3984. {
  3985. $x .= "<p><b class='kn' data-type='2'>填写运单号</b></p>";
  3986. }
  3987. else if($value['waybill'] != "" && $value['review'] > 4)
  3988. {
  3989. $x .= "<p><b class='kn' data-type='2'>修改运单</b></p>";
  3990. }
  3991. 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)
  3992. {
  3993. $x .= "<p><b class='focz' data-type='2' data-id='".$value['id']."'>提交审核</b></p>";
  3994. }
  3995. $x .= "<p><b class='window' data-h='/customersmt/edit/".$customer['id']."' data-t='客户信息 - 修改'>客户信息</b></p>";
  3996. $info_list[$key]['black'] = $x;
  3997. $tly = "";
  3998. if($value['clientremarks'] != "")
  3999. {
  4000. $tly = "<p style='color:#FF3333'>有客户留言</p>";
  4001. }
  4002. if($value['review'] > 4 && $usp['vip'] != 1)
  4003. {
  4004. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/readonly/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  4005. }
  4006. else
  4007. {
  4008. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/b/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  4009. }
  4010. if($value['library'] == 1 && $ud['printtype'] == 3)
  4011. {
  4012. $info_list[$key]['library'] = "不需要";
  4013. }
  4014. else if($value['library'] == 1 && $ud['printtype'] != 3)
  4015. {
  4016. $info_list[$key]['library'] = "未出库";
  4017. }
  4018. else if($value['library'] == 2)
  4019. {
  4020. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  4021. }
  4022. else if($value['library'] == 3)
  4023. {
  4024. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  4025. }
  4026. unset($info_list[$key]['waybillid']);
  4027. }
  4028. $total = $this->fullordersmt1->find_count($where);
  4029. $pagenum = ceil($total/$perpage);
  4030. $over = $total-($start+$perpage);
  4031. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4032. echo json_encode($rows);exit;
  4033. }
  4034. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4035. $this->data['wlshop'] = $wlshop;
  4036. $this->data['express'] = $this->express->find_all();
  4037. $user = $this->user->get_api($_SESSION['api']);
  4038. $powerid = $this->power->read($user['power']);
  4039. $powertext = explode('|',trim($powerid['excelid'],'|'));
  4040. $pid = '';
  4041. foreach ($powertext as $v)
  4042. {
  4043. $pid .= " id = ".$v." or";
  4044. }
  4045. $fullorderexcel = $this->fullorderexcel->find_all("type = '100004' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  4046. $this->data['fullorderexcel'] = $fullorderexcel;
  4047. $error = $this->fullordersmt1->find_count("print = 1 and failed !='' and mergeid = 0 and waybill = '' and (".rtrim($fgshop,'or').")");
  4048. $this->data['error'] = $error;
  4049. $this->_Template('fullordersmt_a',$this->data);
  4050. }
  4051. public function _bbb($arg_array)
  4052. {
  4053. $post = $this->input->post(NULL, TRUE);
  4054. if(isset($post['id']))
  4055. {
  4056. $id = $this->input->post('id',true);
  4057. $data = $this->fullordersmt1->read($id);
  4058. $post['type'] = $this->input->post('warehouse',true);
  4059. $post['country'] = $this->input->post('country',true);
  4060. $currency = $this->country->read($post['country']);
  4061. $post['al'] = $currency['lb'];
  4062. $post['freight'] = $this->input->post('freight',true);
  4063. $post['expressmoney'] = $this->input->post('expressmoney',true);
  4064. $post['shouldmoney'] = $this->input->post('shouldmoney',true);
  4065. $post['orderremarks'] = $this->input->post('orderremarks',true);
  4066. $shipremarks = $this->input->post('shipremarks');
  4067. $shipremarks = str_replace(array('%26','%2B'),array('&','+'),$shipremarks);
  4068. $post['shipremarks'] = preg_replace('/( | | |\s)/',' ',$shipremarks);
  4069. $post['email'] = $this->input->post('email',true);
  4070. $name = $this->input->post('name',true);
  4071. $post['name'] = str_replace("'","’",$name);
  4072. $post['phone'] = $this->input->post('phone',true);
  4073. $post['country'] = $this->input->post('country',true);
  4074. $post['province'] = $this->input->post('province',true);
  4075. $post['city'] = $this->input->post('city',true);
  4076. $post['zipcode'] = $this->input->post('zipcode',true);
  4077. $post['street'] = $this->input->post('street',true);
  4078. $address = $this->input->post('address',true);
  4079. $post['address'] = str_replace("'","’",$address);
  4080. $post['express'] = $this->input->post('express',true);
  4081. $post['printtype'] = $this->input->post('printtype',true);
  4082. $post['fpdata'] = $this->input->post('fpdata');
  4083. $post['waybill'] = $this->input->post('waybill',true);
  4084. $post['msg'] = $this->input->post('msg',true);
  4085. $post['zsbjz'] = $this->input->post('zsbjz',true);
  4086. $post['refundy'] = $this->input->post('refundy',true);
  4087. $post['refundj'] = $this->input->post('refundj',true);
  4088. $rtime = $this->input->post('rtime',true);
  4089. $post['rtime'] = strtotime($rtime);
  4090. $post['rpaypal'] = $this->input->post('rpaypal',true);
  4091. $post['rtext'] = $this->input->post('rtext',true);
  4092. $editstate = $this->input->post('state',true);
  4093. $post['review'] = 1;
  4094. if($post['zsbjz'] < '0.01')
  4095. {
  4096. echo json_encode(array('msg'=>'总申报价错误!','success'=>false));exit;
  4097. }
  4098. if($data['library'] == 1)
  4099. {
  4100. if($data['print'] != 3 && $data['review'] < 5)
  4101. {
  4102. $post['libraryconfirm'] = 1;
  4103. $post['librarynot'] = "订单未打印";
  4104. }
  4105. else if($data['print'] != 3 && $data['review'] > 4)
  4106. {
  4107. $post['print'] = 1;
  4108. $post['libraryconfirm'] = 1;
  4109. $post['librarynot'] = "订单未打印,订单审核后修改";
  4110. }
  4111. else
  4112. {
  4113. $post['libraryconfirm'] = 1;
  4114. $post['librarynot'] = "订单打印后修改";
  4115. }
  4116. }
  4117. if($post['printtype'] == 1)//如果是运单
  4118. {
  4119. $post['productdescription'] = $this->input->post('productdescription',true);
  4120. $post['customs'] = $this->input->post('customs',true);
  4121. }
  4122. /**
  4123. if($editstate == 216 && $data['state'] != 216)
  4124. {
  4125. echo json_encode(array('msg'=>'不可修改为完成状态','success'=>false));exit;
  4126. }
  4127. **/
  4128. if($editstate == 216 && preg_match('/\d/is',$post['waybill']) != true)
  4129. {
  4130. echo json_encode(array('msg'=>'当前信息不可修改订单状态','success'=>false));exit;
  4131. }
  4132. else
  4133. {
  4134. if($data['review'] == 1 && $data['source'] != 1)
  4135. {
  4136. $review = 6;
  4137. }
  4138. else if($data['review'] == 3 || ($data['review'] == 1 && $data['source'] == 1))
  4139. {
  4140. $review = 2;
  4141. }
  4142. else
  4143. {
  4144. $review = $data['review'];
  4145. }
  4146. $post['review'] = $review;
  4147. $post['state'] = $editstate;
  4148. $post['reviewtime'] = time();
  4149. }
  4150. if($this->fullordersmt1->save($post,$id))
  4151. {
  4152. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  4153. }
  4154. else
  4155. {
  4156. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  4157. }
  4158. }
  4159. $arg_array = $arg_array[0];$fpdata = array();
  4160. $fullordersmt = $this->fullordersmt1->read($arg_array);
  4161. $fullordersmt['parameter'] = str_replace(",","---",$fullordersmt['parameter']);
  4162. $country = $this->country->find_all('1=1','id,name','name asc');//所有国家信息
  4163. $express = $this->express->find_all('1=1');//所有快递配置信息
  4164. $this->data['fullordersmt'] = $fullordersmt;
  4165. $this->data['country'] = $country;
  4166. $this->data['express'] = $express;
  4167. $this->data['dtime'] = date('Y-m-d H:i:s',$fullordersmt['dtime']);
  4168. if(stripos($fullordersmt['fpdata'],';') !== false)
  4169. {
  4170. $fpdata = explode(';',rtrim($fullordersmt['fpdata'],';'));
  4171. foreach ($fpdata as $k=>$v)
  4172. {
  4173. $fpdata[$k] = explode('|',$v);
  4174. }
  4175. }
  4176. $this->data['fpdata'] = $fpdata;
  4177. $shop = $this->shop->read($fullordersmt['shop']);
  4178. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  4179. $is = 0;
  4180. if($shop['type'] == 269)//判断是否独立站,269是独立站
  4181. {
  4182. $is = 1;
  4183. }
  4184. $this->data['is'] = $is;
  4185. if(isset($_SESSION['api']))
  4186. {
  4187. $user = $this->user->get_api($_SESSION['api']);
  4188. if($user['vip'] == 1)
  4189. {
  4190. $vip = 1;
  4191. }
  4192. else
  4193. {
  4194. $vip = 0;
  4195. }
  4196. }
  4197. else
  4198. {
  4199. $vip = 0;
  4200. }
  4201. $this->data['power'] = $vip;
  4202. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  4203. $downwaybill = '';
  4204. if($fullordersmt['printtype'] == 1)
  4205. {
  4206. if($fullordersmt['waybill'] != '')
  4207. {
  4208. $downwaybill .= '<a href="/data/pdf/'.date('Ymd',$fullordersmt['printtime']).'/y-'.$fullordersmt['waybill'].'.pdf" target="_blank">'.$fullordersmt['waybill'].'</a>、';
  4209. }
  4210. }
  4211. $oldwaybill = explode('-',ltrim($fullordersmt['oldwaybill'],'-'));
  4212. if(isset($oldwaybill[0][1]))
  4213. {
  4214. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  4215. foreach ($oldwaybill as $v)
  4216. {
  4217. $dw = explode('/',$v);
  4218. if(isset($dw[1]))
  4219. {
  4220. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  4221. }
  4222. }
  4223. }
  4224. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  4225. /** 历史打印时间 **/
  4226. $printtime = '';
  4227. if($fullordersmt['oldprinttime'])
  4228. {
  4229. $pte = explode('-',rtrim($fullordersmt['oldprinttime'],'-'));
  4230. foreach ($pte as $v)
  4231. {
  4232. $printtime .= date('Y-m-d H:i:s',$v).'、';
  4233. }
  4234. }
  4235. $this->data['printtime'] = rtrim($printtime,'、');
  4236. $this->_Template('fullordersmt_b',$this->data);
  4237. }
  4238. public function _cf() //速卖通订单拆分
  4239. {
  4240. $post = $this->input->post(NULL, TRUE);
  4241. if(isset($post['id']))
  4242. {
  4243. $id = $this->input->post('id',true);
  4244. $b = $this->fullordersmt->read($id);
  4245. $order = array();
  4246. if($b['merge'] == $b['id'])
  4247. {
  4248. $data = $this->fullordersmt->find_all("merge = '".$b['merge']."'");
  4249. foreach ($data as $v)
  4250. {
  4251. $a = $this->fullordersmthb->get_orderinfo($v['orderinfo']);
  4252. if($a)
  4253. {
  4254. $this->fullordersmt->save($a,$v['id']);
  4255. }
  4256. $order[] = $v['id'];
  4257. }
  4258. echo json_encode(array('msg'=>'拆分成功!','d'=>$order,'success'=>true));exit;
  4259. }
  4260. else
  4261. {
  4262. echo json_encode(array('msg'=>'拆分条件错误!','success'=>false));exit;
  4263. }
  4264. }
  4265. }
  4266. public function _epod()
  4267. {
  4268. $post = $this->input->post(NULL, TRUE);
  4269. if(isset($post['number']))
  4270. {
  4271. $number = $this->input->post('number',true);
  4272. $data = $this->fullordersmt->get_number($number);
  4273. if(is_file('./data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf'))
  4274. {
  4275. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].'/data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf','success'=>true));exit;
  4276. }
  4277. else
  4278. {
  4279. $epod = $this->dhl->get_epod($data);
  4280. if($epod['c'] == 1)
  4281. {
  4282. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].$epod['d'],'success'=>true));exit;
  4283. }
  4284. else
  4285. {
  4286. echo json_encode(array('msg'=>$epod['d'],'success'=>false));exit;
  4287. }
  4288. }
  4289. }
  4290. }
  4291. public function _ddcf()
  4292. {
  4293. $post = $this->input->post(NULL, TRUE);
  4294. if(isset($post['number']))
  4295. {
  4296. $number = $this->input->post('number',true);
  4297. $data = $this->fullordersmt->get_number($number);
  4298. if(!$data)
  4299. {
  4300. echo json_encode(array('msg'=>'没有找到此订单','success'=>false));exit;
  4301. }
  4302. if($data['review'] != 1 && $data['review'] != 2)
  4303. {
  4304. echo json_encode(array('msg'=>'必须是 待审核 状态才能拆分','success'=>false));exit;
  4305. }
  4306. $cfnum = explode('-',trim($number,'-'));
  4307. if((count($cfnum)> 3 && stripos($pd[$x],'-PF-') !== false) || (count($cfnum)> 4 && stripos($pd[$x],'-PF-') === false))
  4308. {
  4309. echo json_encode(array('msg'=>'只能在原单操作拆分','success'=>false));exit;
  4310. }
  4311. $num = $this->fullordersmt->find_count("number like '".$number."%'");
  4312. $data['number'] = $data['number'].'-'.$num;
  4313. $data['orderinfo'] = $data['shop'].date('ymdHis',time()).rand(0,1);
  4314. $data['shouldmoney'] = 0;
  4315. $data['budget'] = 0;
  4316. $data['shipremarks'] = '';
  4317. $data['source'] = 1;
  4318. unset($data['id']);
  4319. unset($data['jweight']);
  4320. unset($data['fpcount']);
  4321. unset($data['returndata']);
  4322. unset($data['waybill']);
  4323. unset($data['oldwaybill']);
  4324. unset($data['printtime']);
  4325. if($this->fullordersmt->insert($data))
  4326. {
  4327. echo json_encode(array('msg'=>'拆分成功!新订单编号:'.$data['number'],'success'=>true));exit;
  4328. }
  4329. else
  4330. {
  4331. echo json_encode(array('msg'=>'拆分失败,请重试','success'=>false));exit;
  4332. }
  4333. }
  4334. }
  4335. }