Fullordersmt.php 152 KB

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