Fullordersmt.php 147 KB

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