Fullordersmt.php 145 KB

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