Fullordersmt.php 154 KB

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