Fullordersmt.php 152 KB

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