Fullordersmt.php 154 KB

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