Fullorderexcel.php 128 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Fullorderexcel extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_fullorder','fullorder');
  7. $this->load->_model('Model_fullordertt','fullordertt');
  8. $this->load->_model('Model_fullorderxw','fullorderxw');
  9. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  10. $this->load->_model('Model_fullordersmt','fullordersmt');
  11. $this->load->_model('Model_fullorderamz','fullorderamz');
  12. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  13. $this->load->_model('Model_fullorderexcelclassid','fullorderexcelclassid');
  14. $this->load->_model('Model_shop','shop');
  15. $this->load->_model('Model_country','country');
  16. $this->load->_model('Model_warehouse','warehouse');
  17. $this->load->_model('Model_excel','excel');
  18. $this->load->_model('Model_notice','notice');
  19. $this->load->_model('Model_express','express');
  20. $this->load->_model('Model_api','api');
  21. $this->load->_model('Model_apismt','apismt');
  22. $this->load->_model('Model_usps','usps');
  23. $this->load->_model('Model_typeclass','typeclass');
  24. $this->load->_model('Model_systemwigsout','systemwigsout');
  25. $this->load->_model('Model_setting','setting');
  26. $this->load->_model('Model_customer','customer');
  27. $this->load->_model('Model_customersmt','customersmt');
  28. $this->load->_model('Model_orderurl','orderurl');
  29. $this->load->_model('Model_whlabel','whlabel');
  30. $this->load->_model('Model_whlabel_bh','whlabel_bh');
  31. $this->load->_model('Model_apiyy','apiyy');
  32. $this->load->_model('Model_classid','classid');
  33. $this->load->_model('Model_systemtransfer','systemtransfer');
  34. $this->load->_model('Model_transfer','transfer');
  35. $this->load->_model('Model_classid','classid');
  36. $this->load->_model('Model_whlabel_type','whlabel_type');
  37. $this->load->_model('Model_power','power');
  38. $this->load->_model('Model_productdescribe','productdescribe');
  39. $this->load->_model('Model_shopsku','shopsku');
  40. $this->load->_model('Model_is','is');
  41. $this->load->_model('Model_whlabel_qh','whlabel_qh');
  42. $this->load->_model('Model_emaildata','emaildata');
  43. $this->load->_model('Model_afspaypal','afspaypal');
  44. $this->load->_model('Model_producttitle','producttitle');
  45. $this->load->_model('Model_message','message');
  46. $this->load->_model("Model_logic_ding","logic_ding");
  47. $this->load->_model('Model_excelxh','excelxh');
  48. }
  49. //定义方法的调用规则 获取URI第二段值
  50. public function _remap($arg,$arg_array)
  51. {
  52. if($arg == 'excel')
  53. {
  54. $this->_excel();
  55. }
  56. else if($arg == 'excelhz')
  57. {
  58. $this->_excelhz();
  59. }
  60. else if($arg == 'add')
  61. {
  62. $this->_add();
  63. }
  64. else if($arg == 'edit')
  65. {
  66. $this->_edit($arg_array);
  67. }
  68. else if($arg == 'copy'){
  69. $this->_copy($arg_array);
  70. }
  71. else if($arg == 'del')
  72. {
  73. $this->_del();
  74. }
  75. else if($arg == 'rows')
  76. {
  77. $this->_rows();
  78. }
  79. else if($arg == 'waybill')
  80. {
  81. $this->_waybill($arg_array);
  82. }
  83. else if($arg == 'order')
  84. {
  85. $this->_order($arg_array);
  86. }
  87. else if($arg == 'xxpl')//线下批量导入
  88. {
  89. $this->_xxpl();
  90. }
  91. else if($arg == 'skuzh')//sku转中文
  92. {
  93. $this->_skuzh();
  94. }
  95. else if($arg == 'cs')
  96. {
  97. $this->_cs();
  98. }
  99. else if($arg == 'scwd')
  100. {
  101. $this->_scwd();
  102. }
  103. else if($arg == 'jmexcel')
  104. {
  105. $this->_jmexcel();
  106. }
  107. else if($arg == 'classid')
  108. {
  109. $this->_classid();
  110. }
  111. else if($arg == 'classidadd')
  112. {
  113. $this->_classidadd();
  114. }
  115. else if($arg == 'classidedit')
  116. {
  117. $this->_classidedit($arg_array);
  118. }
  119. else
  120. {
  121. $this->_index();
  122. }
  123. }
  124. //管理
  125. public function _index()
  126. {
  127. $post = $this->input->post(NULL, TRUE);
  128. if(isset($post['page']))
  129. {
  130. $page = $this->input->post('page',true);
  131. $perpage = $this->input->post('perpage',true);
  132. $type = $this->input->post('type',true);
  133. $where = "1=1 ";
  134. //数据排序
  135. $order_str = "id asc";
  136. if(empty($page))
  137. {
  138. $start = 0;
  139. $perpage = 1;
  140. }
  141. else
  142. {
  143. $start = ($page - 1)*$perpage;
  144. }
  145. if($type)
  146. {
  147. $where .= " and type = '$type'";
  148. }
  149. //取得信息列表
  150. $info_list = $this->fullorderexcel->find_all($where,'id,type,title',$order_str,$start,$perpage);
  151. foreach ($info_list as $k=>$v)
  152. {
  153. $classid = $this->fullorderexcelclassid->read($v['type']);
  154. $info_list[$k]['type'] = $classid['title'];
  155. $info_list[$k]['action'] = "<h9 class='window' data-h='/fullorderexcel/copy/".$v['id']."' style='color:#000'><span>复制表格</span></h9>";
  156. }
  157. $total = $this->fullorderexcel->find_count($where);
  158. $pagenum = ceil($total/$perpage);
  159. $over = $total-($start+$perpage);
  160. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  161. echo json_encode($rows);exit;
  162. }
  163. $classid = $this->fullorderexcelclassid->find_all();
  164. $this->data['classid'] = $classid;
  165. $this->_Template('fullorderexcel',$this->data);
  166. }
  167. //添加
  168. public function _add()
  169. {
  170. $post = $this->input->post(NULL, TRUE);
  171. if(isset($post['title']))
  172. {
  173. $post['title'] = $this->input->post('title',true);
  174. $post['type'] = $this->input->post('type',true);
  175. $post['content'] = $this->input->post('content',true);
  176. $post['contentzh'] = $this->input->post('contentzh',true);
  177. $addid = $this->fullorderexcel->insert($post);
  178. if($addid)
  179. {
  180. $adminid = $this->power->read(1);
  181. $this->power->save(array("excelid"=>$adminid['excelid'].$addid.'|',"exceltext"=>$adminid['exceltext'].$post['title'].'|'),$adminid['id']);
  182. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  183. }
  184. else
  185. {
  186. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  187. }
  188. }
  189. $classid = $this->fullorderexcelclassid->find_all();
  190. $this->data['classid'] = $classid;
  191. $this->_Template('fullorderexcel_add',$this->data);
  192. }
  193. //修改
  194. public function _edit($arg_array)
  195. {
  196. $post = $this->input->post(NULL, TRUE);
  197. if(isset($post['id']))
  198. {
  199. $id = $this->input->post('id',true);
  200. $post['title'] = $this->input->post('title',true);
  201. $post['type'] = $this->input->post('type',true);
  202. $post['content'] = $this->input->post('content',true);
  203. $post['contentzh'] = $this->input->post('contentzh',true);
  204. if($this->fullorderexcel->save($post,$id))
  205. {
  206. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  207. }
  208. else
  209. {
  210. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  211. }
  212. }
  213. $arg_array = $arg_array[0];
  214. $fullorderexcel = $this->fullorderexcel->read($arg_array);
  215. $this->data['fullorderexcel'] = $fullorderexcel;
  216. $classid = $this->fullorderexcelclassid->find_all();
  217. $this->data['classid'] = $classid;
  218. $this->_Template('fullorderexcel_edit',$this->data);
  219. }
  220. public function _copy($arg_array)
  221. {
  222. $post = $this->input->post(NULL, TRUE);
  223. if(isset($post['id']))
  224. {
  225. $post['title'] = $this->input->post('title',true);
  226. $post['type'] = $this->input->post('type',true);
  227. $post['content'] = $this->input->post('content',true);
  228. $post['contentzh'] = $this->input->post('contentzh',true);
  229. unset($post['id']);
  230. $addid =$this->fullorderexcel->insert($post);
  231. if($addid)
  232. {
  233. $adminid = $this->power->read(1);
  234. $this->power->save(array("excelid"=>$adminid['excelid'].$addid.'|',"exceltext"=>$adminid['exceltext'].$post['title'].'|'),$adminid['id']);
  235. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  236. }
  237. else
  238. {
  239. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  240. }
  241. }
  242. $arg_array = $arg_array[0];
  243. $fullorderexcel = $this->fullorderexcel->read($arg_array);
  244. $this->data['fullorderexcel'] = $fullorderexcel;
  245. $classid = $this->fullorderexcelclassid->find_all();
  246. $this->data['classid'] = $classid;
  247. $this->_Template('fullorderexcel_copy',$this->data);
  248. }
  249. //删除
  250. public function _del()
  251. {
  252. $post = $this->input->post(NULL, TRUE);
  253. if(isset($post['s']))
  254. {
  255. $id_arr = $this->input->post('s');
  256. $id_arr = explode(',',$id_arr);
  257. if(!$id_arr)
  258. {
  259. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  260. }
  261. //循环删除记录
  262. foreach ($id_arr as $v)
  263. {
  264. $this->fullorderexcel->remove($v);
  265. }
  266. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  267. }
  268. }
  269. //获取数据
  270. public function _rows()
  271. {
  272. $post = $this->input->post(NULL, TRUE);
  273. if(isset($post['id']))
  274. {
  275. $id = $this->input->post('id',true);
  276. $fullorderexcel = $this->fullorderexcel->read($id);
  277. $content = explode('|',rtrim($fullorderexcel['content'],'|'));
  278. $contentzh = explode('|',rtrim($fullorderexcel['contentzh'],'|'));
  279. $data = array();
  280. for($i=0;$i<count($content);$i++)
  281. {
  282. $a = explode('-',$content[$i]);
  283. $b = explode('-',$contentzh[$i]);
  284. $data[] = array(0=>$a[1],1=>$b[1]);
  285. }
  286. echo json_encode(array('rows'=>($data),'success'=>true));
  287. }
  288. }
  289. //导出订单excel
  290. public function _excel()
  291. {
  292. $fgshop = "";$sid = "";$excelshop="";
  293. if(isset($_SESSION['api']))
  294. {
  295. $user = $this->user->get_api($_SESSION['api']);
  296. $usp = $user;
  297. $usersp = explode('|',trim($user['shop'],'|'));
  298. foreach ($usersp as $value)
  299. {
  300. $fgshop .= " shop = ".$value." or";
  301. $sid .= " id = ".$value." or";
  302. }
  303. $userexcel = explode('|',trim($user['excelshop'],'|'));
  304. if($user['excelshop'] == '')
  305. {
  306. echo "没有下载权限";exit;
  307. }
  308. foreach ($userexcel as $value)
  309. {
  310. $excelshop .= " shop = ".$value." or";
  311. }
  312. if($excelshop != "")
  313. {
  314. $excelshop = "(".rtrim($excelshop,'or').")";
  315. }
  316. }
  317. if(isset($_GET['fexcel']))
  318. {
  319. $typeclass = array();
  320. $tclass = $this->typeclass->find_all();
  321. foreach ($tclass as $v)
  322. {
  323. $typeclass[$v['id']] = $v;
  324. }
  325. $dowid = $this->input->get('a');
  326. $wid = "";
  327. if($dowid != "")
  328. {
  329. $id_arr = explode(',',rtrim($dowid,','));
  330. $wid .= " id = 0 or";
  331. foreach ($id_arr as $v)
  332. {
  333. $wid .= " id = '$v' or";
  334. }
  335. $wid = " and".rtrim($wid,'or');
  336. }
  337. $fexcel = $this->input->get('fexcel',true);
  338. $page = $this->input->get('page',true);
  339. $perpage = $this->input->get('perpage',true);
  340. $warehouse = $this->input->get('warehouse',true);
  341. $timetk = $this->input->get('timetk',true);
  342. $timetj = $this->input->get('timetj',true);
  343. $shop = $this->input->get('shop',true);
  344. $source = $this->input->get('source',true);
  345. $state = $this->input->get('state',true);
  346. $review = $this->input->get('review',true);
  347. $type = $this->input->get('type',true);
  348. $express = $this->input->get('express',true);
  349. $orderinfo = $this->input->get('orderinfo',true);
  350. $user = $this->input->get('user',true);
  351. $client = $this->input->get('name',true);
  352. $waybill = $this->input->get('waybill',true);
  353. $number = $this->input->get('number',true);
  354. $email = $this->input->get('email',true);
  355. $dlz = $this->input->get('dlz',true);
  356. $library = $this->input->get('library',true);
  357. $libraryconfirm = $this->input->get('libraryconfirm',true);
  358. $print = $this->input->get('print',true);
  359. $timetkk = $this->input->get('timetkk',true);
  360. $timetjj = $this->input->get('timetjj',true);
  361. $xztime = $this->input->get('xztime',true);
  362. $country = $this->input->get('country',true);
  363. $zf = $this->input->get('zf',true);
  364. $pay = $this->input->get('pay',true);
  365. $phone = $this->input->get('phone',true);
  366. $so = $this->input->get('so',true);
  367. $sfxh = $this->input->get('sfxh',true);
  368. $xdcs = $this->input->get('xdcs',true);
  369. $xdcs = $this->input->get('xdcs',true);
  370. $dbapi = $this->input->get('dbapi',true);
  371. $dbapinocc = $this->input->get('dbapinocc',true);
  372. $orderurl = $this->input->get('orderurl',true);
  373. $timetk = strtotime($timetk);
  374. $timetj = strtotime($timetj);
  375. $timetkk = strtotime($timetkk);
  376. $timetjj = strtotime($timetjj);
  377. $productid = $this->input->get('productid',true);
  378. $px = $this->input->get('px',true);
  379. $fexcel = $this->fullorderexcel->read($fexcel);
  380. $classid = $this->fullorderexcelclassid->read($fexcel['type']);
  381. $where = "1 = 1 and (".rtrim($fgshop,'or').")";
  382. if($warehouse)
  383. {
  384. $where .= " and type = '$warehouse'";
  385. }
  386. if($xztime)
  387. {
  388. if($timetk && $timetj)
  389. {
  390. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  391. }
  392. if($timetkk && $timetjj)
  393. {
  394. $where .= " and ".$xztime." > '$timetkk' and ".$xztime." < '$timetjj'";
  395. }
  396. }
  397. else
  398. {
  399. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  400. }
  401. if($productid){
  402. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  403. }
  404. if($library)
  405. {
  406. $where .= " and library = '$library'";
  407. }
  408. if($print)
  409. {
  410. $where .= " and print = '$print'";
  411. }
  412. if($shop)
  413. {
  414. $where .= " and shop = '$shop'";
  415. }
  416. if($source)
  417. {
  418. if($source == '2d')
  419. {
  420. $where .= " and source >= '2'";
  421. }
  422. else
  423. {
  424. $where .= " and source = '$source'";
  425. }
  426. }
  427. if($state)
  428. {
  429. $where .= " and state = '$state'";
  430. }
  431. if($review)
  432. {
  433. $where .= " and review = '$review'";
  434. }
  435. if($type)
  436. {
  437. $where .= " and type = '$type'";
  438. }
  439. if($express)
  440. {
  441. $where .= " and express = '$express'";
  442. }
  443. if($orderinfo)
  444. {
  445. $where .= " and orderinfo = '$orderinfo'";
  446. }
  447. if($user)
  448. {
  449. $where .= " and user = '$user'";
  450. }
  451. if($client)
  452. {
  453. $where .= " and client like '%$client%'";
  454. }
  455. if($waybill)
  456. {
  457. $where .= " and waybill = '$waybill'";
  458. }
  459. if($number)
  460. {
  461. $where .= " and number = '$number'";
  462. }
  463. if($email)
  464. {
  465. $where .= " and email = '$email'";
  466. }
  467. if($country)
  468. {
  469. $where .= " and country = '$country'";
  470. }
  471. if($dlz)
  472. {
  473. $where .= " and waybill != '' and dlz = 0";
  474. }
  475. if($libraryconfirm)
  476. {
  477. $where .= " and libraryconfirm = '$libraryconfirm'";
  478. }
  479. if($so)
  480. {
  481. $where .= " and shipremarks like '%$so%'";
  482. }
  483. if($pay)
  484. {
  485. $where .= " and pay = '$pay'";
  486. }
  487. if($phone)
  488. {
  489. $where .= " and phone = '$phone'";
  490. }
  491. if($sfxh != '')
  492. {
  493. $where .= " and sfxh = '$sfxh'";
  494. }
  495. if($orderurl)
  496. {
  497. $url = $this->orderurl->read($orderurl);
  498. $where .= " and link like '%".$url['url']."%'";
  499. }
  500. if($zf)
  501. {
  502. if($zf == 1)
  503. {
  504. $where .= " and paypal not like '%-%-%-%'";
  505. }
  506. else
  507. {
  508. $where .= " and paypal like '%-%-%-%'";
  509. }
  510. }
  511. $sj = $this->input->get('sj',true);
  512. if($sj)
  513. {
  514. $sj = $this->input->get('sj',true);
  515. }
  516. else
  517. {
  518. $sj = $classid['type'];
  519. }
  520. $fexceleq = explode("|",rtrim($fexcel['content'],'|'));
  521. foreach ($fexceleq as $k=>$v)
  522. {
  523. $fexceleq[$k] = explode('-',$v);
  524. $num[$k] = $fexceleq[$k][0];
  525. }
  526. //array_multisort($num,SORT_ASC,$fexceleq);//重新排序
  527. $feq = "";$kong = array();$sku9610 = ''; $goods_sku_list = [];
  528. foreach ($fexceleq as $k=>$v)
  529. {
  530. if(isset($v[1]))
  531. {
  532. if($v[1] == 'klarnabill' || $v[1] == 'klarnaship' || $v[1] == 'PPname' || $v[1] == 'PPaddress' || $v[1] == 'PPemail' || $v[1] == 'afterpayship' || $v[1] == 'afterpaybill')
  533. {
  534. $feq .= 'klarnadata,';
  535. }
  536. if($v[1] == 'ccfpdata' || $v[1] == 'cpfpdata' || $v[1] == 'dbapi' || $v[1] == 'scapi')
  537. {
  538. $feq .= 'fpdata,';
  539. }
  540. if(in_array($v[1],['gradefpdata','colorfpdata','densityfpdata','hairnumberfpdata','lacetypefpdata','lowefpdata'])){
  541. $goods_sku_list[] = $v[1];
  542. continue;
  543. }
  544. if($v[1] != 'kong')//空值去除
  545. {
  546. if($v[1] == '9610sku' || $v[1] == 'issku' || $v[1] == 'sku')
  547. {
  548. if($v[1] == '9610sku')
  549. {
  550. $sku9610 = 1;
  551. }
  552. if($sj == 'fullordersmt')
  553. {
  554. $v[1] = 'sku';
  555. }
  556. else
  557. {
  558. $v[1] = 'issku';
  559. }
  560. }
  561. $feq .= $v[1].',';
  562. }
  563. else
  564. {
  565. $kong[$v[0]] = 1;
  566. }
  567. }
  568. }
  569. //处理额外加上的subtotal和rowtoal 但是不想在表中加太多字段 想着以后有关金额的都给怼到extra_price字段中
  570. if((strpos($feq,'subtotal')!= false)||(strpos($feq,'rowtotal')!= false) ||(strpos($feq,'product_id')!= false)){
  571. if(strpos($feq,'subtotal')!= false){
  572. $feq = str_replace('subtotal,',"extra_price as subtotal,",$feq);
  573. }
  574. if(strpos($feq,'rowtotal')!= false){
  575. $feq = str_replace('rowtotal,',"extra_price as rowtotal,",$feq);
  576. }
  577. if(strpos($feq,'product_id')!= false){
  578. $feq = str_replace('product_id,',"extra_price as product_id,",$feq);
  579. }
  580. }
  581. //添加订单前缀
  582. $shopqz_list = [];
  583. if(strpos($feq,'shopqz') !== false){
  584. $feq = str_replace('shopqz,',"shop as shopqz,",$feq);
  585. $shop_list = $this->shop->find_all("1 = 1","id,shortname");
  586. $shopqz_list = array_column($shop_list,'shortname','id');
  587. }
  588. $tt_cate_one = [];
  589. $tt_cate_two = [];
  590. if($sj == 'fullordertt'){
  591. if(strpos($feq,'ttcateone')!== false){
  592. $feq = str_replace('ttcateone,',"cate_one as ttcateone,",$feq);
  593. $tt_cate_one = $this->fullordertt->getCateOne();
  594. $tt_cate_two = $this->fullordertt->getCateTwo();
  595. }
  596. if(strpos($feq,'ttcatetwo')!== false){
  597. $feq = str_replace('ttcatetwo,',"cate_two as ttcatetwo,",$feq);
  598. }
  599. }
  600. //$dbapi_nocc
  601. if(strpos($feq,'dbapinocc')!= false){
  602. $feq = str_replace('dbapinocc,',"fpdata as dbapinocc,",$feq);
  603. }
  604. //商品的规格展示 如果前面没有fpdata 需要加上
  605. if(count($goods_sku_list) > 0){
  606. if(strpos($feq,'fpdata,') === false){
  607. $feq = "fpdata,".$feq;
  608. }
  609. }
  610. $typeclass_lpdl = [];
  611. //料品大类
  612. if(strpos($feq,'lpdl')!= false){
  613. $feq = str_replace('lpdl,',"fpdata as lpdl,",$feq);
  614. $tmp_typeclass_lpdl = $this->db->from('typeclass')->select("id,title,zh,classid")->where('classid',16)->get()->result_array();
  615. $typeclass_lpdl = array_column($tmp_typeclass_lpdl,'zh','id');
  616. }
  617. $typeclass_lhdycc = [];
  618. //料号对应尺寸
  619. if(strpos($feq,'lhdycc')!= false){
  620. $feq = str_replace('lhdycc,',"fpdata as lhdycc,",$feq);
  621. $tmp_typeclass_lhdycc = $this->db->from('typeclass')->select("id,title,zh,classid")->where('classid',14)->get()->result_array();
  622. $typeclass_lhdycc = array_column($tmp_typeclass_lhdycc,'zh','id');
  623. }
  624. $feq = rtrim($feq,',');
  625. $fexcelzhw = explode('|',rtrim($fexcel['contentzh'],'|'));
  626. foreach ($fexcelzhw as $k=>$v)
  627. {
  628. $fexcelzhw[$k] = explode('-',$v);
  629. $numb[$k] = $fexcelzhw[$k][0];
  630. }
  631. //array_multisort($numb,SORT_ASC,$fexcelzhw);//重新排序
  632. $fexcelzh = array();
  633. foreach ($fexcelzhw as $k=>$v)
  634. {
  635. $fexcelzh[] = $v[1];
  636. }
  637. if($px)
  638. {
  639. $order_str = $px." desc";
  640. }
  641. else
  642. {
  643. $order_str = "id desc";
  644. }
  645. // if($_GET['fexcel'] == '157'){
  646. // $this->logic_ding->sendToDing("excel导出的【".$where.$wid.' and '.$excelshop);
  647. // $this->logic_ding->sendToDing("excel导出的【".'id,'.$feq);
  648. // $this->logic_ding->sendToDing("excel导出的【".$order_str);
  649. // $this->logic_ding->sendToDing("excel导出的SJ【".$sj);
  650. // }
  651. //取得信息列表
  652. $info_list = $this->$sj->find_all($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str);
  653. //格式化数据
  654. $i = 1;$shouldmoney = 0;$hl=1;
  655. foreach ($info_list as $key=>$value)
  656. {
  657. $data = $this->$sj->read($value['id']);
  658. $data = str_replace(array("'"),array("’"),$data);
  659. if(isset($value['email']) && $usp['excelpass'] == '1')
  660. {
  661. $emailpass = $this->setting->get_excelpass($value['email']);
  662. $info_list[$key]['email'] = $emailpass;
  663. }
  664. if(isset($value['phone']) && $usp['excelpass'] == '1')
  665. {
  666. $phonepass = $this->setting->get_excelpass($value['phone']);
  667. $info_list[$key]['phone'] = $phonepass;
  668. }
  669. if(isset($value['currencytitle']))
  670. {
  671. if($value['currencytitle'] != "CNY")
  672. {
  673. $hl=$value['hl'];
  674. }
  675. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  676. $budget=$budget+($value['budget']*$hl);
  677. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  678. $refund=$refund+($value['refund']*$hl);
  679. }
  680. if(isset($value['shop']))
  681. {
  682. $shop = $this->shop->read($value['shop']);
  683. $info_list[$key]['shop'] = $shop['shopname'];
  684. }
  685. if(isset($value['dtime']))
  686. {
  687. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  688. }
  689. if(isset($value['printtime']))
  690. {
  691. if($value['printtime'] > 0)
  692. {
  693. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  694. }
  695. }
  696. if(isset($value['sku']))
  697. {
  698. if($sku9610 == '1')
  699. {
  700. $aesku = explode(';',$value['sku']);
  701. $aesku = $aesku[0];
  702. $aesku = explode(':',$aesku);
  703. if(count($aesku) > 1)
  704. {
  705. $aesku = $aesku[1];
  706. $aesku = str_replace('--','~',$aesku);
  707. $aesku = explode('-',$aesku);
  708. $aesku = $aesku[0];
  709. $aesku = str_replace('~','--',$aesku);
  710. $info_list[$key]['sku'] = $aesku;
  711. }
  712. else
  713. {
  714. $info_list[$key]['sku'] = '';
  715. }
  716. }
  717. else
  718. {
  719. $info_list[$key]['sku'] = $value['sku'];
  720. }
  721. }
  722. if(isset($value['issku']))
  723. {
  724. $value['issku'] = str_replace(array('&lt;','&gt;'),array('<','>'),$value['issku']);
  725. if($sku9610 == '1')
  726. {
  727. $aesku = explode(';',$value['issku']);
  728. $aesku = $aesku[0];
  729. $aesku = str_replace('--','~',$aesku);
  730. $aesku = explode('-',$aesku);
  731. $aesku = $aesku[0];
  732. $aesku = str_replace('~','--',$aesku);
  733. $aesku = str_replace(array('<','>'),array('&lt;','&gt;'),$aesku);
  734. $info_list[$key]['issku'] = $aesku;
  735. }
  736. else
  737. {
  738. $value['issku'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['issku']);
  739. $info_list[$key]['issku'] = $value['issku'];
  740. }
  741. }
  742. if(isset($value['subtotal'])){
  743. $tmp_sub_str = "";
  744. $subtotal_list = json_decode($value['subtotal'],true);
  745. foreach($subtotal_list as $v){
  746. if(isset($v['sub_total'])){
  747. $tmp_sub_str .= sprintf( "%.2f",$v['sub_total'])."<br>";
  748. }else{
  749. $tmp_sub_str .= "0<br>";
  750. }
  751. }
  752. $info_list[$key]['subtotal'] = $tmp_sub_str;
  753. }
  754. if(isset($value['rowtotal'])){
  755. $tmp_sub_str = "";
  756. $subtotal_list = json_decode($value['rowtotal'],true);
  757. foreach($subtotal_list as $v){
  758. if(isset($v['row_total'])){
  759. $tmp_sub_str .= sprintf( "%.2f",$v['row_total'])."<br>";
  760. }else{
  761. $tmp_sub_str .= "0<br>";
  762. }
  763. }
  764. $info_list[$key]['rowtotal'] = $tmp_sub_str;
  765. }
  766. if(isset($value['shopqz'])){
  767. $info_list[$key]['shopqz'] = isset($shopqz_list[$value['shopqz']])?$shopqz_list[$value['shopqz']]:'';
  768. }
  769. if(isset($value['dbapinocc'])){
  770. $jmlist_nocc = '';
  771. $classid = $this->classid->sku();
  772. $dbapi = explode(';',trim($value['dbapinocc'],';'));
  773. foreach ($dbapi as $va)
  774. {
  775. $jm_nocc = $classid;
  776. unset($jm_nocc[14]);
  777. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  778. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  779. $ts = explode('|',trim($features,'|'));
  780. if(stripos($ts[0],',') !== false)
  781. {
  782. $ft = explode(',',$ts[0]);
  783. $features = explode('-',trim($ft[1],'-'));
  784. $features[] = $ft[0];
  785. }
  786. else
  787. {
  788. $features = explode('-',trim($ts[0],'-'));
  789. }
  790. foreach($features as $k=>$v)
  791. {
  792. if($v != 0 && isset($typeclass[$v]))
  793. {
  794. if(isset($jm_nocc[$typeclass[$v]['classid']]))
  795. {
  796. if($typeclass[$v]['jm'])
  797. {
  798. $jm_nocc[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  799. }
  800. }
  801. }
  802. }
  803. $jm_nocc = array_filter($jm_nocc);//去除空值
  804. $jm_nocc = implode("-",$jm_nocc);
  805. $jmlist_nocc .= $jm_nocc.'<br>';
  806. }
  807. $info_list[$key]['dbapinocc'] = $jmlist_nocc ;
  808. }
  809. if(isset($value['lpdl'])){
  810. $tmp_lpdl_str ="";
  811. $tmp_fpdata_arr = explode(';',trim($value['fpdata'],';'));
  812. $tmp_fpdata_arr = array_filter($tmp_fpdata_arr);
  813. foreach($tmp_fpdata_arr as $v){
  814. if(empty($v)){
  815. continue;
  816. }
  817. $tmp_arr = explode('-',$v);
  818. if(isset($typeclass_lpdl[$tmp_arr[1]])){
  819. $tmp_lpdl_str .= $typeclass_lpdl[$tmp_arr[1]]."<br>";
  820. }else{
  821. $tmp_lpdl_str .= " ";
  822. }
  823. }
  824. $info_list[$key]['lpdl'] = trim($tmp_lpdl_str,"<br>") ;
  825. }
  826. if(isset($value['lhdycc'])){
  827. $tmp_lhdycc_str ="";
  828. $tmp_fpdata_arr = explode(';',trim($value['fpdata'],';'));
  829. $tmp_fpdata_arr = array_filter($tmp_fpdata_arr);
  830. foreach($tmp_fpdata_arr as $v){
  831. if(empty($v)){
  832. continue;
  833. }
  834. if(stripos($v,',') !== false){
  835. $tmp_arr = explode(',',$v);
  836. if(isset($typeclass_lhdycc[$tmp_arr[0]])){
  837. $tmp_lhdycc_str .= $typeclass_lhdycc[$tmp_arr[0]]."<br>";
  838. }else{
  839. $tmp_lhdycc_str .= "异常 <br>";
  840. }
  841. }else{
  842. $tmp_lhdycc_str .= "无 <br>";
  843. }
  844. }
  845. $info_list[$key]['lhdycc'] = trim($tmp_lhdycc_str,"<br>") ;
  846. }
  847. if(isset($value['product_id'])){
  848. $tmp_product_id = "";
  849. $product_ids = json_decode($value['product_id'],true);
  850. foreach($product_ids as $v){
  851. if(isset($v['product_id'])){
  852. $tmp_product_id .= $v['product_id']."<br>";
  853. }else{
  854. $tmp_product_id .= "<br>";
  855. }
  856. }
  857. $info_list[$key]['product_id'] = $tmp_product_id;
  858. }
  859. if(isset($value['librarytime']))
  860. {
  861. if($value['librarytime'] > 0)
  862. {
  863. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  864. }
  865. }
  866. if(isset($value['buytime']))
  867. {
  868. if($value['buytime'] > 0)
  869. {
  870. $info_list[$key]['buytime'] = date('Y-m-d H:i:s',$value['buytime']);
  871. }
  872. }
  873. if(isset($value['country']))
  874. {
  875. $country = $this->country->read($value['country']);
  876. $info_list[$key]['country'] = $country['name'];
  877. }
  878. if(isset($value['street']))//暂时用街道导出州二字码
  879. {
  880. if($data['country'] == 192)//如果是美国
  881. {
  882. $ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI');
  883. $data['province'] = preg_replace('/( | |\s)/',' ',$data['province']);
  884. $data['province'] = trim($data['province'],' ');
  885. if(isset($ToState[strtolower($data['province'])]))
  886. {
  887. $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
  888. }
  889. else
  890. {
  891. $dataprovince = '';
  892. }
  893. $info_list[$key]['street'] = $dataprovince;
  894. }
  895. else
  896. {
  897. $info_list[$key]['street'] = '';
  898. }
  899. }
  900. if(isset($value['pay']))
  901. {
  902. $pay = $this->typeclass->read($value['pay']);
  903. $info_list[$key]['pay'] = $pay['title'];
  904. }
  905. if(isset($value['type']))
  906. {
  907. $type = $this->warehouse->read($value['type']);
  908. $info_list[$key]['type'] = $type['title'];
  909. }
  910. if(isset($value['express']))
  911. {
  912. $express = $this->express->read($value['express']);
  913. if($express)
  914. {
  915. $info_list[$key]['express'] = $express['servicename'];
  916. }
  917. else
  918. {
  919. $info_list[$key]['express'] = '未选择';
  920. }
  921. }
  922. if(isset($value['ccfpdata']))
  923. {
  924. $ccfpdata = explode(';',$value['fpdata']);
  925. $inc = 0;
  926. foreach ($ccfpdata as $v)
  927. {
  928. if(stripos($v,',') !== false)
  929. {
  930. $cc = explode(',',$v);
  931. $inctype = $this->typeclass->read($cc[0]);
  932. if(is_numeric($inctype['spare']))
  933. {
  934. if($inctype['spare'] > $inc)
  935. {
  936. $inc = $inctype['spare'];
  937. }
  938. }
  939. }
  940. }
  941. $info_list[$key]['ccfpdata'] = $inc.'inch';
  942. }
  943. if(isset($value['printtype']))
  944. {
  945. if($value['printtype'] == 1)
  946. {
  947. $info_list[$key]['printtype'] = '运单';
  948. }
  949. else if($value['printtype'] == 2)
  950. {
  951. $info_list[$key]['printtype'] = '发货单';
  952. }
  953. else if($value['printtype'] == 3)
  954. {
  955. $info_list[$key]['printtype'] = '不打印单据';
  956. }
  957. else
  958. {
  959. $info_list[$key]['printtype'] = '未选择';
  960. }
  961. }
  962. if(isset($value['exstate']))
  963. {
  964. if($value['exstate'] == '99')
  965. {
  966. $info_list[$key]['exstate'] = '未获取到物流信息';
  967. }
  968. else if($value['exstate'] == '1')
  969. {
  970. $info_list[$key]['exstate'] = '已揽收';
  971. }
  972. else if($value['exstate'] == '2')
  973. {
  974. $info_list[$key]['exstate'] = '在途中';
  975. }
  976. else if($value['exstate'] == '3')
  977. {
  978. $info_list[$key]['exstate'] = '派送中';
  979. }
  980. else if($value['exstate'] == '4')
  981. {
  982. $info_list[$key]['exstate'] = '已签收';
  983. }
  984. else if($value['exstate'] == '5')
  985. {
  986. $info_list[$key]['exstate'] = '派送异常';
  987. }
  988. else
  989. {
  990. $info_list[$key]['exstate'] = '';
  991. }
  992. }
  993. if(isset($value['link']))
  994. {
  995. if($value['link'] != '')
  996. {
  997. $link = explode(',',$value['link']);
  998. $info_list[$key]['link'] = $link[0];
  999. }
  1000. else
  1001. {
  1002. $info_list[$key]['link'] = '';
  1003. }
  1004. }
  1005. if(isset($value['klarnabill']))
  1006. {
  1007. $klarnadata = explode('|',$value['klarnadata']);
  1008. if(isset($klarnadata[2]))
  1009. {
  1010. $info_list[$key]['klarnabill'] = $klarnadata[2];
  1011. }
  1012. else
  1013. {
  1014. $info_list[$key]['klarnabill'] = '';
  1015. }
  1016. }
  1017. if(isset($value['klarnaship']))
  1018. {
  1019. $klarnadata = explode('|',$value['klarnadata']);
  1020. if(isset($klarnadata[3]))
  1021. {
  1022. $info_list[$key]['klarnaship'] = $klarnadata[3];
  1023. }
  1024. else
  1025. {
  1026. $info_list[$key]['klarnaship'] = '';
  1027. }
  1028. }
  1029. if(isset($value['afterpaybill']))
  1030. {
  1031. $klarnadata = explode('|',$value['klarnadata']);
  1032. if(isset($klarnadata[1]))
  1033. {
  1034. $info_list[$key]['afterpaybill'] = $klarnadata[1];
  1035. }
  1036. else
  1037. {
  1038. $info_list[$key]['afterpaybill'] = '';
  1039. }
  1040. }
  1041. if(isset($value['afterpayship']))
  1042. {
  1043. $klarnadata = explode('|',$value['klarnadata']);
  1044. if(isset($klarnadata[2]))
  1045. {
  1046. $info_list[$key]['afterpayship'] = $klarnadata[2];
  1047. }
  1048. else
  1049. {
  1050. $info_list[$key]['afterpayship'] = '';
  1051. }
  1052. }
  1053. if(isset($value['PPname']))
  1054. {
  1055. $info_list[$key]['PPname'] = '';
  1056. $klarnadata = explode('|',$value['klarnadata']);
  1057. if(isset($klarnadata[1]))
  1058. {
  1059. $klarnadata = json_decode($klarnadata[1],true);
  1060. if(isset($klarnadata['name']))
  1061. {
  1062. $info_list[$key]['PPname'] = $klarnadata['name'];
  1063. }
  1064. }
  1065. }
  1066. if(isset($value['PPemail']))
  1067. {
  1068. $info_list[$key]['PPemail'] = '';
  1069. $klarnadata = explode('|',$value['klarnadata']);
  1070. if(isset($klarnadata[1]))
  1071. {
  1072. $klarnadata = json_decode($klarnadata[1],true);
  1073. if(isset($klarnadata['email']))
  1074. {
  1075. if($usp['excelpass'] == '1')
  1076. {
  1077. $ppemailpass = $this->setting->get_excelpass($klarnadata['email']);
  1078. }
  1079. else
  1080. {
  1081. $ppemailpass = $klarnadata['email'];
  1082. }
  1083. $info_list[$key]['PPemail'] = $ppemailpass;
  1084. }
  1085. }
  1086. }
  1087. if(isset($value['PPaddress']))
  1088. {
  1089. $info_list[$key]['PPaddress'] = '';
  1090. $klarnadata = explode('|',$value['klarnadata']);
  1091. if(isset($klarnadata[1]))
  1092. {
  1093. $klarnadata = json_decode($klarnadata[1],true);
  1094. if(isset($klarnadata['address']))
  1095. {
  1096. $info_list[$key]['PPaddress'] = $klarnadata['address'];
  1097. }
  1098. }
  1099. }
  1100. if(isset($value['klarnadata']))
  1101. {
  1102. unset($info_list[$key]['klarnadata']);
  1103. }
  1104. if(isset($value['shippingmethod']))
  1105. {
  1106. $tax = explode('Tax:',$value['shippingmethod']);
  1107. $info_list[$key]['shippingmethod'] = (isset($tax[1]))?trim($tax[1],';'):'';
  1108. }
  1109. if(isset($value['systemwigsout']))
  1110. {
  1111. $out = $this->systemtransfer->find_all("number = '".$data['number']."'");
  1112. $outread = '';
  1113. if($out)
  1114. {
  1115. foreach ($out as $val)
  1116. {
  1117. $list = '';
  1118. $rk = explode('|',trim($val['rk'],'|'));
  1119. $rktime = explode('|',trim($val['rktime'],'|'));
  1120. $zw = array();
  1121. $t = $this->transfer->find_all("1=1");
  1122. foreach ($t as $v)
  1123. {
  1124. $zw[$v['id']] = $v['title'];
  1125. }
  1126. if($val['rk'] != '' && count($rk) > 0)
  1127. {
  1128. for($i=0;$i<count($rk);$i++)
  1129. {
  1130. if(!isset($rktime[$i]))
  1131. {
  1132. $list .= $zw[$cz[$i]];
  1133. }
  1134. else
  1135. {
  1136. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  1137. }
  1138. }
  1139. }
  1140. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  1141. }
  1142. }
  1143. else
  1144. {
  1145. $systemwigsout = $this->systemwigsout->find_all("number = '".$data['number']."'");
  1146. if($systemwigsout)
  1147. {
  1148. foreach ($systemwigsout as $v)
  1149. {
  1150. $outread = '';
  1151. if($v['czwarehouse'] == 37)
  1152. {
  1153. $outread .= '华荣厂';
  1154. }
  1155. else if($v['czwarehouse'] == 0)
  1156. {
  1157. $outread .= '龙盈厂';
  1158. }
  1159. $cz = explode('|',trim($v['cz'],'|'));
  1160. $cztime = explode('|',trim($v['cztime'],'|'));
  1161. $zw = $this->transfer->get_list();
  1162. if($v['cz'] != '' && count($cz) > 0)
  1163. {
  1164. for($i=0;$i<count($cz);$i++)
  1165. {
  1166. if(!isset($cztime[$i]))
  1167. {
  1168. $outread .= $zw[$cz[$i]].' -&gt; ';
  1169. }
  1170. else
  1171. {
  1172. $outread .= $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  1173. }
  1174. }
  1175. $outread .= '<br>';
  1176. }
  1177. }
  1178. }
  1179. }
  1180. $info_list[$key]['systemwigsout'] = $outread;
  1181. }
  1182. if(isset($value['sourcetype']))
  1183. {
  1184. if($value['sourcetype'] == '1')
  1185. {
  1186. $info_list[$key]['sourcetype'] = '网红单';
  1187. }
  1188. else if($value['sourcetype'] == '2')
  1189. {
  1190. $info_list[$key]['sourcetype'] = '批发单';
  1191. }
  1192. else if($value['sourcetype'] == '3')
  1193. {
  1194. $info_list[$key]['sourcetype'] = '线下单';
  1195. }
  1196. else if($value['sourcetype'] == '4')
  1197. {
  1198. $info_list[$key]['sourcetype'] = '售后单';
  1199. }
  1200. else if($value['sourcetype'] == '5')
  1201. {
  1202. $info_list[$key]['sourcetype'] = '其它';
  1203. }
  1204. else
  1205. {
  1206. $info_list[$key]['sourcetype'] = '';
  1207. }
  1208. }
  1209. if(isset($value['js']))
  1210. {
  1211. if($value['js'] == '0')
  1212. {
  1213. $info_list[$key]['js'] = 'Ground Advantage';
  1214. }
  1215. else if($value['js'] == '1')
  1216. {
  1217. $info_list[$key]['js'] = 'PRIORITY';
  1218. }
  1219. else if($value['js'] == '2')
  1220. {
  1221. $info_list[$key]['js'] = 'EXPRESS';
  1222. }
  1223. else if($value['js'] == '3')
  1224. {
  1225. $info_list[$key]['js'] = 'IP';
  1226. }
  1227. else if($value['js'] == '4')
  1228. {
  1229. $info_list[$key]['js'] = 'FICP';
  1230. }
  1231. }
  1232. if(isset($value['ttcateone'])){
  1233. $info_list[$key]['ttcateone'] = isset($tt_cate_one[$value['ttcateone']])?$tt_cate_one[$value['ttcateone']]:'';
  1234. }
  1235. if(isset($value['ttcatetwo'])){
  1236. $str = "";
  1237. if(isset($tt_cate_two[$value['ttcateone']])){
  1238. if(isset($tt_cate_two[$value['ttcateone']][$value['ttcatetwo']])){
  1239. $str = $tt_cate_two[$value['ttcateone']][$value['ttcatetwo']];
  1240. }
  1241. }
  1242. $info_list[$key]['ttcatetwo'] = $str;
  1243. }
  1244. if(isset($value['type']))
  1245. {
  1246. $type = $this->warehouse->read($value['type']);
  1247. $info_list[$key]['type'] = $type['title'];
  1248. }
  1249. if(isset($value['xdcs']))
  1250. {
  1251. if($sj == 'fullorder')
  1252. {
  1253. $xdcs = $this->customer->get_email($data['email'],$data['shop']);
  1254. }
  1255. else
  1256. {
  1257. $xdcs = $this->customersmt->get_shopdata($data['shop'],$data['name'],$data['address']);
  1258. }
  1259. $info_list[$key]['xdcs'] = (isset($xdcs['num']))?(($xdcs['num']==0)?1:$xdcs['num']):1;
  1260. }
  1261. if(isset($value['dbapi']) || isset($value['scapi']))
  1262. {
  1263. $jmlist = '';$shuliang = '';
  1264. $classid = $this->classid->sku();
  1265. $dbapi = explode(';',trim($value['fpdata'],';'));
  1266. foreach ($dbapi as $va)
  1267. {
  1268. $pm = $classid;
  1269. $jm = $classid;
  1270. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1271. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1272. $ts = explode('|',trim($features,'|'));
  1273. if(stripos($ts[0],',') !== false)
  1274. {
  1275. $ft = explode(',',$ts[0]);
  1276. $features = explode('-',trim($ft[1],'-'));
  1277. $features[] = $ft[0];
  1278. }
  1279. else
  1280. {
  1281. $features = explode('-',trim($ts[0],'-'));
  1282. }
  1283. foreach($features as $k=>$v)
  1284. {
  1285. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1286. {
  1287. if($typeclass[$v]['bm'] != '')
  1288. {
  1289. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1290. }
  1291. }
  1292. if($v != 0 && isset($typeclass[$v]))
  1293. {
  1294. if($typeclass[$v]['classid'] == 13)
  1295. {
  1296. $dj = $typeclass[$v]['title'];
  1297. }
  1298. if($typeclass[$v]['classid'] == 8)
  1299. {
  1300. $ys = $typeclass[$v]['title'];
  1301. }
  1302. if($typeclass[$v]['classid'] == 15)
  1303. {
  1304. $hx = $typeclass[$v]['title'];
  1305. }
  1306. if(isset($pm[$typeclass[$v]['classid']]))
  1307. {
  1308. if($typeclass[$v]['title'] == '9A')
  1309. {
  1310. $pm[$typeclass[$v]['classid']] = '9A';
  1311. }
  1312. else if($typeclass[$v]['title'] == '10A')
  1313. {
  1314. $pm[$typeclass[$v]['classid']] = '10A';
  1315. }
  1316. else
  1317. {
  1318. $clzh = $typeclass[$v]['zh'];
  1319. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1320. {
  1321. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1322. $clzh = $clzh[0];
  1323. }
  1324. $pm[$typeclass[$v]['classid']] = $clzh;
  1325. }
  1326. }
  1327. if(isset($jm[$typeclass[$v]['classid']]))
  1328. {
  1329. if($typeclass[$v]['jm'])
  1330. {
  1331. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1332. }
  1333. }
  1334. }
  1335. }
  1336. $jm = array_filter($jm);//去除空值
  1337. $jm = implode("-",$jm);
  1338. $jmlist .= $jm.'<br>';
  1339. $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
  1340. $pm = array_filter($pm);//去除空值
  1341. $zh = implode(" ",$pm);
  1342. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1343. }
  1344. if(isset($value['dbapi']))
  1345. {
  1346. $info_list[$key]['dbapi'] = $jmlist;
  1347. }
  1348. else
  1349. {
  1350. $info_list[$key]['scapi'] = $shuliang;
  1351. }
  1352. }
  1353. if(isset($value['dbapi']) && isset($value['scapi']))
  1354. {
  1355. $jmlist = '';$shuliang = '';
  1356. $classid = $this->classid->sku();
  1357. $dbapi = explode(';',trim($value['fpdata'],';'));
  1358. foreach ($dbapi as $va)
  1359. {
  1360. $pm = $classid;
  1361. $jm = $classid;
  1362. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1363. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1364. $ts = explode('|',trim($features,'|'));
  1365. if(stripos($ts[0],',') !== false)
  1366. {
  1367. $ft = explode(',',$ts[0]);
  1368. $features = explode('-',trim($ft[1],'-'));
  1369. $features[] = $ft[0];
  1370. }
  1371. else
  1372. {
  1373. $features = explode('-',trim($ts[0],'-'));
  1374. }
  1375. foreach($features as $k=>$v)
  1376. {
  1377. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1378. {
  1379. if($typeclass[$v]['bm'] != '')
  1380. {
  1381. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1382. }
  1383. }
  1384. if($v != 0 && isset($typeclass[$v]))
  1385. {
  1386. if($typeclass[$v]['classid'] == 13)
  1387. {
  1388. $dj = $typeclass[$v]['title'];
  1389. }
  1390. if($typeclass[$v]['classid'] == 8)
  1391. {
  1392. $ys = $typeclass[$v]['title'];
  1393. }
  1394. if($typeclass[$v]['classid'] == 15)
  1395. {
  1396. $hx = $typeclass[$v]['title'];
  1397. }
  1398. if(isset($pm[$typeclass[$v]['classid']]))
  1399. {
  1400. if($typeclass[$v]['title'] == '9A')
  1401. {
  1402. $pm[$typeclass[$v]['classid']] = '9A';
  1403. }
  1404. else if($typeclass[$v]['title'] == '10A')
  1405. {
  1406. $pm[$typeclass[$v]['classid']] = '10A';
  1407. }
  1408. else
  1409. {
  1410. $clzh = $typeclass[$v]['zh'];
  1411. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1412. {
  1413. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1414. $clzh = $clzh[0];
  1415. }
  1416. $pm[$typeclass[$v]['classid']] = $clzh;
  1417. }
  1418. }
  1419. if(isset($jm[$typeclass[$v]['classid']]))
  1420. {
  1421. if($typeclass[$v]['jm'])
  1422. {
  1423. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1424. }
  1425. }
  1426. }
  1427. }
  1428. $jm = array_filter($jm);//去除空值
  1429. $jm = implode("-",$jm);
  1430. $jmlist .= $jm.'<br>';
  1431. $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
  1432. $pm = array_filter($pm);//去除空值
  1433. $zh = implode(" ",$pm);
  1434. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1435. }
  1436. $info_list[$key]['dbapi'] = $jmlist;
  1437. $info_list[$key]['scapi'] = $shuliang;
  1438. }
  1439. if(isset($value['cpfpdata']))
  1440. {
  1441. $fpread = '';
  1442. $cpfpdata = explode(';',trim($value['fpdata'],';'));
  1443. foreach ($cpfpdata as $v)
  1444. {
  1445. $va = explode('|',trim($v,'|'));
  1446. if(isset($va[1])){
  1447. $fpread .= $va[1].'; ';
  1448. }else{
  1449. $fpread .="合并单没有产品异常标记";
  1450. }
  1451. }
  1452. $info_list[$key]['cpfpdata'] = $fpread;
  1453. }
  1454. if(count($goods_sku_list) > 0){
  1455. $ret_goods_sku = $this->_getGoodsInfo($value,$goods_sku_list,$typeclass);
  1456. if(in_array("gradefpdata",$goods_sku_list)){
  1457. $info_list[$key]['gradefpdata'] = trim($ret_goods_sku['gradefpdata'],"<br>");
  1458. }
  1459. if(in_array("colorfpdata",$goods_sku_list)){
  1460. $info_list[$key]['colorfpdata'] = trim($ret_goods_sku['colorfpdata'],"<br>");
  1461. }
  1462. if(in_array("densityfpdata",$goods_sku_list)){
  1463. $info_list[$key]['densityfpdata'] = trim($ret_goods_sku['densityfpdata'],"<br>");
  1464. }
  1465. if(in_array("hairnumberfpdata",$goods_sku_list)){
  1466. $info_list[$key]['hairnumberfpdata'] = trim($ret_goods_sku['hairnumberfpdata'],"<br>");
  1467. }
  1468. if(in_array("lacetypefpdata",$goods_sku_list)){
  1469. $info_list[$key]['lacetypefpdata'] = trim($ret_goods_sku['lacetypefpdata'],"<br>");
  1470. }
  1471. //lowefpdata
  1472. if(in_array("lowefpdata",$goods_sku_list)){
  1473. $info_list[$key]['lowefpdata'] = trim($ret_goods_sku['lowefpdata'],"<br>");
  1474. }
  1475. }
  1476. unset($info_list[$key]['id']);
  1477. unset($info_list[$key]['fpdata']);
  1478. }
  1479. $fzh = "";
  1480. foreach ($fexcelzh as $v)
  1481. {
  1482. $fzh .= "<td>".$v."</td>";
  1483. }
  1484. $data = array($shouldmoney.' CNY');
  1485. $title = $fexcel['title'].'-'.date('Ymd',time());
  1486. $titlename = "<table border=1>
  1487. <tr>"
  1488. .$fzh.
  1489. "</tr>
  1490. </table>";
  1491. $tail = "\n";
  1492. $filename = $title.".xls";
  1493. $this->excelxh->get_fz5($info_list,$titlename,$filename,$tail,$kong);
  1494. }
  1495. }
  1496. //根据fpdata获取商品sku属性
  1497. private function _getGoodsInfo($value,$goods_sku_list,$typeclass){
  1498. $tmp_goods = explode(';',trim($value['fpdata'],';'));
  1499. $sku_gradefpdata_str = $sku_colorfpdata_str = $sku_densityfpdata_str = $sku_hairnumberfpdata_str = $sku_lacetypefpdata_str = $sku_lowefpdata_str = "";
  1500. foreach($tmp_goods as $tmp_goods_item){
  1501. $dq_goods_item = explode('|',trim($tmp_goods_item,'|'));
  1502. //'gradefpdata','colorfpdata','densityfpdata','hairnumberfpdata','lacetypefpdata'
  1503. $ddq_goods_item = explode('-',trim($dq_goods_item[0],'-'));
  1504. $now_good_sku_info = [];
  1505. foreach($ddq_goods_item as $ll){
  1506. if(!empty($typeclass[$ll])){
  1507. $now_good_sku_info[$typeclass[$ll]['classid']] = empty($typeclass[$ll]['jm'])? " --" : $typeclass[$ll]['jm'];
  1508. }
  1509. }
  1510. if(isset($now_good_sku_info[13])){
  1511. $sku_gradefpdata_str .= $now_good_sku_info[13]."<br/>";
  1512. }else{
  1513. $sku_gradefpdata_str .= " -- <br/>";
  1514. }
  1515. if(isset($now_good_sku_info[8])){
  1516. $sku_colorfpdata_str .= $now_good_sku_info[8]."<br/>";
  1517. }else{
  1518. $sku_colorfpdata_str .= " -- <br/>";
  1519. }
  1520. if(isset($now_good_sku_info[10])){
  1521. $sku_densityfpdata_str .= $now_good_sku_info[10]."<br/>";
  1522. }else{
  1523. $sku_densityfpdata_str .= " -- <br/>";
  1524. }
  1525. if(isset($now_good_sku_info[43])){
  1526. $sku_hairnumberfpdata_str .= $now_good_sku_info[43]."<br/>";
  1527. }else{
  1528. $sku_hairnumberfpdata_str .= " -- <br/>";
  1529. }
  1530. if(isset($now_good_sku_info[18])){
  1531. $sku_lacetypefpdata_str .= $now_good_sku_info[18]."<br/>";
  1532. }else{
  1533. $sku_lacetypefpdata_str .= " -- <br/>";
  1534. }
  1535. if(isset($now_good_sku_info[15])){
  1536. $sku_lowefpdata_str .= $now_good_sku_info[15]."<br/>";
  1537. }else{
  1538. $sku_lowefpdata_str .= " -- <br/>";
  1539. }
  1540. // if($typeclass[$ll]['classid'] == 13){
  1541. // //等级
  1542. // $sku_gradefpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1543. // }elseif($typeclass[$ll]['classid'] == 8){
  1544. // //颜色
  1545. // $sku_colorfpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1546. // }elseif($typeclass[$ll]['classid'] == 10){
  1547. // //密度
  1548. // $sku_densityfpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1549. // }elseif($typeclass[$ll]['classid'] == 43){
  1550. // //人发头套编码
  1551. // $sku_hairnumberfpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1552. // }elseif($typeclass[$ll]['classid'] == 18){
  1553. // //头套种类
  1554. // $sku_lacetypefpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1555. // }
  1556. }
  1557. return [
  1558. 'gradefpdata' => trim($sku_gradefpdata_str,"<br/>"),
  1559. 'colorfpdata' => trim($sku_colorfpdata_str,"<br/>"),
  1560. 'densityfpdata' => trim($sku_densityfpdata_str,"<br/>"),
  1561. 'hairnumberfpdata' => trim($sku_hairnumberfpdata_str,"<br/>"),
  1562. 'lacetypefpdata' => trim($sku_lacetypefpdata_str,"<br/>"),
  1563. 'lowefpdata'=>trim($sku_lowefpdata_str,"<br/>"),
  1564. ];
  1565. }
  1566. //导出订单excel
  1567. public function _excelhz()
  1568. {
  1569. $fgshop = "";$sid = "";$excelshop="";
  1570. if(isset($_SESSION['api']))
  1571. {
  1572. $user = $this->user->get_api($_SESSION['api']);
  1573. $usp = $user;
  1574. $usersp = explode('|',trim($user['shop'],'|'));
  1575. foreach ($usersp as $value)
  1576. {
  1577. $fgshop .= " shop = ".$value." or";
  1578. $sid .= " id = ".$value." or";
  1579. }
  1580. $userexcel = explode('|',trim($user['excelshop'],'|'));
  1581. if($user['excelshop'] == '')
  1582. {
  1583. echo "没有下载权限";exit;
  1584. }
  1585. foreach ($userexcel as $value)
  1586. {
  1587. $excelshop .= " shop = ".$value." or";
  1588. }
  1589. if($excelshop != "")
  1590. {
  1591. $excelshop = "(".rtrim($excelshop,'or').")";
  1592. }
  1593. }
  1594. if(isset($_GET['fexcel']))
  1595. {
  1596. $typeclass = array();
  1597. $tclass = $this->typeclass->find_all();
  1598. foreach ($tclass as $v)
  1599. {
  1600. $typeclass[$v['id']] = $v;
  1601. }
  1602. $dowid = $this->input->get('a');
  1603. $wid = "";
  1604. if($dowid != "")
  1605. {
  1606. $id_arr = explode(',',rtrim($dowid,','));
  1607. $wid .= " id = 0 or";
  1608. foreach ($id_arr as $v)
  1609. {
  1610. $wid .= " id = '$v' or";
  1611. }
  1612. $wid = " and (".rtrim($wid,'or').") ";
  1613. }
  1614. $fexcel = $this->input->get('fexcel',true);
  1615. $page = $this->input->get('page',true);
  1616. $perpage = $this->input->get('perpage',true);
  1617. $warehouse = $this->input->get('warehouse',true);
  1618. $timetk = $this->input->get('timetk',true);
  1619. $timetj = $this->input->get('timetj',true);
  1620. $shop = $this->input->get('shop',true);
  1621. $source = $this->input->get('source',true);
  1622. $state = $this->input->get('state',true);
  1623. $review = $this->input->get('review',true);
  1624. $type = $this->input->get('type',true);
  1625. $express = $this->input->get('express',true);
  1626. $orderinfo = $this->input->get('orderinfo',true);
  1627. $user = $this->input->get('user',true);
  1628. $client = $this->input->get('name',true);
  1629. $waybill = $this->input->get('waybill',true);
  1630. $number = $this->input->get('number',true);
  1631. $email = $this->input->get('email',true);
  1632. $dlz = $this->input->get('dlz',true);
  1633. $library = $this->input->get('library',true);
  1634. $libraryconfirm = $this->input->get('libraryconfirm',true);
  1635. $print = $this->input->get('print',true);
  1636. $timetkk = $this->input->get('timetkk',true);
  1637. $timetjj = $this->input->get('timetjj',true);
  1638. $xztime = $this->input->get('xztime',true);
  1639. $country = $this->input->get('country',true);
  1640. $zf = $this->input->get('zf',true);
  1641. $pay = $this->input->get('pay',true);
  1642. $phone = $this->input->get('phone',true);
  1643. $so = $this->input->get('so',true);
  1644. $sfxh = $this->input->get('sfxh',true);
  1645. $xdcs = $this->input->get('xdcs',true);
  1646. $xdcs = $this->input->get('xdcs',true);
  1647. $dbapi = $this->input->get('dbapi',true);
  1648. $dbapinocc = $this->input->get('dbapinocc',true);
  1649. $orderurl = $this->input->get('orderurl',true);
  1650. $timetk = strtotime($timetk);
  1651. $timetj = strtotime($timetj);
  1652. $timetkk = strtotime($timetkk);
  1653. $timetjj = strtotime($timetjj);
  1654. $px = $this->input->get('px',true);
  1655. $fexcel = $this->fullorderexcel->read($fexcel);
  1656. $classid = $this->fullorderexcelclassid->read($fexcel['type']);
  1657. $where = "1 = 1 and (".rtrim($fgshop,'or').")";
  1658. if($warehouse)
  1659. {
  1660. $where .= " and type = '$warehouse'";
  1661. }
  1662. if($xztime)
  1663. {
  1664. if($timetk && $timetj)
  1665. {
  1666. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  1667. }
  1668. if($timetkk && $timetjj)
  1669. {
  1670. $where .= " and ".$xztime." > '$timetkk' and ".$xztime." < '$timetjj'";
  1671. }
  1672. }
  1673. else
  1674. {
  1675. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  1676. }
  1677. if($library)
  1678. {
  1679. $where .= " and library = '$library'";
  1680. }
  1681. if($print)
  1682. {
  1683. $where .= " and print = '$print'";
  1684. }
  1685. if($shop)
  1686. {
  1687. $where .= " and shop = '$shop'";
  1688. }
  1689. if($source)
  1690. {
  1691. if($source == '2d')
  1692. {
  1693. $where .= " and source >= '2'";
  1694. }
  1695. else
  1696. {
  1697. $where .= " and source = '$source'";
  1698. }
  1699. }
  1700. if($state)
  1701. {
  1702. $where .= " and state = '$state'";
  1703. }
  1704. if($review)
  1705. {
  1706. $where .= " and review = '$review'";
  1707. }
  1708. if($type)
  1709. {
  1710. $where .= " and type = '$type'";
  1711. }
  1712. if($express)
  1713. {
  1714. $where .= " and express = '$express'";
  1715. }
  1716. if($orderinfo)
  1717. {
  1718. $where .= " and orderinfo = '$orderinfo'";
  1719. }
  1720. if($user)
  1721. {
  1722. $where .= " and user = '$user'";
  1723. }
  1724. if($client)
  1725. {
  1726. $where .= " and client like '%$client%'";
  1727. }
  1728. if($waybill)
  1729. {
  1730. $where .= " and waybill = '$waybill'";
  1731. }
  1732. if($number)
  1733. {
  1734. $where .= " and number = '$number'";
  1735. }
  1736. if($email)
  1737. {
  1738. $where .= " and email = '$email'";
  1739. }
  1740. if($country)
  1741. {
  1742. $where .= " and country = '$country'";
  1743. }
  1744. if($dlz)
  1745. {
  1746. $where .= " and waybill != '' and dlz = 0";
  1747. }
  1748. if($libraryconfirm)
  1749. {
  1750. $where .= " and libraryconfirm = '$libraryconfirm'";
  1751. }
  1752. if($so)
  1753. {
  1754. $where .= " and shipremarks like '%$so%'";
  1755. }
  1756. if($pay)
  1757. {
  1758. $where .= " and pay = '$pay'";
  1759. }
  1760. if($phone)
  1761. {
  1762. $where .= " and phone = '$phone'";
  1763. }
  1764. if($sfxh != '')
  1765. {
  1766. $where .= " and sfxh = '$sfxh'";
  1767. }
  1768. if($orderurl)
  1769. {
  1770. $url = $this->orderurl->read($orderurl);
  1771. $where .= " and link like '%".$url['url']."%'";
  1772. }
  1773. if($zf)
  1774. {
  1775. if($zf == 1)
  1776. {
  1777. $where .= " and paypal not like '%-%-%-%'";
  1778. }
  1779. else
  1780. {
  1781. $where .= " and paypal like '%-%-%-%'";
  1782. }
  1783. }
  1784. $sj = $this->input->get('sj',true);
  1785. if($sj)
  1786. {
  1787. $sj = $this->input->get('sj',true);
  1788. }
  1789. else
  1790. {
  1791. $sj = $classid['type'];
  1792. }
  1793. $fexceleq = explode("|",rtrim($fexcel['content'],'|'));
  1794. foreach ($fexceleq as $k=>$v)
  1795. {
  1796. $fexceleq[$k] = explode('-',$v);
  1797. $num[$k] = $fexceleq[$k][0];
  1798. }
  1799. //array_multisort($num,SORT_ASC,$fexceleq);//重新排序
  1800. $feq = "";$kong = array();$sku9610 = '';
  1801. foreach ($fexceleq as $k=>$v)
  1802. {
  1803. if(isset($v[1]))
  1804. {
  1805. if($v[1] == 'klarnabill' || $v[1] == 'klarnaship' || $v[1] == 'PPname' || $v[1] == 'PPaddress' || $v[1] == 'PPemail' || $v[1] == 'afterpayship' || $v[1] == 'afterpaybill')
  1806. {
  1807. $feq .= 'klarnadata,';
  1808. }
  1809. if($v[1] == 'ccfpdata' || $v[1] == 'cpfpdata' || $v[1] == 'dbapi' || $v[1] == 'scapi')
  1810. {
  1811. $feq .= 'fpdata,';
  1812. }
  1813. if($v[1] != 'kong')//空值去除
  1814. {
  1815. if($v[1] == '9610sku' || $v[1] == 'issku' || $v[1] == 'sku')
  1816. {
  1817. if($v[1] == '9610sku')
  1818. {
  1819. $sku9610 = 1;
  1820. }
  1821. if($sj == 'fullordersmt')
  1822. {
  1823. $v[1] = 'sku';
  1824. }
  1825. else
  1826. {
  1827. $v[1] = 'issku';
  1828. }
  1829. }
  1830. $feq .= $v[1].',';
  1831. }
  1832. else
  1833. {
  1834. $kong[$v[0]] = 1;
  1835. }
  1836. }
  1837. }
  1838. //处理额外加上的subtotal和rowtoal 但是不想在表中加太多字段 想着以后有关金额的都给怼到extra_price字段中
  1839. if((strpos($feq,'subtotal')!= false)||(strpos($feq,'rowtotal')!= false) ||(strpos($feq,'product_id')!= false)){
  1840. if(strpos($feq,'subtotal')!= false){
  1841. $feq = str_replace('subtotal,',"extra_price as subtotal,",$feq);
  1842. }
  1843. if(strpos($feq,'rowtotal')!= false){
  1844. $feq = str_replace('rowtotal,',"extra_price as rowtotal,",$feq);
  1845. }
  1846. if(strpos($feq,'product_id')!= false){
  1847. $feq = str_replace('product_id,',"extra_price as product_id,",$feq);
  1848. }
  1849. }
  1850. //添加订单前缀
  1851. $shopqz_list = [];
  1852. if(strpos($feq,'shopqz') !== false){
  1853. $feq = str_replace('shopqz,',"shop as shopqz,",$feq);
  1854. $shop_list = $this->shop->find_all("1 = 1","id,shortname");
  1855. $shopqz_list = array_column($shop_list,'shortname','id');
  1856. }
  1857. //$dbapi_nocc
  1858. if(strpos($feq,'dbapinocc')!= false){
  1859. $feq = str_replace('dbapinocc,',"fpdata as dbapinocc,",$feq);
  1860. }
  1861. $typeclass_lpdl = [];
  1862. //料品大类
  1863. if(strpos($feq,'lpdl')!= false){
  1864. $feq = str_replace('lpdl,',"fpdata as lpdl,",$feq);
  1865. $tmp_typeclass_lpdl = $this->db->from('typeclass')->select("id,title,zh,classid")->where('classid',16)->get()->result_array();
  1866. $typeclass_lpdl = array_column($tmp_typeclass_lpdl,'zh','id');
  1867. }
  1868. $typeclass_lhdycc = [];
  1869. //料号对应尺寸
  1870. if(strpos($feq,'lhdycc')!= false){
  1871. $feq = str_replace('lhdycc,',"fpdata as lhdycc,",$feq);
  1872. $tmp_typeclass_lhdycc = $this->db->from('typeclass')->select("id,title,zh,classid")->where('classid',14)->get()->result_array();
  1873. $typeclass_lhdycc = array_column($tmp_typeclass_lhdycc,'zh','id');
  1874. }
  1875. $feq = rtrim($feq,',');
  1876. $fexcelzhw = explode('|',rtrim($fexcel['contentzh'],'|'));
  1877. foreach ($fexcelzhw as $k=>$v)
  1878. {
  1879. $fexcelzhw[$k] = explode('-',$v);
  1880. $numb[$k] = $fexcelzhw[$k][0];
  1881. }
  1882. //array_multisort($numb,SORT_ASC,$fexcelzhw);//重新排序
  1883. $fexcelzh = array();
  1884. foreach ($fexcelzhw as $k=>$v)
  1885. {
  1886. $fexcelzh[] = $v[1];
  1887. }
  1888. if($px)
  1889. {
  1890. $order_str = $px." desc";
  1891. }
  1892. else
  1893. {
  1894. $order_str = "id desc";
  1895. }
  1896. // if($_GET['fexcel'] == '157'){
  1897. // $this->logic_ding->sendToDing("excel导出的【".$where.$wid.' and '.$excelshop);
  1898. // $this->logic_ding->sendToDing("excel导出的【".'id,'.$feq);
  1899. // $this->logic_ding->sendToDing("excel导出的【".$order_str);
  1900. // $this->logic_ding->sendToDing("excel导出的SJ【".$sj);
  1901. // }
  1902. $extra = [
  1903. 'usp'=>$usp,
  1904. 'sku9610'=>$sku9610,
  1905. 'typeclass_lpdl'=>$typeclass_lpdl,
  1906. 'typeclass_lhdycc'=>$typeclass_lhdycc
  1907. ];
  1908. $dlz_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullorder',$extra);
  1909. $tt_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullordertt',$extra);
  1910. $smt_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullordersmt',$extra);
  1911. $amz_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullorderamz',$extra);
  1912. $info_list = array_merge( $dlz_ret['info_list'],$tt_ret['info_list'],$smt_ret['info_list'],$amz_ret['info_list']);
  1913. $shouldmoney = $dlz_ret['shouldmoney']+$tt_ret['shouldmoney']+$smt_ret['shouldmoney']+$amz_ret['shouldmoney'];
  1914. $fzh = "";
  1915. foreach ($fexcelzh as $v)
  1916. {
  1917. $fzh .= "<td>".$v."</td>";
  1918. }
  1919. $data = array($shouldmoney.' CNY');
  1920. $title = $fexcel['title'].'-'.date('Ymd',time());
  1921. $titlename = "<table border=1>
  1922. <tr>"
  1923. .$fzh.
  1924. "</tr>
  1925. </table>";
  1926. $tail = "\n";
  1927. $filename = $title.".xls";
  1928. $this->excel->get_fz5($info_list,$titlename,$filename,$tail,$kong);
  1929. }
  1930. }
  1931. public function _datahz($where,$field,$order_str,$sj,$extra){
  1932. //取得信息列表
  1933. $info_list = $this->$sj->find_all($where,$field,$order_str);
  1934. //格式化数据
  1935. $i = 1;$shouldmoney = 0;$hl=1;
  1936. $usp = $extra['usp'];
  1937. $sku9610 = $extra['sku9610'];
  1938. $typeclass_lpdl = $extra['typeclass_lpdl'];
  1939. $typeclass_lhdycc = $extra['typeclass_lhdycc'];
  1940. foreach ($info_list as $key=>$value)
  1941. {
  1942. $data = $this->$sj->read($value['id']);
  1943. $data = str_replace(array("'"),array("’"),$data);
  1944. if(isset($value['email']) && $usp['excelpass'] == '1')
  1945. {
  1946. $emailpass = $this->setting->get_excelpass($value['email']);
  1947. $info_list[$key]['email'] = $emailpass;
  1948. }
  1949. if(isset($value['phone']) && $usp['excelpass'] == '1')
  1950. {
  1951. $phonepass = $this->setting->get_excelpass($value['phone']);
  1952. $info_list[$key]['phone'] = $phonepass;
  1953. }
  1954. if(isset($value['currencytitle']))
  1955. {
  1956. if($value['currencytitle'] != "CNY")
  1957. {
  1958. $hl=$value['hl'];
  1959. }
  1960. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  1961. }
  1962. if(isset($value['shop']))
  1963. {
  1964. $shop = $this->shop->read($value['shop']);
  1965. $info_list[$key]['shop'] = $shop['shopname'];
  1966. }
  1967. if(isset($value['dtime']))
  1968. {
  1969. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  1970. }
  1971. if(isset($value['printtime']))
  1972. {
  1973. if($value['printtime'] > 0)
  1974. {
  1975. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1976. }
  1977. }
  1978. if(isset($value['sku']))
  1979. {
  1980. if($sku9610 == '1')
  1981. {
  1982. $aesku = explode(';',$value['sku']);
  1983. $aesku = $aesku[0];
  1984. $aesku = explode(':',$aesku);
  1985. if(count($aesku) > 1)
  1986. {
  1987. $aesku = $aesku[1];
  1988. $aesku = str_replace('--','~',$aesku);
  1989. $aesku = explode('-',$aesku);
  1990. $aesku = $aesku[0];
  1991. $aesku = str_replace('~','--',$aesku);
  1992. $info_list[$key]['sku'] = $aesku;
  1993. }
  1994. else
  1995. {
  1996. $info_list[$key]['sku'] = '';
  1997. }
  1998. }
  1999. else
  2000. {
  2001. $info_list[$key]['sku'] = $value['sku'];
  2002. }
  2003. }
  2004. if(isset($value['issku']))
  2005. {
  2006. $value['issku'] = str_replace(array('&lt;','&gt;'),array('<','>'),$value['issku']);
  2007. if($sku9610 == '1')
  2008. {
  2009. $aesku = explode(';',$value['issku']);
  2010. $aesku = $aesku[0];
  2011. $aesku = str_replace('--','~',$aesku);
  2012. $aesku = explode('-',$aesku);
  2013. $aesku = $aesku[0];
  2014. $aesku = str_replace('~','--',$aesku);
  2015. $aesku = str_replace(array('<','>'),array('&lt;','&gt;'),$aesku);
  2016. $info_list[$key]['issku'] = $aesku;
  2017. }
  2018. else
  2019. {
  2020. $value['issku'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['issku']);
  2021. $info_list[$key]['issku'] = $value['issku'];
  2022. }
  2023. }
  2024. if(isset($value['subtotal'])){
  2025. $tmp_sub_str = "";
  2026. $subtotal_list = json_decode($value['subtotal'],true);
  2027. foreach($subtotal_list as $v){
  2028. if(isset($v['sub_total'])){
  2029. $tmp_sub_str .= sprintf( "%.2f",$v['sub_total'])."<br>";
  2030. }else{
  2031. $tmp_sub_str .= "0<br>";
  2032. }
  2033. }
  2034. $info_list[$key]['subtotal'] = $tmp_sub_str;
  2035. }
  2036. if(isset($value['rowtotal'])){
  2037. $tmp_sub_str = "";
  2038. $subtotal_list = json_decode($value['rowtotal'],true);
  2039. foreach($subtotal_list as $v){
  2040. if(isset($v['row_total'])){
  2041. $tmp_sub_str .= sprintf( "%.2f",$v['row_total'])."<br>";
  2042. }else{
  2043. $tmp_sub_str .= "0<br>";
  2044. }
  2045. }
  2046. $info_list[$key]['rowtotal'] = $tmp_sub_str;
  2047. }
  2048. if(isset($value['dbapinocc'])){
  2049. $jmlist_nocc = '';
  2050. $classid = $this->classid->sku();
  2051. $dbapi = explode(';',trim($value['dbapinocc'],';'));
  2052. foreach ($dbapi as $va)
  2053. {
  2054. $jm_nocc = $classid;
  2055. unset($jm_nocc[14]);
  2056. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  2057. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  2058. $ts = explode('|',trim($features,'|'));
  2059. if(stripos($ts[0],',') !== false)
  2060. {
  2061. $ft = explode(',',$ts[0]);
  2062. $features = explode('-',trim($ft[1],'-'));
  2063. $features[] = $ft[0];
  2064. }
  2065. else
  2066. {
  2067. $features = explode('-',trim($ts[0],'-'));
  2068. }
  2069. foreach($features as $k=>$v)
  2070. {
  2071. if($v != 0 && isset($typeclass[$v]))
  2072. {
  2073. if(isset($jm_nocc[$typeclass[$v]['classid']]))
  2074. {
  2075. if($typeclass[$v]['jm'])
  2076. {
  2077. $jm_nocc[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2078. }
  2079. }
  2080. }
  2081. }
  2082. $jm_nocc = array_filter($jm_nocc);//去除空值
  2083. $jm_nocc = implode("-",$jm_nocc);
  2084. $jmlist_nocc .= $jm_nocc.'<br>';
  2085. }
  2086. $info_list[$key]['dbapinocc'] = $jmlist_nocc ;
  2087. }
  2088. if(isset($value['lpdl'])){
  2089. $tmp_lpdl_str ="";
  2090. $tmp_fpdata_arr = explode(';',trim($value['fpdata'],';'));
  2091. $tmp_fpdata_arr = array_filter($tmp_fpdata_arr);
  2092. foreach($tmp_fpdata_arr as $v){
  2093. if(empty($v)){
  2094. continue;
  2095. }
  2096. $tmp_arr = explode('-',$v);
  2097. if(isset($typeclass_lpdl[$tmp_arr[1]])){
  2098. $tmp_lpdl_str .= $typeclass_lpdl[$tmp_arr[1]]."<br>";
  2099. }else{
  2100. $tmp_lpdl_str .= " ";
  2101. }
  2102. }
  2103. $info_list[$key]['lpdl'] = trim($tmp_lpdl_str,"<br>") ;
  2104. }
  2105. if(isset($value['lhdycc'])){
  2106. $tmp_lhdycc_str ="";
  2107. $tmp_fpdata_arr = explode(';',trim($value['fpdata'],';'));
  2108. $tmp_fpdata_arr = array_filter($tmp_fpdata_arr);
  2109. foreach($tmp_fpdata_arr as $v){
  2110. if(empty($v)){
  2111. continue;
  2112. }
  2113. if(stripos($v,',') !== false){
  2114. $tmp_arr = explode(',',$v);
  2115. if(isset($typeclass_lhdycc[$tmp_arr[0]])){
  2116. $tmp_lhdycc_str .= $typeclass_lhdycc[$tmp_arr[0]]."<br>";
  2117. }else{
  2118. $tmp_lhdycc_str .= "异常 <br>";
  2119. }
  2120. }else{
  2121. $tmp_lhdycc_str .= "无 <br>";
  2122. }
  2123. }
  2124. $info_list[$key]['lhdycc'] = trim($tmp_lhdycc_str,"<br>") ;
  2125. }
  2126. if(isset($value['shopqz'])){
  2127. $info_list[$key]['shopqz'] = isset($shopqz_list[$value['shopqz']])?$shopqz_list[$value['shopqz']]:'';
  2128. }
  2129. if(isset($value['product_id'])){
  2130. $tmp_product_id = "";
  2131. $product_ids = json_decode($value['product_id'],true);
  2132. foreach($product_ids as $v){
  2133. if(isset($v['product_id'])){
  2134. $tmp_product_id .= $v['product_id']."<br>";
  2135. }else{
  2136. $tmp_product_id .= "<br>";
  2137. }
  2138. }
  2139. $info_list[$key]['product_id'] = $tmp_product_id;
  2140. }
  2141. if(isset($value['librarytime']))
  2142. {
  2143. if($value['librarytime'] > 0)
  2144. {
  2145. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  2146. }
  2147. }
  2148. if(isset($value['buytime']))
  2149. {
  2150. if($value['buytime'] > 0)
  2151. {
  2152. $info_list[$key]['buytime'] = date('Y-m-d H:i:s',$value['buytime']);
  2153. }
  2154. }
  2155. if(isset($value['country']))
  2156. {
  2157. $country = $this->country->read($value['country']);
  2158. $info_list[$key]['country'] = $country['name'];
  2159. }
  2160. if(isset($value['street']))//暂时用街道导出州二字码
  2161. {
  2162. if($data['country'] == 192)//如果是美国
  2163. {
  2164. $ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI');
  2165. $data['province'] = preg_replace('/( | |\s)/',' ',$data['province']);
  2166. $data['province'] = trim($data['province'],' ');
  2167. if(isset($ToState[strtolower($data['province'])]))
  2168. {
  2169. $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
  2170. }
  2171. else
  2172. {
  2173. $dataprovince = '';
  2174. }
  2175. $info_list[$key]['street'] = $dataprovince;
  2176. }
  2177. else
  2178. {
  2179. $info_list[$key]['street'] = '';
  2180. }
  2181. }
  2182. if(isset($value['pay']))
  2183. {
  2184. if(empty($value['pay'])){
  2185. $info_list[$key]['pay'] = "";
  2186. }else{
  2187. if($sj =='fullorder'){
  2188. $pay = $this->typeclass->read($value['pay']);
  2189. $info_list[$key]['pay'] = $pay['title'];
  2190. }
  2191. }
  2192. }
  2193. if(isset($value['type']))
  2194. {
  2195. $type = $this->warehouse->read($value['type']);
  2196. $info_list[$key]['type'] = $type['title'];
  2197. }
  2198. if(isset($value['express']))
  2199. {
  2200. $express = $this->express->read($value['express']);
  2201. if($express)
  2202. {
  2203. $info_list[$key]['express'] = $express['servicename'];
  2204. }
  2205. else
  2206. {
  2207. $info_list[$key]['express'] = '未选择';
  2208. }
  2209. }
  2210. if(isset($value['ccfpdata']))
  2211. {
  2212. $ccfpdata = explode(';',$value['fpdata']);
  2213. $inc = 0;
  2214. foreach ($ccfpdata as $v)
  2215. {
  2216. if(stripos($v,',') !== false)
  2217. {
  2218. $cc = explode(',',$v);
  2219. $inctype = $this->typeclass->read($cc[0]);
  2220. if(is_numeric($inctype['spare']))
  2221. {
  2222. if($inctype['spare'] > $inc)
  2223. {
  2224. $inc = $inctype['spare'];
  2225. }
  2226. }
  2227. }
  2228. }
  2229. $info_list[$key]['ccfpdata'] = $inc.'inch';
  2230. }
  2231. if(isset($value['printtype']))
  2232. {
  2233. if($value['printtype'] == 1)
  2234. {
  2235. $info_list[$key]['printtype'] = '运单';
  2236. }
  2237. else if($value['printtype'] == 2)
  2238. {
  2239. $info_list[$key]['printtype'] = '发货单';
  2240. }
  2241. else if($value['printtype'] == 3)
  2242. {
  2243. $info_list[$key]['printtype'] = '不打印单据';
  2244. }
  2245. else
  2246. {
  2247. $info_list[$key]['printtype'] = '未选择';
  2248. }
  2249. }
  2250. if(isset($value['exstate']))
  2251. {
  2252. if($value['exstate'] == '99')
  2253. {
  2254. $info_list[$key]['exstate'] = '未获取到物流信息';
  2255. }
  2256. else if($value['exstate'] == '1')
  2257. {
  2258. $info_list[$key]['exstate'] = '已揽收';
  2259. }
  2260. else if($value['exstate'] == '2')
  2261. {
  2262. $info_list[$key]['exstate'] = '在途中';
  2263. }
  2264. else if($value['exstate'] == '3')
  2265. {
  2266. $info_list[$key]['exstate'] = '派送中';
  2267. }
  2268. else if($value['exstate'] == '4')
  2269. {
  2270. $info_list[$key]['exstate'] = '已签收';
  2271. }
  2272. else if($value['exstate'] == '5')
  2273. {
  2274. $info_list[$key]['exstate'] = '派送异常';
  2275. }
  2276. else
  2277. {
  2278. $info_list[$key]['exstate'] = '';
  2279. }
  2280. }
  2281. if(isset($value['link']))
  2282. {
  2283. if($value['link'] != '')
  2284. {
  2285. $link = explode(',',$value['link']);
  2286. $info_list[$key]['link'] = $link[0];
  2287. }
  2288. else
  2289. {
  2290. $info_list[$key]['link'] = '';
  2291. }
  2292. }
  2293. if(isset($value['klarnabill']))
  2294. {
  2295. $klarnadata = explode('|',$value['klarnadata']);
  2296. if(isset($klarnadata[2]))
  2297. {
  2298. $info_list[$key]['klarnabill'] = $klarnadata[2];
  2299. }
  2300. else
  2301. {
  2302. $info_list[$key]['klarnabill'] = '';
  2303. }
  2304. }
  2305. if(isset($value['klarnaship']))
  2306. {
  2307. $klarnadata = explode('|',$value['klarnadata']);
  2308. if(isset($klarnadata[3]))
  2309. {
  2310. $info_list[$key]['klarnaship'] = $klarnadata[3];
  2311. }
  2312. else
  2313. {
  2314. $info_list[$key]['klarnaship'] = '';
  2315. }
  2316. }
  2317. if(isset($value['afterpaybill']))
  2318. {
  2319. $klarnadata = explode('|',$value['klarnadata']);
  2320. if(isset($klarnadata[1]))
  2321. {
  2322. $info_list[$key]['afterpaybill'] = $klarnadata[1];
  2323. }
  2324. else
  2325. {
  2326. $info_list[$key]['afterpaybill'] = '';
  2327. }
  2328. }
  2329. if(isset($value['afterpayship']))
  2330. {
  2331. $klarnadata = explode('|',$value['klarnadata']);
  2332. if(isset($klarnadata[2]))
  2333. {
  2334. $info_list[$key]['afterpayship'] = $klarnadata[2];
  2335. }
  2336. else
  2337. {
  2338. $info_list[$key]['afterpayship'] = '';
  2339. }
  2340. }
  2341. if(isset($value['PPname']))
  2342. {
  2343. $info_list[$key]['PPname'] = '';
  2344. $klarnadata = explode('|',$value['klarnadata']);
  2345. if(isset($klarnadata[1]))
  2346. {
  2347. $klarnadata = json_decode($klarnadata[1],true);
  2348. if(isset($klarnadata['name']))
  2349. {
  2350. $info_list[$key]['PPname'] = $klarnadata['name'];
  2351. }
  2352. }
  2353. }
  2354. if(isset($value['PPemail']))
  2355. {
  2356. $info_list[$key]['PPemail'] = '';
  2357. $klarnadata = explode('|',$value['klarnadata']);
  2358. if(isset($klarnadata[1]))
  2359. {
  2360. $klarnadata = json_decode($klarnadata[1],true);
  2361. if(isset($klarnadata['email']))
  2362. {
  2363. if($usp['excelpass'] == '1')
  2364. {
  2365. $ppemailpass = $this->setting->get_excelpass($klarnadata['email']);
  2366. }
  2367. else
  2368. {
  2369. $ppemailpass = $klarnadata['email'];
  2370. }
  2371. $info_list[$key]['PPemail'] = $ppemailpass;
  2372. }
  2373. }
  2374. }
  2375. if(isset($value['PPaddress']))
  2376. {
  2377. $info_list[$key]['PPaddress'] = '';
  2378. $klarnadata = explode('|',$value['klarnadata']);
  2379. if(isset($klarnadata[1]))
  2380. {
  2381. $klarnadata = json_decode($klarnadata[1],true);
  2382. if(isset($klarnadata['address']))
  2383. {
  2384. $info_list[$key]['PPaddress'] = $klarnadata['address'];
  2385. }
  2386. }
  2387. }
  2388. if(isset($value['klarnadata']))
  2389. {
  2390. unset($info_list[$key]['klarnadata']);
  2391. }
  2392. if(isset($value['shippingmethod']))
  2393. {
  2394. $tax = explode('Tax:',$value['shippingmethod']);
  2395. $info_list[$key]['shippingmethod'] = (isset($tax[1]))?trim($tax[1],';'):'';
  2396. }
  2397. if(isset($value['systemwigsout']))
  2398. {
  2399. $out = $this->systemtransfer->find_all("number = '".$data['number']."'");
  2400. $outread = '';
  2401. if($out)
  2402. {
  2403. foreach ($out as $val)
  2404. {
  2405. $list = '';
  2406. $rk = explode('|',trim($val['rk'],'|'));
  2407. $rktime = explode('|',trim($val['rktime'],'|'));
  2408. $zw = array();
  2409. $t = $this->transfer->find_all("1=1");
  2410. foreach ($t as $v)
  2411. {
  2412. $zw[$v['id']] = $v['title'];
  2413. }
  2414. if($val['rk'] != '' && count($rk) > 0)
  2415. {
  2416. for($i=0;$i<count($rk);$i++)
  2417. {
  2418. if(!isset($rktime[$i]))
  2419. {
  2420. $list .= $zw[$cz[$i]];
  2421. }
  2422. else
  2423. {
  2424. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  2425. }
  2426. }
  2427. }
  2428. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  2429. }
  2430. }
  2431. else
  2432. {
  2433. $systemwigsout = $this->systemwigsout->find_all("number = '".$data['number']."'");
  2434. if($systemwigsout)
  2435. {
  2436. foreach ($systemwigsout as $v)
  2437. {
  2438. $outread = '';
  2439. if($v['czwarehouse'] == 37)
  2440. {
  2441. $outread .= '华荣厂';
  2442. }
  2443. else if($v['czwarehouse'] == 0)
  2444. {
  2445. $outread .= '龙盈厂';
  2446. }
  2447. $cz = explode('|',trim($v['cz'],'|'));
  2448. $cztime = explode('|',trim($v['cztime'],'|'));
  2449. $zw = $this->transfer->get_list();
  2450. if($v['cz'] != '' && count($cz) > 0)
  2451. {
  2452. for($i=0;$i<count($cz);$i++)
  2453. {
  2454. if(!isset($cztime[$i]))
  2455. {
  2456. $outread .= $zw[$cz[$i]].' -&gt; ';
  2457. }
  2458. else
  2459. {
  2460. $outread .= $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  2461. }
  2462. }
  2463. $outread .= '<br>';
  2464. }
  2465. }
  2466. }
  2467. }
  2468. $info_list[$key]['systemwigsout'] = $outread;
  2469. }
  2470. if(isset($value['sourcetype']))
  2471. {
  2472. if($value['sourcetype'] == '1')
  2473. {
  2474. $info_list[$key]['sourcetype'] = '网红单';
  2475. }
  2476. else if($value['sourcetype'] == '2')
  2477. {
  2478. $info_list[$key]['sourcetype'] = '批发单';
  2479. }
  2480. else if($value['sourcetype'] == '3')
  2481. {
  2482. $info_list[$key]['sourcetype'] = '线下单';
  2483. }
  2484. else if($value['sourcetype'] == '4')
  2485. {
  2486. $info_list[$key]['sourcetype'] = '售后单';
  2487. }
  2488. else if($value['sourcetype'] == '5')
  2489. {
  2490. $info_list[$key]['sourcetype'] = '其它';
  2491. }
  2492. else
  2493. {
  2494. $info_list[$key]['sourcetype'] = '';
  2495. }
  2496. }
  2497. if(isset($value['js']))
  2498. {
  2499. if($value['js'] == '0')
  2500. {
  2501. $info_list[$key]['js'] = 'Ground Advantage';
  2502. }
  2503. else if($value['js'] == '1')
  2504. {
  2505. $info_list[$key]['js'] = 'PRIORITY';
  2506. }
  2507. else if($value['js'] == '2')
  2508. {
  2509. $info_list[$key]['js'] = 'EXPRESS';
  2510. }
  2511. else if($value['js'] == '3')
  2512. {
  2513. $info_list[$key]['js'] = 'IP';
  2514. }
  2515. else if($value['js'] == '4')
  2516. {
  2517. $info_list[$key]['js'] = 'FICP';
  2518. }
  2519. }
  2520. if(isset($value['type']))
  2521. {
  2522. $type = $this->warehouse->read($value['type']);
  2523. $info_list[$key]['type'] = $type['title'];
  2524. }
  2525. if(isset($value['xdcs']))
  2526. {
  2527. if($sj == 'fullorder')
  2528. {
  2529. $xdcs = $this->customer->get_email($data['email'],$data['shop']);
  2530. }
  2531. else
  2532. {
  2533. $xdcs = $this->customersmt->get_shopdata($data['shop'],$data['name'],$data['address']);
  2534. }
  2535. $info_list[$key]['xdcs'] = (isset($xdcs['num']))?(($xdcs['num']==0)?1:$xdcs['num']):1;
  2536. }
  2537. if(isset($value['dbapi']) || isset($value['scapi']))
  2538. {
  2539. $jmlist = '';$shuliang = '';
  2540. $classid = $this->classid->sku();
  2541. $dbapi = explode(';',trim($value['fpdata'],';'));
  2542. foreach ($dbapi as $va)
  2543. {
  2544. $pm = $classid;
  2545. $jm = $classid;
  2546. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  2547. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  2548. $ts = explode('|',trim($features,'|'));
  2549. if(stripos($ts[0],',') !== false)
  2550. {
  2551. $ft = explode(',',$ts[0]);
  2552. $features = explode('-',trim($ft[1],'-'));
  2553. $features[] = $ft[0];
  2554. }
  2555. else
  2556. {
  2557. $features = explode('-',trim($ts[0],'-'));
  2558. }
  2559. foreach($features as $k=>$v)
  2560. {
  2561. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  2562. {
  2563. if($typeclass[$v]['bm'] != '')
  2564. {
  2565. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  2566. }
  2567. }
  2568. if($v != 0 && isset($typeclass[$v]))
  2569. {
  2570. if($typeclass[$v]['classid'] == 13)
  2571. {
  2572. $dj = $typeclass[$v]['title'];
  2573. }
  2574. if($typeclass[$v]['classid'] == 8)
  2575. {
  2576. $ys = $typeclass[$v]['title'];
  2577. }
  2578. if($typeclass[$v]['classid'] == 15)
  2579. {
  2580. $hx = $typeclass[$v]['title'];
  2581. }
  2582. if(isset($pm[$typeclass[$v]['classid']]))
  2583. {
  2584. if($typeclass[$v]['title'] == '9A')
  2585. {
  2586. $pm[$typeclass[$v]['classid']] = '9A';
  2587. }
  2588. else if($typeclass[$v]['title'] == '10A')
  2589. {
  2590. $pm[$typeclass[$v]['classid']] = '10A';
  2591. }
  2592. else
  2593. {
  2594. $clzh = $typeclass[$v]['zh'];
  2595. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2596. {
  2597. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2598. $clzh = $clzh[0];
  2599. }
  2600. $pm[$typeclass[$v]['classid']] = $clzh;
  2601. }
  2602. }
  2603. if(isset($jm[$typeclass[$v]['classid']]))
  2604. {
  2605. if($typeclass[$v]['jm'])
  2606. {
  2607. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2608. }
  2609. }
  2610. }
  2611. }
  2612. $jm = array_filter($jm);//去除空值
  2613. $jm = implode("-",$jm);
  2614. $jmlist .= $jm.'<br>';
  2615. $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
  2616. $pm = array_filter($pm);//去除空值
  2617. $zh = implode(" ",$pm);
  2618. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2619. }
  2620. if(isset($value['dbapi']))
  2621. {
  2622. $info_list[$key]['dbapi'] = $jmlist;
  2623. }
  2624. else
  2625. {
  2626. $info_list[$key]['scapi'] = $shuliang;
  2627. }
  2628. }
  2629. if(isset($value['dbapi']) && isset($value['scapi']))
  2630. {
  2631. $jmlist = '';$shuliang = '';
  2632. $classid = $this->classid->sku();
  2633. $dbapi = explode(';',trim($value['fpdata'],';'));
  2634. foreach ($dbapi as $va)
  2635. {
  2636. $pm = $classid;
  2637. $jm = $classid;
  2638. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  2639. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  2640. $ts = explode('|',trim($features,'|'));
  2641. if(stripos($ts[0],',') !== false)
  2642. {
  2643. $ft = explode(',',$ts[0]);
  2644. $features = explode('-',trim($ft[1],'-'));
  2645. $features[] = $ft[0];
  2646. }
  2647. else
  2648. {
  2649. $features = explode('-',trim($ts[0],'-'));
  2650. }
  2651. foreach($features as $k=>$v)
  2652. {
  2653. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  2654. {
  2655. if($typeclass[$v]['bm'] != '')
  2656. {
  2657. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  2658. }
  2659. }
  2660. if($v != 0 && isset($typeclass[$v]))
  2661. {
  2662. if($typeclass[$v]['classid'] == 13)
  2663. {
  2664. $dj = $typeclass[$v]['title'];
  2665. }
  2666. if($typeclass[$v]['classid'] == 8)
  2667. {
  2668. $ys = $typeclass[$v]['title'];
  2669. }
  2670. if($typeclass[$v]['classid'] == 15)
  2671. {
  2672. $hx = $typeclass[$v]['title'];
  2673. }
  2674. if(isset($pm[$typeclass[$v]['classid']]))
  2675. {
  2676. if($typeclass[$v]['title'] == '9A')
  2677. {
  2678. $pm[$typeclass[$v]['classid']] = '9A';
  2679. }
  2680. else if($typeclass[$v]['title'] == '10A')
  2681. {
  2682. $pm[$typeclass[$v]['classid']] = '10A';
  2683. }
  2684. else
  2685. {
  2686. $clzh = $typeclass[$v]['zh'];
  2687. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2688. {
  2689. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2690. $clzh = $clzh[0];
  2691. }
  2692. $pm[$typeclass[$v]['classid']] = $clzh;
  2693. }
  2694. }
  2695. if(isset($jm[$typeclass[$v]['classid']]))
  2696. {
  2697. if($typeclass[$v]['jm'])
  2698. {
  2699. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2700. }
  2701. }
  2702. }
  2703. }
  2704. $jm = array_filter($jm);//去除空值
  2705. $jm = implode("-",$jm);
  2706. $jmlist .= $jm.'<br>';
  2707. $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
  2708. $pm = array_filter($pm);//去除空值
  2709. $zh = implode(" ",$pm);
  2710. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2711. }
  2712. $info_list[$key]['dbapi'] = $jmlist;
  2713. $info_list[$key]['scapi'] = $shuliang;
  2714. }
  2715. if(isset($value['cpfpdata']))
  2716. {
  2717. $fpread = '';
  2718. $cpfpdata = explode(';',trim($value['fpdata'],';'));
  2719. foreach ($cpfpdata as $v)
  2720. {
  2721. $va = explode('|',trim($v,'|'));
  2722. if(isset($va[1])){
  2723. $fpread .= $va[1].'; ';
  2724. }else{
  2725. $fpread .="合并单没有产品异常标记";
  2726. }
  2727. }
  2728. $info_list[$key]['cpfpdata'] = $fpread;
  2729. }
  2730. unset($info_list[$key]['id']);
  2731. unset($info_list[$key]['fpdata']);
  2732. }
  2733. return [
  2734. 'info_list'=>$info_list,
  2735. 'shouldmoney'=>$shouldmoney
  2736. ];
  2737. }
  2738. //上传运单
  2739. public function _waybill($arg_array)
  2740. {
  2741. $readid = $arg_array[0];
  2742. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  2743. /* 订单加入键值-k */
  2744. $fdata = $this->fullorder->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and dlz < 1 and state = 207');
  2745. foreach ($fdata as $v)
  2746. {
  2747. $dataorder[$v['orderinfo']] = $v;
  2748. }
  2749. $sdata = $this->fullordersmt->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and state = 207 and (dlz < 1 or dlz = 3)');
  2750. foreach ($sdata as $v)
  2751. {
  2752. $dataorder[$v['orderinfo']] = $v;
  2753. }
  2754. $tdata = $this->fullordertt->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and state = 207 and (dlz < 1 or dlz = 3)');
  2755. foreach ($tdata as $v)
  2756. {
  2757. $dataorder[$v['orderinfo']] = $v;
  2758. }
  2759. $xdata = $this->fullorderxw->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and state = 207 and (dlz < 1 or dlz = 3)');
  2760. foreach ($xdata as $v)
  2761. {
  2762. $dataorder[$v['orderinfo']] = $v;
  2763. }
  2764. /* 订单加入键值-j */
  2765. /* 店铺加入键值-j */
  2766. $fshop = $this->shop->find_all('1=1');
  2767. foreach ($fshop as $v)
  2768. {
  2769. $datashop[$v['id']] = $v;
  2770. }
  2771. /* 店铺加入键值-k */
  2772. /* 快递加入键值-j */
  2773. $fex = $this->express->find_all('1=1');
  2774. foreach ($fex as $v)
  2775. {
  2776. $dataex[$v['id']] = $v;
  2777. }
  2778. /* 快递加入键值-k */
  2779. /* 仓库加入键值-k */
  2780. $fwh = $this->warehouse->find_all('1=1');
  2781. foreach ($fwh as $v)
  2782. {
  2783. $datack[$v['id']] = $v;
  2784. }
  2785. /* 仓库加入键值-j */
  2786. $fs = $this->notice->get_ordertatus(216);//216成功状态
  2787. if(is_numeric($readid) == false || $readid < 1)
  2788. {
  2789. echo json_encode(array('msg'=>'店铺信息错误!','success'=>true));exit;
  2790. }
  2791. $dir = '/data/excel/'.date('Ymd',time()).'/';
  2792. $config['upload_path'] = '.'.$dir ;
  2793. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  2794. $config['allowed_types'] = 'xls|xlsx|csv';
  2795. $config['max_size'] = 10240;
  2796. $this->load->library('upload', $config);
  2797. $this->upload->initialize($config);
  2798. if ($this->upload->do_upload('userfile'))
  2799. {
  2800. $full_path = $dir.$this->upload->data('file_name');
  2801. $fileName = '.' . $full_path;
  2802. if (!file_exists($fileName))
  2803. {
  2804. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  2805. }
  2806. else
  2807. {
  2808. require_once "./data/excel/PHPExcel/IOFactory.php";
  2809. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  2810. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  2811. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  2812. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  2813. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  2814. ++$column;//如果列数大于26行
  2815. $list = array();
  2816. for ($i = 2; $i <= $row; $i++) // 行数循环
  2817. {
  2818. $data = array();
  2819. for ($c = 'A'; $c != $column; $c++) // 列数循环
  2820. {
  2821. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  2822. }
  2823. $list[] = $data;
  2824. }
  2825. }
  2826. $i = 0;$j = 0;$ed = array();$cscs = array();
  2827. $this->db->trans_begin();
  2828. foreach ($list as $key=>$value)
  2829. {
  2830. $ddh = preg_replace('/\D/s','',$value['0']);
  2831. $ydh = preg_replace('/\W/s','',$value['1']);
  2832. $shop = $datashop[$readid];
  2833. if($shop['type'] == '269')
  2834. {
  2835. $orid = $readid.$ddh;
  2836. }
  2837. else
  2838. {
  2839. $orid = $ddh;
  2840. }
  2841. if(isset($dataorder[$orid]))
  2842. {
  2843. if($shop['type'] == 269)//独立站前缀需要添加ID
  2844. {
  2845. $time = time();
  2846. $xg = $dataorder[$orid];
  2847. $oldw = $xg['waybill'];
  2848. $ex = $dataex[$xg['express']];
  2849. $warehouse = $datack[$xg['type']];
  2850. $msg = $ydh;
  2851. $xg['waybill'] = $ydh;
  2852. $fs = $this->notice->find_all("shop = '".$xg['shop']."' and message = '1' and state = '1' and type = '4' and ktime < '$time' and jtime > '$time'");
  2853. if(isset($fs[0]))
  2854. {
  2855. $fs = $fs[0];
  2856. $fs['email'] = $this->emaildata->read($fs['email']);
  2857. if(($xg['dlzemail'] == 1 && $msg != $oldw) || $xg['dlzemail'] == 0)
  2858. {
  2859. $ck = $this->notice->get_god($xg,$shop,$ex,$fs);
  2860. if($ck == 1)
  2861. {
  2862. $ckemail = '邮件发送成功,';
  2863. $this->fullorder->save(array('dlzemail'=>1,'dlzemailtime'=>time()),$xg['id']);
  2864. }
  2865. }
  2866. }
  2867. if($msg != $oldw)
  2868. {
  2869. if($xg['source'] != 1)
  2870. {
  2871. $ms = $this->message->find_all("express like '%,".$xg['express'].",%'");
  2872. if(!isset($ms[0]))
  2873. {
  2874. $ms = $this->message->read(2);
  2875. }
  2876. else
  2877. {
  2878. $ms = $ms[0];
  2879. }
  2880. $ddh = substr($xg['orderinfo'],1);
  2881. $shopifyid = $xg['shopify'];
  2882. //独立站地址更新订单状态、物流信息
  2883. $shopname = $shop['brandname']; //店铺名
  2884. $buyername = $xg['bname']; //Bill Name
  2885. $email_call = $shop['shopid']; //发货人邮箱;
  2886. $phone = $shop['shopphone']; //发货人电话
  2887. $track_type = $ex['title']; //快递名称
  2888. $service = $ex['title']; //快递追踪名称
  2889. $track_link = $ex['url']; //快递查询网址
  2890. $logistics_number = $ydh; //运单号
  2891. $t= array('%buyername%','%email_call%','%track_type%','%service%','%track_link%','%logistics_number%','%shop%','%phone%','%jtime%');
  2892. $h= array($buyername,$email_call,$track_type,$service,$track_link,$logistics_number,$shopname,$phone,$ex['yjtime']);
  2893. $remark = str_replace($t,$h,$ms['content']);
  2894. @$gx = $this->api->get_gx($ddh,$ydh,$xg,$shop,$ex,$remark,$shopifyid);
  2895. }
  2896. else if($xg['source'] == 1)
  2897. {
  2898. $gx['res'] = 3;
  2899. $gx['state'] = 216;
  2900. }
  2901. }
  2902. else
  2903. {
  2904. $gx['res'] = $xg['dlz'];
  2905. $gx['state'] = $xg['state'];
  2906. }
  2907. $xg['iscode'] = $ex['title'];
  2908. $xg['url'] = $shop['shopname'];
  2909. @$chuanshu = $this->api->get_paypal($xg);
  2910. //$this->afspaypal->insert(array('number'=>$xg['number'],'cs'=>$chuanshu));
  2911. $this->fullorder->save(array('waybill'=>$msg,'state'=>$gx['state'],'dlz'=>$gx['res']),$xg['id']);
  2912. /**
  2913. $xg = $dataorder[$arg_array[0].$ddh];
  2914. $ex = $dataex[$xg['express']];
  2915. $warehouse = $datack[$xg['type']];
  2916. if($xg['source'] != 1 && $ex['iscode'] != 'Other' && $xg['state'] == '207')
  2917. {
  2918. //独立站地址更新订单状态、物流信息
  2919. $gx = $this->api->get_gx($ddh,$ydh,$xg,$shop,$ex,$xg['msg'],$xg['msg'],$dataorder[$orid]['shopify']);
  2920. if(!isset($gx['res']))
  2921. {
  2922. $ed[] = array($ddh.'-更新失败');
  2923. $j++;
  2924. continue;
  2925. }
  2926. $this->fullorder->save(array('waybill'=>$ydh,'dlz'=>$gx['res'],'state'=>$gx['state']),$xg['id']);
  2927. if($gx['res'] == 1 && $fs)
  2928. {
  2929. $ck = $this->_email($fs['content'],$xg,$warehouse['company']);
  2930. }
  2931. }
  2932. else if($xg['source'] == 1 && $xg['state'] == '207')
  2933. {
  2934. $this->fullorder->save(array('waybill'=>$ydh,'dlz'=>3,'state'=>216),$xg['id']);
  2935. if($fs)
  2936. {
  2937. $ck = $this->_email($fs['content'],$xg,$warehouse['company']);
  2938. }
  2939. }
  2940. else
  2941. {
  2942. $ed[] = array($ddh.'-状态错误');
  2943. $j++;
  2944. continue;
  2945. }
  2946. **/
  2947. }
  2948. else if($shop['type'] == 270)//速卖通对接发货声明
  2949. {
  2950. $xg = $dataorder[$ddh];
  2951. $ex = $dataex[$xg['express']];
  2952. $warehouse = $datack[$xg['type']];
  2953. if($xg['source'] != 1 && $ex['aecode'] != 'Other' && $xg['library'] == 2 && ($xg['dlz'] == '0' || $xg['dlz'] == '2'))
  2954. {
  2955. $result = $this->apismt->get_out($ydh,'all',$xg['orderinfo'],$ex['aecode'],$sp['code']);
  2956. if(isset($result['result_success']) && $result['result_success'] == "true")
  2957. {
  2958. $this->fullordersmt->save(array('waybill'=>$ydh,'state'=>209,'dlz'=>1),$xg['id']);
  2959. /** 合并信息处理开始-发货声明 **/
  2960. if($xg['merge'] != '0')
  2961. {
  2962. $hdata = $this->fullordersmt->find_all("merge = '".$xg['merge']."' and id != '".$xg['id']."' and dlz = '0' and source != 1");$l=0;
  2963. foreach ($hdata as $v)
  2964. {
  2965. $result = $this->apismt->get_out($ydh,'all',$v['orderinfo'],$ex['aecode'],$sp['code']);
  2966. if(isset($result['result_success']) && $result['result_success'] == "true")
  2967. {
  2968. $this->fullordersmt->save(array('waybill'=>$ydh,'state'=>209,'dlz'=>1),$v['id']);
  2969. }
  2970. else
  2971. {
  2972. $ed[] = array($v['orderinfo'].'-合并单发货声明失败,请在ERP上手动操作此单');
  2973. $j++;
  2974. continue;
  2975. }
  2976. $l++;
  2977. if($l > 10)
  2978. {
  2979. break;
  2980. }
  2981. }
  2982. }
  2983. /** 合并信息处理结束开始 **/
  2984. }
  2985. else
  2986. {
  2987. $ed[] = array($ddh.'-发货声明失败');
  2988. $j++;
  2989. continue;
  2990. }
  2991. }
  2992. else if($xg['source'] != 1 && $ex['aecode'] != 'Other' && $xg['dlz'] == '1' && $xg['library'] == 2)//修改声明
  2993. {
  2994. $obtain = $this->apismt->get_obtain($xg['orderinfo'],$sp['code']);//修改声明先查询之前物流信息
  2995. if(isset($obtain['logistics_no']))
  2996. {
  2997. $result = $this->apismt->get_editout($obtain['logistics_no'],$ydh,'all',$xg['orderinfo'],$obtain['service_name'],$ex['aecode'],$sp['code']);
  2998. }
  2999. if(isset($result['result_success']) && $result['result_success'] == "true")
  3000. {
  3001. $this->fullordersmt->save(array('waybill'=>$ydh),$xg['id']);
  3002. /** 合并信息处理开始-修改声明 **/
  3003. if($xg['merge'] != '0')
  3004. {
  3005. $hdata = $this->fullordersmt->find_all("merge = '".$xg['merge']."' and id != '".$xg['id']."' and dlz != 1 and source != 1");$l=0;
  3006. foreach ($hdata as $v)
  3007. {
  3008. $obtain = $this->apismt->get_obtain($v['orderinfo'],$sp['code']);//修改声明先查询之前物流信息
  3009. if(isset($obtain['logistics_no']))
  3010. {
  3011. $result = $this->apismt->get_editout($obtain['logistics_no'],$ydh,'all',$v['orderinfo'],$obtain['service_name'],$ex['aecode'],$sp['code']);
  3012. }
  3013. if(isset($result['result_success']) && $result['result_success'] == "true")
  3014. {
  3015. $this->fullordersmt->save(array('waybill'=>$ydh),$v['id']);
  3016. }
  3017. else
  3018. {
  3019. $ed[] = array($v['orderinfo'].'-合并单修改发货声明失败,请在ERP上手动操作此单');
  3020. $j++;
  3021. continue;
  3022. }
  3023. $l++;
  3024. if($l > 10)
  3025. {
  3026. break;
  3027. }
  3028. }
  3029. }
  3030. /** 合并信息处理结束开始 **/
  3031. }
  3032. else
  3033. {
  3034. $ed[] = array($ddh.'-修改发货声明失败');
  3035. $j++;
  3036. continue;
  3037. }
  3038. }
  3039. else if($xg['source'] == 1 && $xg['state'] == '207')
  3040. {
  3041. $this->fullordersmt->save(array('waybill'=>$ydh,'dlz'=>3,'state'=>216),$xg['id']);
  3042. }
  3043. else
  3044. {
  3045. $this->fullordersmt->save(array('waybill'=>$ydh),$xg['id']);
  3046. }
  3047. }
  3048. }
  3049. else
  3050. {
  3051. $ed[] = array($ddh.'-单号错误或重复操作');
  3052. $i++;
  3053. continue;
  3054. }
  3055. sleep(1);//停留1秒
  3056. }
  3057. if ($this->db->trans_status() === FALSE)
  3058. {
  3059. $this->db->trans_rollback();
  3060. }
  3061. else
  3062. {
  3063. $this->db->trans_commit();
  3064. }
  3065. if($i+$j > 0)
  3066. {
  3067. $time = date('Ymd',time());
  3068. $title = '错误信息-'.$time;
  3069. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3070. $tail = "\n";
  3071. $filename = $title.".xls";
  3072. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3073. $dir = '/data/excel/'.$time.'/';
  3074. $file_name = 'error_'.$time.rand(1000,9999);
  3075. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3076. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3077. fwrite($myfile,$ecl);
  3078. fclose($myfile);
  3079. $error = $dir.$file_name.'.xls';
  3080. echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
  3081. }
  3082. else
  3083. {
  3084. echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
  3085. }
  3086. }
  3087. else
  3088. {
  3089. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3090. }
  3091. }
  3092. //上传速卖通订单
  3093. public function _order($arg_array)
  3094. {
  3095. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  3096. /* 订单加入键值-k */
  3097. $fdata = $this->fullorder_smt->find_all('dtime >'.(time()-5*24*3600));
  3098. foreach ($fdata as $v)
  3099. {
  3100. $dataorder[$v['orderinfo']] = $v;
  3101. }
  3102. /* 订单加入键值-j */
  3103. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3104. $config['upload_path'] = '.'.$dir ;
  3105. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3106. $config['allowed_types'] = 'xls|xlsx|csv';
  3107. $config['max_size'] = 10240;
  3108. $this->load->library('upload', $config);
  3109. $this->upload->initialize($config);
  3110. if ($this->upload->do_upload('userfile'))
  3111. {
  3112. $full_path = $dir.$this->upload->data('file_name');
  3113. $fileName = '.' . $full_path;
  3114. if (!file_exists($fileName))
  3115. {
  3116. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3117. }
  3118. else
  3119. {
  3120. require_once "./data/excel/PHPExcel/IOFactory.php";
  3121. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3122. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3123. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3124. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3125. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3126. ++$column;//如果列数大于26行
  3127. $list = array();
  3128. for ($i = 2; $i <= $row; $i++) // 行数循环
  3129. {
  3130. $data = array();
  3131. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3132. {
  3133. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3134. }
  3135. $list[] = $data;
  3136. }
  3137. }
  3138. $i = 0;$j = 0;$ed = array();$tytime = time();
  3139. foreach ($list as $key=>$value)
  3140. {
  3141. $value['2'] = preg_replace('/\D/s','',$value['2']);
  3142. if($value['2'] && !isset($dataorder[$value['2']]))
  3143. {
  3144. $num = $this->fullorder_smt->find_count('gtime = "'.date('Ymd',time()).'"');
  3145. $post['source'] = 2;//订单类型:1.线下订单2.PC3.手机
  3146. $post['state'] = 207;//订单状态:207等待发货
  3147. $post['review'] = 6;//审核状态:1.未送审2.待审核3.不通过4取消重审5.审核通过6.自动通过
  3148. $post['reviewtime'] = $tytime;//审核时间
  3149. $post['print'] = 2;//打印状态:1.不可打印2.未打印3.已打印
  3150. $post['library'] = 1;//出库状态:1.未出库2.已出库3.已退库
  3151. $post['libraryconfirm'] = 1;//出库确认:1.不允许2.允许
  3152. if($post['print'] != 3)
  3153. {
  3154. $post['librarynot'] = "订单未打印,未审核或未通过";//不能出库原因
  3155. }
  3156. $value['1'] = trim($value['1'],' ');
  3157. $shortname = explode('-',$value['1']);
  3158. $shortname = $this->shop->get_shortname($shortname[0]);
  3159. if(!$shortname)
  3160. {
  3161. $ed[] = array($value['1'].'-编码有问题');
  3162. $i++;
  3163. continue;
  3164. }
  3165. $post['shop'] = $shortname['id']?$shortname['id']:0;//速卖通
  3166. $post['user'] = '无';
  3167. $post['number'] = $value['1'];//编号
  3168. $post['orderinfo'] = $value['2'];//订单号
  3169. $post['client'] = preg_replace('/( | | |\s)/',' ',$value['3']);//客户名称
  3170. $post['buytime'] = $tytime;//时间转UX
  3171. $post['dtime'] = $tytime;//订单时间
  3172. $post['gtime'] = date('Ymd',$tytime);//格式化时间
  3173. //$post['pay'] = $this->input->post('pay',true);//支付方式
  3174. $post['capital'] = 3;//资金状态
  3175. $post['type'] = 5;//发货仓库
  3176. $post['currency'] = 219;//币种
  3177. $post['currencytitle'] = 'USD';//币种名称
  3178. $post['freight'] = 0;//运费
  3179. $post['expressmoney'] = 0;//物流金额
  3180. $post['shouldmoney'] = 0;//应收金额
  3181. $post['budget'] = 0;//应到金额*店铺到帐金额比
  3182. $orderremarks = '';//订单备注
  3183. $post['shipremarks'] = $value['12'];//仓库品名
  3184. $post['email'] = '';//邮箱
  3185. $post['name'] = preg_replace('/( | | |\s)/',' ',$value['3']);//名字
  3186. $post['phone'] = $value['10'];//电话
  3187. $post['country'] = 192;//国家
  3188. $ct = $this->country->get_ename($value['9']);//国家
  3189. $post['al'] = $ct['lb'];//国家二字码
  3190. $post['province'] = $value['8'];//省、州
  3191. $post['city'] = $value['6'];//城市
  3192. $post['zipcode'] = $value['7'];//邮编
  3193. $post['address'] = $value['4'];//地址1
  3194. $post['address2'] = $value['5']?$value['5']:'';//地址2
  3195. $post['express'] = 2;//快递
  3196. $post['printtype'] = 1;//打印类型
  3197. $post['fpdata'] = '';//购买产品内容
  3198. $post['sbpm'] = 'Hair Sample';//申报品名
  3199. $post['zwpm'] = '假发';//中文品名
  3200. $post['ts'] = $value['17'];//条数
  3201. $post['dtsbjz'] = 15;//单条申报价
  3202. $post['zsbjz'] = 15;//总申报价
  3203. $post['zzl'] = 0.5;//总重量
  3204. $post['zjs'] = 1;//总件数
  3205. $post['quantity'] = 1;//数量
  3206. $post['paypal'] = '';//支付号
  3207. $post['guarantee'] = '';//卖家保障
  3208. $post['zzl'] = $value['13'];//总重量
  3209. $post['bx'] = $value['14'];//总重量
  3210. $post['qm'] = $value['15'];//总重量
  3211. $post['js'] = $value['16'];//总重量
  3212. $barcode = $this->usps->get_address(array('address'=>$value['4'],'address2'=>$value['5'],'city'=>$value['6'],'province'=>$value['8'],'zipcode'=>$value['7']));
  3213. if(isset($barcode['Address']['Error']['Description']))
  3214. {
  3215. $ed[] = array($value['1'].'-'.$barcode['Address']['Error']['Description']);
  3216. $i++;
  3217. }
  3218. else
  3219. {
  3220. $this->fullorder_smt->insert($post);
  3221. }
  3222. }
  3223. else
  3224. {
  3225. $ed[] = array($value['1'].'-单号错误或重复操作');
  3226. $i++;
  3227. }
  3228. sleep(2);//停留2秒
  3229. }
  3230. if($i+$j > 0)
  3231. {
  3232. $time = date('Ymd',time());
  3233. $title = '错误信息-'.$time;
  3234. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3235. $tail = "\n";
  3236. $filename = $title.".xls";
  3237. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3238. $dir = '/data/excel/'.$time.'/';
  3239. $file_name = 'error_'.$time.rand(1000,9999);
  3240. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3241. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3242. fwrite($myfile,$ecl);
  3243. fclose($myfile);
  3244. $error = $dir.$file_name.'.xls';
  3245. echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
  3246. }
  3247. else
  3248. {
  3249. echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
  3250. }
  3251. }
  3252. else
  3253. {
  3254. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3255. }
  3256. }
  3257. public function _email($content,$data,$shopname)
  3258. {
  3259. $express = $this->express->read($data['express']);
  3260. $t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
  3261. $h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['servicename'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
  3262. $content = str_replace($t,$h,$content);
  3263. $this->load->library('email');
  3264. $config['protocol'] = 'smtp';
  3265. $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
  3266. $config['smtp_port'] = 465;
  3267. $config['smtp_user'] = 'service@email.supernovahair.com';
  3268. $config['smtp_pass'] = 'LONGyihair374';
  3269. $config['smtp_crypto'] = 'ssl';
  3270. $config['crlf'] = "\r\n";
  3271. $config['newline'] = "\r\n";
  3272. $this->email->initialize($config);
  3273. $this->email->from('service@email.supernovahair.com',$shopname);
  3274. $this->email->to($data['email']);//收件
  3275. $this->email->subject('The product you purchased has a new progress');//标题
  3276. $this->email->message($content);//内容
  3277. if ( ! $this->email->send())
  3278. {
  3279. return 2;
  3280. }
  3281. else
  3282. {
  3283. return 1;
  3284. }
  3285. }
  3286. //导出订单excel
  3287. public function _cs()
  3288. {
  3289. if(isset($_GET['fexcel']))
  3290. {
  3291. if(isset($_SESSION['api']))
  3292. {
  3293. $user = $this->user->get_api($_SESSION['api']);
  3294. $usp = $user;
  3295. $fgshop = "";$sid = "";
  3296. $user = explode('|',trim($user['shop'],'|'));
  3297. foreach ($user as $value)
  3298. {
  3299. $fgshop .= " shop = ".$value." or";
  3300. $sid .= " id = ".$value." or";
  3301. }
  3302. }
  3303. $dowid = $this->input->get('a');
  3304. $wid = "";
  3305. if($dowid != "")
  3306. {
  3307. $id_arr = explode(',',rtrim($dowid,','));
  3308. foreach ($id_arr as $v)
  3309. {
  3310. $wid .= " id = 0 or";
  3311. $wid .= " id = '$v' or";
  3312. }
  3313. $wid = " and".rtrim($wid,'or');
  3314. }
  3315. $fexcel = $this->input->get('fexcel',true);
  3316. $page = $this->input->get('page',true);
  3317. $perpage = $this->input->get('perpage',true);
  3318. $warehouse = $this->input->get('warehouse',true);
  3319. $timetk = $this->input->get('timetk',true);
  3320. $timetj = $this->input->get('timetj',true);
  3321. $shop = $this->input->get('shop',true);
  3322. $source = $this->input->get('source',true);
  3323. $state = $this->input->get('state',true);
  3324. $review = $this->input->get('review',true);
  3325. $type = $this->input->get('type',true);
  3326. $express = $this->input->get('express',true);
  3327. $orderinfo = $this->input->get('orderinfo',true);
  3328. $user = $this->input->get('user',true);
  3329. $client = $this->input->get('name',true);
  3330. $waybill = $this->input->get('waybill',true);
  3331. $number = $this->input->get('number',true);
  3332. $email = $this->input->get('email',true);
  3333. $dlz = $this->input->get('dlz',true);
  3334. $library = $this->input->get('library',true);
  3335. $libraryconfirm = $this->input->get('libraryconfirm',true);
  3336. $print = $this->input->get('print',true);
  3337. $timetkk = $this->input->get('timetkk',true);
  3338. $timetjj = $this->input->get('timetjj',true);
  3339. $timetk = strtotime($timetk);
  3340. $timetj = strtotime($timetj);
  3341. $timetkk = strtotime($timetkk);
  3342. $timetjj = strtotime($timetjj);
  3343. $where = "mergeid = 0 and (".rtrim($fgshop,'or').")";
  3344. if($warehouse)
  3345. {
  3346. $where .= " and type = '$warehouse'";
  3347. }
  3348. if($timetk && $timetj)
  3349. {
  3350. $timetj = $timetj+24*3600;
  3351. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3352. }
  3353. if($timetkk && $timetjj)
  3354. {
  3355. $where .= " and librarytime > '$timetkk' and librarytime < '$timetjj'";
  3356. }
  3357. if($library)
  3358. {
  3359. $where .= " and library = '$library'";
  3360. }
  3361. if($print)
  3362. {
  3363. $where .= " and print = '$print'";
  3364. }
  3365. if($shop)
  3366. {
  3367. $where .= " and shop = '$shop'";
  3368. }
  3369. if($source)
  3370. {
  3371. $where .= " and source = '$source'";
  3372. }
  3373. if($state)
  3374. {
  3375. $where .= " and state = '$state'";
  3376. }
  3377. if($review)
  3378. {
  3379. $where .= " and review = '$review'";
  3380. }
  3381. if($type)
  3382. {
  3383. $where .= " and type = '$type'";
  3384. }
  3385. if($express)
  3386. {
  3387. $where .= " and express = '$express'";
  3388. }
  3389. if($orderinfo)
  3390. {
  3391. $where .= " and orderinfo = '$orderinfo'";
  3392. }
  3393. if($user)
  3394. {
  3395. $where .= " and user = '$user'";
  3396. }
  3397. if($client)
  3398. {
  3399. $where .= " and client like '%$client%'";
  3400. }
  3401. if($waybill)
  3402. {
  3403. $where .= " and waybill = '$waybill'";
  3404. }
  3405. if($number)
  3406. {
  3407. $where .= " and number = '$number'";
  3408. }
  3409. if($email)
  3410. {
  3411. $where .= " and email = '$email'";
  3412. }
  3413. if($dlz)
  3414. {
  3415. $where .= " and waybill != '' and dlz = 0";
  3416. }
  3417. if($dlz)
  3418. {
  3419. $where .= " and libraryconfirm = '$libraryconfirm'";
  3420. }
  3421. $fexcel = $this->fullorderexcel->read($fexcel);
  3422. $fexceleq = explode("|",rtrim($fexcel['content'],'|'));
  3423. foreach ($fexceleq as $k=>$v)
  3424. {
  3425. $fexceleq[$k] = explode('-',$v);
  3426. $num[$k] = $fexceleq[$k][0];
  3427. }
  3428. //array_multisort($num,SORT_ASC,$fexceleq);//重新排序
  3429. $feq = "";
  3430. foreach ($fexceleq as $k=>$v)
  3431. {
  3432. $feq .= $v[1].',';
  3433. }
  3434. $feq = rtrim($feq,',');
  3435. $fexcelzhw = explode('|',rtrim($fexcel['contentzh'],'|'));
  3436. foreach ($fexcelzhw as $k=>$v)
  3437. {
  3438. $fexcelzhw[$k] = explode('-',$v);
  3439. $numb[$k] = $fexcelzhw[$k][0];
  3440. }
  3441. //array_multisort($numb,SORT_ASC,$fexcelzhw);//重新排序
  3442. $fexcelzh = array();
  3443. foreach ($fexcelzhw as $k=>$v)
  3444. {
  3445. $fexcelzh[] = $v[1];
  3446. }
  3447. //取得信息列表
  3448. $info_list = $this->fullorder->find_all($where.$wid,$feq,'id desc');
  3449. //格式化数据
  3450. $i = 1;$shouldmoney = 0;$hl=1;
  3451. foreach ($info_list as $key=>$value)
  3452. {
  3453. if(isset($value['currencytitle']))
  3454. {
  3455. if($value['currencytitle'] != "CNY")
  3456. {
  3457. $hl=$value['hl'];
  3458. }
  3459. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  3460. $budget=$budget+($value['budget']*$hl);
  3461. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  3462. $refund=$refund+($value['refund']*$hl);
  3463. }
  3464. if(isset($value['shop']))
  3465. {
  3466. $shop = $this->shop->read($value['shop']);
  3467. $info_list[$key]['shop'] = $shop['shopname'];
  3468. }
  3469. if(isset($value['dtime']))
  3470. {
  3471. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  3472. }
  3473. if(isset($value['country']))
  3474. {
  3475. $country = $this->country->read($value['country']);
  3476. $info_list[$key]['country'] = $country['name'];
  3477. }
  3478. if(isset($value['type']))
  3479. {
  3480. $type = $this->warehouse->read($value['type']);
  3481. $info_list[$key]['type'] = $type['title'];
  3482. }
  3483. if(isset($value['express']))
  3484. {
  3485. $express = $this->express->read($value['express']);
  3486. if($express)
  3487. {
  3488. $info_list[$key]['express'] = $express['servicename'];
  3489. }
  3490. else
  3491. {
  3492. $info_list[$key]['express'] = '未选择';
  3493. }
  3494. }
  3495. }
  3496. echo $timetkk;
  3497. }
  3498. }
  3499. public function _gggs($sku,$s,$j,$k)
  3500. {
  3501. $companytitle = array(9=>3,10=>2,11=>1,12=>4);
  3502. $this->load->database();
  3503. $this->db->select('id');
  3504. $this->db->from('crowd_whlabel');
  3505. $this->db->where('warehouse', '5');
  3506. $this->db->where('sku', $sku);
  3507. $this->db->where('state', '0');
  3508. $this->db->limit($s,$k);
  3509. $query = $this->db->get();
  3510. $ids = array_column($query->result_array(), 'id');
  3511. if (!empty($ids))
  3512. {
  3513. // 更新
  3514. $this->db->where_in('id', $ids);
  3515. $this->db->update('crowd_whlabel', array('companytitle' => $companytitle[$j]));
  3516. return $this->db->affected_rows();
  3517. }
  3518. }
  3519. public function _xxpl()
  3520. {
  3521. $this->load->database();
  3522. $data = ['type' => ''];
  3523. $this->db->update('crowd_whlabel', $data);
  3524. $wt = array();
  3525. $whlabel_type = $this->whlabel_type->find_all();
  3526. foreach ($whlabel_type as $v)
  3527. {
  3528. $wt[$v['title']] = $v['id'];
  3529. }
  3530. /* 订单加入键值-j */
  3531. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3532. $config['upload_path'] = '.'.$dir ;
  3533. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3534. $config['allowed_types'] = 'xls|xlsx|csv';
  3535. $config['max_size'] = 10240;
  3536. $this->load->library('upload', $config);
  3537. $this->upload->initialize($config);
  3538. if ($this->upload->do_upload('userfile'))
  3539. {
  3540. $full_path = $dir.$this->upload->data('file_name');
  3541. $fileName = '.' . $full_path;
  3542. if (!file_exists($fileName))
  3543. {
  3544. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3545. }
  3546. else
  3547. {
  3548. require_once "./data/excel/PHPExcel/IOFactory.php";
  3549. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3550. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3551. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3552. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3553. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3554. ++$column;//如果列数大于26行
  3555. $list = array();
  3556. for ($i = 2; $i <= $row; $i++) // 行数循环
  3557. {
  3558. $data = array();
  3559. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3560. {
  3561. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3562. }
  3563. $list[] = $data;
  3564. }
  3565. }
  3566. $wt = array();
  3567. $whlabel_type = $this->whlabel_type->find_all();
  3568. foreach ($whlabel_type as $v)
  3569. {
  3570. $wt[$v['title']] = $v['id'];
  3571. }
  3572. $j = 0;$ed = array();$e = 0;$c = 0;$cs = array();
  3573. foreach ($list as $v)
  3574. {
  3575. $this->load->database();
  3576. // 设置更新数据
  3577. $data = ['type' => $wt[$v[1]]];
  3578. // 添加条件:SKU 为 123456 且 warehouse 为 5
  3579. $this->db->where('SKU', $v[0]);
  3580. $this->db->where('warehouse', '5');
  3581. // 批量更新
  3582. $this->db->update('crowd_whlabel', $data);
  3583. }
  3584. /** 导入缺货
  3585. $time = time();
  3586. $whlabel = $this->whlabel->get_sku($v[0]);
  3587. if($whlabel)
  3588. {
  3589. $this->whlabel_qh->insert(array('sku'=>$whlabel['sku'],'features'=>$whlabel['features'],'num'=>$v['1'],'gtime'=>date('Ym',$time),'gxtime'=>date('Ymd',$time)));
  3590. }
  3591. else
  3592. {
  3593. $ed[] = $v['0'];
  3594. $j++;
  3595. }
  3596. }
  3597. **/
  3598. /**
  3599. 更换等级
  3600. $this->load->database();
  3601. // 设置更新数据
  3602. $data = ['type' => $wt[$v[1]]];
  3603. // 添加条件:SKU 为 123456 且 warehouse 为 5
  3604. $this->db->where('SKU', $v[0]);
  3605. $this->db->where('warehouse', '5');
  3606. // 批量更新
  3607. $this->db->update('crowd_whlabel', $data);
  3608. **/
  3609. /**
  3610. $whlabel_type = $this->whlabel_type->find_all();
  3611. foreach ($whlabel_type as $v)
  3612. {
  3613. $wt[$v['title']] = $v['id'];
  3614. }
  3615. foreach ($list as $v)
  3616. {
  3617. $w = $this->whlabel->find_all("sku = '".$v[0]."' and warehouse = 5");
  3618. if($w && isset($wt[$v[1]]))
  3619. {
  3620. foreach ($w as $val)
  3621. {
  3622. $this->whlabel->save(array('type'=>$wt[$v[1]]),$val['id']);
  3623. }
  3624. }
  3625. else
  3626. {
  3627. $ed[] = array($v[0],$v[1]);
  3628. $j++;
  3629. }
  3630. }
  3631. **/
  3632. if($e > 0)
  3633. {
  3634. $time = date('Ymd',time());
  3635. $title = '错误信息-'.$time;
  3636. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3637. $tail = "\n";
  3638. $filename = $title.".xls";
  3639. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3640. $dir = '/data/excel/'.$time.'/';
  3641. $file_name = 'error_'.$time.rand(1000,9999);
  3642. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3643. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3644. fwrite($myfile,$ecl);
  3645. fclose($myfile);
  3646. $error = $dir.$file_name.'.xls';
  3647. echo json_encode(array('msg'=>$j.'条异常,','error'=>$error,'success'=>true));exit;
  3648. }
  3649. else
  3650. {
  3651. echo json_encode(array('msg'=>'添加成功!'.$c,'success'=>true));exit;
  3652. }
  3653. }
  3654. else
  3655. {
  3656. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3657. }
  3658. }
  3659. public function _skuzh()
  3660. {
  3661. /* 订单加入键值-j */
  3662. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3663. $config['upload_path'] = '.'.$dir ;
  3664. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3665. $config['allowed_types'] = 'xls|xlsx|csv';
  3666. $config['max_size'] = 10240;
  3667. $this->load->library('upload', $config);
  3668. $this->upload->initialize($config);
  3669. if ($this->upload->do_upload('userfile'))
  3670. {
  3671. $full_path = $dir.$this->upload->data('file_name');
  3672. $fileName = '.' . $full_path;
  3673. if (!file_exists($fileName))
  3674. {
  3675. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3676. }
  3677. else
  3678. {
  3679. require_once "./data/excel/PHPExcel/IOFactory.php";
  3680. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3681. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3682. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3683. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3684. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3685. ++$column;//如果列数大于26行
  3686. $list = array();
  3687. for ($i = 2; $i <= $row; $i++) // 行数循环
  3688. {
  3689. $data = array();
  3690. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3691. {
  3692. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3693. }
  3694. $list[] = $data;
  3695. }
  3696. }
  3697. $dictionaries = $this->typeclass->find_all('spare!= "" and classid != 1 and classid != 2 and classid != 3 and classid != 4 and classid != 5 and classid != 11 and classid != 16 and classid != 17 and classid != 20 and classid != 21 and classid != 23 and classid != 24 and classid != 29 and classid != 30 and classid != 31 and classid != 32');
  3698. $dtc = array();
  3699. foreach ($dictionaries as $v)
  3700. {
  3701. if(stripos($v['spare'],'|') !== false)//如果有多个值
  3702. {
  3703. $v['spare'] = explode('|',$v['spare']);
  3704. foreach ($v['spare'] as $k=>$vs)
  3705. {
  3706. if(stripos($v['zh'],'|') !== false)
  3707. {
  3708. $vzh = explode('|',$v['zh']);
  3709. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  3710. }
  3711. else
  3712. {
  3713. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  3714. }
  3715. }
  3716. }
  3717. else
  3718. {
  3719. $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
  3720. }
  3721. }
  3722. $dictionaries2 = $this->typeclass->find_all();
  3723. foreach ($dictionaries2 as $v)
  3724. {
  3725. $dtctitle[$v['id']] = $v['title'];
  3726. }
  3727. /* 匹配结束 */
  3728. /* 价格加入 */
  3729. $money = array();
  3730. $productdescribe = $this->productdescribe->find_all('1=1');
  3731. foreach ($productdescribe as $v)
  3732. {
  3733. $money[$v['number']] = array();
  3734. }
  3735. /* 价格加入 */
  3736. /* 匹配ID加入 */
  3737. $int = array();
  3738. $intdata = $this->typeclass->find_all('classid=14','id,spare');
  3739. foreach ($intdata as $v)
  3740. {
  3741. $v['spare'] = explode('|',$v['spare']);
  3742. $int[$v['id']] = $v['spare'][0];
  3743. }
  3744. /* 匹配ID加入 */
  3745. $zjsku = array();
  3746. $shopsku = $this->shopsku->find_all();
  3747. foreach ($shopsku as $val)
  3748. {
  3749. $ss = explode(',',trim($val['shop'],','));
  3750. foreach ($ss as $v)
  3751. {
  3752. if(isset($zjsku[$v]))
  3753. {
  3754. $zjsku[$v] .= ','.trim($val['sku'],',');
  3755. }
  3756. else
  3757. {
  3758. $zjsku[$v] = trim($val['sku'],',');
  3759. }
  3760. }
  3761. }
  3762. /* 匹配ID结束 */
  3763. $q = '1;';
  3764. $is = $this->is->find_all('1=1','*','number asc');//获取仓库平匹配表
  3765. $shop = $this->shop->read(19);
  3766. if(isset($zjsku[$shop['id']]))//判断是否找到店铺SKU
  3767. {
  3768. $sku = rtrim($sku,',').','.$zjsku[$shop['id']];
  3769. }
  3770. $ed = array();
  3771. foreach ($list as $v)
  3772. {
  3773. $r = $this->api->matching(trim($q,';'),$v['2'],$dtc,$money,$int,$dtctitle,$shop);
  3774. $p = '';
  3775. $product = explode(';',trim($r['product'],';'));
  3776. if($r['title'] != '' && $product)
  3777. {
  3778. foreach ($product as $val)
  3779. {
  3780. $vc = explode('|',$val);
  3781. if(isset($vc[1]))
  3782. {
  3783. $p .= $vc[1].'<br>';
  3784. }
  3785. }
  3786. $r['title'] = str_replace(array('<','>'),array('&lt;','&gt;'),$r['title']);
  3787. $ed[] = array($v['0'],$v['1'],$r['title'],$v['3'],$v['4'],$v['5']);
  3788. }
  3789. else
  3790. {
  3791. $ed[] = array($v['0'],$v['1'],$v['2'].' SKU错误',$v['3'],$v['4'],$v['5']);
  3792. }
  3793. }
  3794. $time = date('Ymd',time());
  3795. $title = 'sku转换'.$time;
  3796. $titlename = "<table border=1><tr><td>退款日期</td><td>订单号</td><td>SKU</td><td退款金额</td><td退款情况具体描述</td><可用/不可用</td></tr></table>";
  3797. $tail = "\n";
  3798. $filename = $title.".xls";
  3799. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3800. $dir = '/data/excel/'.$time.'/';
  3801. $file_name = 'sku转换 '.$time.rand(1000,9999);
  3802. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3803. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3804. fwrite($myfile,$ecl);
  3805. fclose($myfile);
  3806. $error = $dir.$file_name.'.xls';
  3807. echo json_encode(array('msg'=>'转换成功!','error'=>$error,'success'=>true));exit;
  3808. }
  3809. else
  3810. {
  3811. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3812. }
  3813. }
  3814. public function _xxpl_b()
  3815. {
  3816. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  3817. /* 订单加入键值-k */
  3818. $fdata = $this->fullordersmt->find_all('dtime >'.(time()-10*24*3600));
  3819. foreach ($fdata as $v)
  3820. {
  3821. $dataorder[$v['orderinfo']] = $v;
  3822. }
  3823. /* 订单加入键值-j */
  3824. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3825. $config['upload_path'] = '.'.$dir ;
  3826. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3827. $config['allowed_types'] = 'xls|xlsx|csv';
  3828. $config['max_size'] = 10240;
  3829. $this->load->library('upload', $config);
  3830. $this->upload->initialize($config);
  3831. if ($this->upload->do_upload('userfile'))
  3832. {
  3833. $full_path = $dir.$this->upload->data('file_name');
  3834. $fileName = '.' . $full_path;
  3835. if (!file_exists($fileName))
  3836. {
  3837. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3838. }
  3839. else
  3840. {
  3841. require_once "./data/excel/PHPExcel/IOFactory.php";
  3842. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3843. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3844. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3845. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3846. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3847. ++$column;//如果列数大于26行
  3848. $list = array();
  3849. for ($i = 2; $i <= $row; $i++) // 行数循环
  3850. {
  3851. $data = array();
  3852. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3853. {
  3854. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3855. }
  3856. $list[] = $data;
  3857. }
  3858. }
  3859. $i = 0;$j = 0;$ed = array();$time = time();
  3860. foreach ($list as $key=>$value)
  3861. {
  3862. $shop = $this->shop->get_shopname($value['2']);//通过店铺名称查找店铺
  3863. if(!$shop)
  3864. {
  3865. $ed[] = array($value['0'].'-无此店铺');
  3866. $i++;continue;
  3867. }
  3868. $post['buytime'] = strtotime($value['6']);//付款时间
  3869. $value['0'] = preg_replace('/\D/s','',$value['0']);
  3870. if($value['0'] && !isset($dataorder[$value['0']]))
  3871. {
  3872. $post['source'] = 2;//订单类型:1.线下订单2.PC3.手机
  3873. $post['state'] = 207;//订单状态:207等待发货
  3874. $post['review'] = 6;//审核状态:1.未送审2.待审核3.不通过4取消重审5.审核通过6.自动通过
  3875. $post['reviewtime'] = $time;//审核时间
  3876. $post['print'] = 2;//打印状态:1.不可打印2.未打印3.已打印
  3877. $post['library'] = 1;//出库状态:1.未出库2.已出库3.已退库
  3878. $post['libraryconfirm'] = 1;//出库确认:1.不允许2.允许
  3879. $post['dtime'] = $time;//订单时间
  3880. $post['capital'] = 3;//资金状态
  3881. $post['currency'] = 219;//币种
  3882. $post['currencytitle'] = 'USD';//币种名称
  3883. $post['freight'] = 0;//运费
  3884. $post['expressmoney'] = 0;//物流金额
  3885. $post['shouldmoney'] = 0;//应收金额
  3886. if($post['print'] != 3)
  3887. {
  3888. $post['librarynot'] = "订单未打印";//不能出库原因
  3889. }
  3890. $post['gtime'] = date('Ymd',$post['buytime']);//格式化时间
  3891. $num = $this->fullordersmt->find_count('gtime = "'.date('Ymd',$post['buytime']).'" and shop = "'.$shop['id'].'"','id');
  3892. $post['number'] = $shop['shortname'].'-'.substr(date('ymd',$post['buytime']),1).'-'.(substr(strval($num+1+1000),1,3));//编号
  3893. $post['user'] = $shop['shopuser'];//店铺负责人
  3894. $post['orderinfo'] = $value['0'];//订单号
  3895. $post['type'] = $value['7'];//发货仓库
  3896. $post['shop'] = $shop['id'];//店铺
  3897. $post['shouldmoney'] = $value['3'];//订单金额
  3898. $post['product'] = $value['4']?$value['4']:'';//商品名称
  3899. $post['pay'] = $value['5'];//付款方式
  3900. $post['paypal'] = $value['1']?$value['1']:'';//交易号
  3901. $post['orderremarks'] = $value['8']?$value['8']:'';//订单备注
  3902. $post['shipremarks'] = $value['9'];//仓库品名
  3903. $post['client'] = preg_replace('/( | | | |\s)/',' ',$value['10']);//公司名
  3904. $post['name'] = preg_replace('/( | | | |\s)/',' ',$value['11']);//收货人
  3905. $post['phone'] = $value['12'];//电话
  3906. $ct = $this->country->get_ename(preg_replace('/( | | | |\s)/',' ',$value['13']));//国家
  3907. if(!$ct)
  3908. {
  3909. $ed[] = array($value['0'].'-无此国家');
  3910. $i++;continue;
  3911. }
  3912. $post['country'] = $ct['id'];//国家
  3913. $post['al'] = $ct['lb'];//国家二字码
  3914. $post['province'] = $value['14'];//省、州
  3915. $post['city'] = $value['15'];//城市
  3916. $post['zipcode'] = $value['16'];//邮编
  3917. $post['address'] = $value['17'];//地址1
  3918. $post['address2'] = $value['18']?$value['18']:'';//地址2
  3919. $yga = $value['3'];$ygb = $shop['estimaterate'];
  3920. $post['budget'] = eval("return $yga*1.$ygb;");//预估到帐金额
  3921. $post['sbpm'] = $value['19'];//申报品名
  3922. $post['zwpm'] = $value['20'];//中文品名
  3923. $post['ts'] = $value['21'];//条数
  3924. $post['dtsbjz'] = $value['22'];//单条申报价
  3925. $post['zsbjz'] = $value['23'];//总申报价
  3926. $post['zzl'] = $value['24'];//总重量
  3927. $post['zjs'] = $value['25'];//总件数
  3928. $express = $this->express->get_servicename(preg_replace('/( | | | |\s)/',' ',$value['26']));
  3929. if(!$express)
  3930. {
  3931. $ed[] = array($value['0'].'-无此快递方式');
  3932. $i++;continue;
  3933. }
  3934. $post['express'] = $express['id'];//快递
  3935. $post['printtype'] = 1;//打印类型 1.运单.2.发货单
  3936. $post['fpdata'] = '';//购买产品内容
  3937. $this->fullordersmt->insert($post);
  3938. }
  3939. else
  3940. {
  3941. $ed[] = array($value['0'].'-单号错误或重复操作');
  3942. $i++;
  3943. }
  3944. sleep(2);//停留2秒
  3945. }
  3946. if($i+$j > 0)
  3947. {
  3948. $time = date('Ymd',time());
  3949. $title = '错误信息-'.$time;
  3950. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3951. $tail = "\n";
  3952. $filename = $title.".xls";
  3953. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3954. $dir = '/data/excel/'.$time.'/';
  3955. $file_name = 'error_'.$time.rand(1000,9999);
  3956. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3957. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3958. fwrite($myfile,$ecl);
  3959. fclose($myfile);
  3960. $error = $dir.$file_name.'.xls';
  3961. echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
  3962. }
  3963. else
  3964. {
  3965. echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
  3966. }
  3967. }
  3968. else
  3969. {
  3970. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3971. }
  3972. }
  3973. public function _scwd()
  3974. {
  3975. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3976. $config['upload_path'] = '.'.$dir ;
  3977. $config['allowed_types'] = '*';
  3978. $config['max_size'] = 102400;
  3979. $this->load->library('upload', $config);
  3980. $this->upload->initialize($config);
  3981. if ($this->upload->do_upload('userfile'))
  3982. {
  3983. $full_path = $dir.$this->upload->data('file_name');
  3984. echo json_encode(array('msg'=>'成功!','wdurl'=>$full_path,'success'=>true));exit;
  3985. }
  3986. else
  3987. {
  3988. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3989. }
  3990. }
  3991. public function _jmexcel()
  3992. {
  3993. $setting = $this->setting->get_settings();
  3994. $excelpass = $setting['excelpass'];
  3995. $excelusernum = $setting['excelusernum'];
  3996. $exceljmnum = $setting['exceljmnum'];
  3997. $user = $this->user->get_api($_SESSION['api']);
  3998. if(!isset($user['exceltime']))
  3999. {
  4000. $this->session->sess_destroy();
  4001. header("Location:/");
  4002. }
  4003. $post = $this->input->post(NULL, TRUE);
  4004. if(isset($post['data']))
  4005. {
  4006. $data = $this->input->post('data',true);
  4007. $data = str_replace("\n",",",$data);;
  4008. $data = explode(',',trim($data,','));
  4009. $d = '';$i = 0;
  4010. foreach ($data as $v)
  4011. {
  4012. if($v == '')
  4013. {
  4014. continue;
  4015. }
  4016. $j = $this->setting->get_jmexcelpass($v);
  4017. if($j == '')
  4018. {
  4019. $j = $v.' 信息不正确';
  4020. }
  4021. $d .= $j."<br />";
  4022. $i++;
  4023. }
  4024. if($i > $exceljmnum)
  4025. {
  4026. echo json_encode(array('msg'=>'每次解密数量不可超出'.$exceljmnum.'条','success'=>false));exit;
  4027. }
  4028. if($user['exceltime'] != date('Ymd',time()))
  4029. {
  4030. $this->user->save(array('exceltime'=>date('Ymd',time()),'excelnum'=>1),$user['id']);
  4031. }
  4032. else
  4033. {
  4034. if($user['excelnum'] > $excelusernum)
  4035. {
  4036. echo json_encode(array('msg'=>'今日此账号解密次数已使用完毕','success'=>false));exit;
  4037. }
  4038. else
  4039. {
  4040. $this->user->save(array('excelnum'=>$user['excelnum']+1),$user['id']);
  4041. }
  4042. }
  4043. echo json_encode(array('msg'=>$d,'success'=>true));exit;
  4044. }
  4045. $this->data['excelpass'] = $excelpass;
  4046. $this->data['excelusernum'] = $excelusernum;
  4047. $this->data['exceljmnum'] = $exceljmnum;
  4048. $this->_Template('fullorderexcel_jmexcel',$this->data);
  4049. }
  4050. //管理
  4051. public function _classid()
  4052. {
  4053. $post = $this->input->post(NULL, TRUE);
  4054. if(isset($post['page']))
  4055. {
  4056. $page = $this->input->post('page',true);
  4057. $perpage = $this->input->post('perpage',true);
  4058. $type = $this->input->post('type',true);
  4059. $where = "1=1 ";
  4060. //数据排序
  4061. $order_str = "id asc";
  4062. if(empty($page))
  4063. {
  4064. $start = 0;
  4065. $perpage = 1;
  4066. }
  4067. else
  4068. {
  4069. $start = ($page - 1)*$perpage;
  4070. }
  4071. if($type)
  4072. {
  4073. $where .= " and type = '$type'";
  4074. }
  4075. //取得信息列表
  4076. $info_list = $this->fullorderexcelclassid->find_all($where,'id,title,type',$order_str,$start,$perpage);
  4077. $total = $this->fullorderexcelclassid->find_count($where);
  4078. $pagenum = ceil($total/$perpage);
  4079. $over = $total-($start+$perpage);
  4080. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4081. echo json_encode($rows);exit;
  4082. }
  4083. $this->_Template('fullorderexcel_classid',$this->data);
  4084. }
  4085. //添加
  4086. public function _classidadd()
  4087. {
  4088. $post = $this->input->post(NULL, TRUE);
  4089. if(isset($post['title']))
  4090. {
  4091. if($this->fullorderexcelclassid->insert($post))
  4092. {
  4093. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  4094. }
  4095. else
  4096. {
  4097. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  4098. }
  4099. }
  4100. $this->_Template('fullorderexcel_classidadd',$this->data);
  4101. }
  4102. //修改
  4103. public function _classidedit($arg_array)
  4104. {
  4105. $post = $this->input->post(NULL, TRUE);
  4106. if(isset($post['id']))
  4107. {
  4108. $id = $this->input->post('id',true);
  4109. if($this->fullorderexcelclassid->save($post,$id))
  4110. {
  4111. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  4112. }
  4113. else
  4114. {
  4115. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  4116. }
  4117. }
  4118. $arg_array = $arg_array[0];
  4119. $fullorderexcelclassid = $this->fullorderexcelclassid->read($arg_array);
  4120. $this->data['fullorderexcelclassid'] = $fullorderexcelclassid;
  4121. $this->_Template('fullorderexcel_classidedit',$this->data);
  4122. }
  4123. }