Fullordersmt.php 152 KB

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