Fullordersmt.php 152 KB

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