Fullordersmt.php 146 KB

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