Fullordersmt.php 148 KB

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