Fullordersmt.php 155 KB

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