Customer.php 95 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Customer extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_customer','customer');
  7. $this->load->_model('Model_typeclass','typeclass');
  8. $this->load->_model('Model_shop','shop');
  9. $this->load->_model('Model_country','country');
  10. $this->load->_model('Model_express','express');
  11. $this->load->_model('Model_fullorder','fullorder');
  12. $this->load->_model('Model_fullordertt','fullordertt');
  13. $this->load->_model('Model_excel','excel');
  14. $this->load->_model('Model_whlabel','whlabel');
  15. $this->load->_model('Model_warehouse','warehouse');
  16. $this->load->_model('Model_specialstock','specialstock');
  17. $this->load->_model('Model_ck','ck');
  18. $this->load->_model('Model_weight','weight');
  19. $this->load->_model('Model_pay','pay');
  20. $this->load->_model('Model_setting','setting');
  21. $this->load->_model('Model_classid','classid');
  22. $this->load->_model('Model_apiyy','apiyy');
  23. $this->load->_model('Model_whlabel_fc','whlabel_fc');
  24. $this->load->_model('Model_hl','hl');
  25. $this->load->_model('Model_productdescribe','productdescribe');
  26. $this->load->_model('Model_shopsku','shopsku');
  27. $this->load->_model('Model_api','api');
  28. }
  29. //定义方法的调用规则 获取URI第二段值
  30. public function _remap($arg,$arg_array)
  31. {
  32. if($arg == 'add')//添加
  33. {
  34. $this->_add();
  35. }
  36. else if($arg == 'edit')//修改
  37. {
  38. $this->_edit($arg_array);
  39. }
  40. else if($arg == 'del')//黑名单
  41. {
  42. $this->_del();
  43. }
  44. else if($arg == 'change')//更改名单状态
  45. {
  46. $this->_change();
  47. }
  48. else if($arg == 'mdedit')//修改
  49. {
  50. $this->_mdedit($arg_array);
  51. }
  52. else if($arg == 'black')//黑名单
  53. {
  54. $this->_black();
  55. }
  56. else if($arg == 'excela')
  57. {
  58. $this->_excela();
  59. }
  60. else if($arg == 'temuexcel')
  61. {
  62. $this->_temuexcel();
  63. }
  64. else if($arg == 'daifakehuexcel')
  65. {
  66. $this->_daifakehuexcel();
  67. }
  68. else if($arg == 'excel')//下载excel
  69. {
  70. $this->_excel();
  71. }
  72. else if($arg == 'indexexcel')//下载excel
  73. {
  74. $this->_indexexcel();
  75. }
  76. else if($arg == 'down')//黑名单
  77. {
  78. $this->_down();
  79. }
  80. else if($arg == 'bankdown')//下载客户
  81. {
  82. $this->_bankdown();
  83. }
  84. else if($arg == 'newold')//新老客户比
  85. {
  86. $this->_newold();
  87. }
  88. else if($arg == 'dgso')
  89. {
  90. $this->_dgso();
  91. }
  92. else if($arg == 'cx')
  93. {
  94. $this->_cx();
  95. }
  96. else
  97. {
  98. $this->_index();
  99. }
  100. }
  101. //管理
  102. public function _index_xxxxxx()//通过索引订单查询购买次数,太慢,暂时抛弃
  103. {
  104. $user = $this->user->get_api($_SESSION['api']);
  105. if($user)
  106. {
  107. $fgshop = "";$sid = "";
  108. $user = explode('|',trim($user['shop'],'|'));
  109. foreach ($user as $value)
  110. {
  111. $fgshop .= " shop = ".$value." or";
  112. $sid .= " id = ".$value." or";
  113. }
  114. }
  115. $post = $this->input->post(NULL, TRUE);
  116. if(isset($post['page']))
  117. {
  118. $page = $this->input->post('page',true);
  119. $perpage = $this->input->post('perpage',true);
  120. $shop = $this->input->post('shop',true);
  121. $numphone = $this->input->post('numphone',true);
  122. $name = $this->input->post('name',true);
  123. $email = $this->input->post('email',true);
  124. $address = $this->input->post('address',true);
  125. $level = $this->input->post('level',true);
  126. $num = $this->input->post('num',true);
  127. $timetk = $this->input->post('timetk',true);
  128. $timetj = $this->input->post('timetj',true);
  129. $timetk = strtotime($timetk);
  130. $timetj = strtotime($timetj);
  131. $where = "1=1 and type = 1 and (".rtrim($fgshop,'or').")";
  132. if($shop)
  133. {
  134. $where .= " and shop = '$shop'";
  135. }
  136. if($numphone)
  137. {
  138. $where .= " and numphone = '$numphone'";
  139. }
  140. if($name)
  141. {
  142. $where .= " and name like '%$name%'";
  143. }
  144. if($email)
  145. {
  146. $where .= " and email like '%$email%'";
  147. }
  148. if($level)
  149. {
  150. $where .= " and level = '$level'";
  151. }
  152. if($address)
  153. {
  154. $where .= " and address like '%$address%'";
  155. }
  156. if($timetk && $timetj)
  157. {
  158. //$where .= " and ((time > '$timetk' and time < '$timetj') or time = 0)";
  159. $where .= " and ((time > '$timetk' and time < '$timetj') or time = '0')";
  160. }
  161. //数据排序
  162. $order_str = "id desc";
  163. $numdata = array();
  164. if(empty($page))
  165. {
  166. $start = 0;
  167. $perpage = 1;
  168. }
  169. else
  170. {
  171. $start = ($page - 1)*$perpage;
  172. }
  173. //取得信息列表
  174. if($num > 0)
  175. {
  176. $info_list = $this->customer->find_all($where,'id,shop,source,name,email,country,level,money,num,time,count,type',$order_str);
  177. }
  178. else
  179. {
  180. $info_list = $this->customer->find_all($where,'id,shop,source,name,email,country,level,money,num,time,count,type',$order_str,$start,$perpage);
  181. }
  182. foreach ($info_list as $key=>$value)
  183. {
  184. $shop = $this->shop->read($value['shop']);
  185. $info_list[$key]['shop'] = $shop['shopname'];
  186. $source = $this->typeclass->read($value['source']);
  187. $info_list[$key]['source'] = $source['title'];
  188. if($value['email'] != '0' && $value['email'] != '' && $value['email'] != '无')
  189. {
  190. $gnum = $this->fullorder->find_count("email = '".$value['email']."' and shop = '".$value['shop']."' and mergeid = 0 and buytime > '$timetk' and buytime < '$timetj'");
  191. }
  192. else
  193. {
  194. $gnum = 0;
  195. }
  196. $info_list[$key]['num'] = $gnum;
  197. if($value['country'] != 0)
  198. {
  199. $country = $this->country->read($value['country']);
  200. $info_list[$key]['country'] = $country['name'];
  201. }
  202. else
  203. {
  204. $info_list[$key]['country'] = "未知";
  205. }
  206. if($value['level'] == 1)
  207. {
  208. $info_list[$key]['level'] = "网红";
  209. }
  210. else if($value['level'] == 2)
  211. {
  212. $info_list[$key]['level'] = "批发";
  213. }
  214. else if($value['level'] == 3)
  215. {
  216. $info_list[$key]['level'] = "店铺转线下";
  217. }
  218. else if($value['level'] == 4)
  219. {
  220. $info_list[$key]['level'] = "线下其他";
  221. }
  222. else if($value['level'] == 5)
  223. {
  224. $info_list[$key]['level'] = "店内客户";
  225. }
  226. if($value['time'] != 0)
  227. {
  228. $info_list[$key]['time'] = date('Y-m-d',$value['time']);
  229. }
  230. else
  231. {
  232. $info_list[$key]['time'] = "无";
  233. }
  234. $info_list[$key]['type'] = "<a href='javascript:void(0);' class='window' data-h='/customer/mdedit/".$value['id']."' data-t='客户下单'><b>下单</b></a>&nbsp;&nbsp;&nbsp;&nbsp;<a class='customer' data-type='2' data-t='yr' data-id='".$value['id']."' href='javascript:void(0);'>移入黑名单</a>";
  235. if($num >= '10' && $gnum >= '10')
  236. {
  237. $numdata[] = $info_list[$key];
  238. }
  239. else if ($num > '0' && $num < '10' && $gnum == $num)
  240. {
  241. $numdata[] = $info_list[$key];
  242. }
  243. }
  244. if($num > 0)
  245. {
  246. $info_list = array_slice($numdata,$start,$perpage);;
  247. $total = count($numdata);
  248. }
  249. else
  250. {
  251. $total = $this->customer->find_count($where);
  252. }
  253. $pagenum = ceil($total/$perpage);
  254. $over = $total-($start+$perpage);
  255. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  256. echo json_encode($rows);exit;
  257. }
  258. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  259. $this->data['wlshop'] = $wlshop;
  260. $this->_Template('customer',$this->data);
  261. }
  262. public function _index()//通过计数,2020/02/21已校准
  263. {
  264. $user = $this->user->get_api($_SESSION['api']);
  265. if($user)
  266. {
  267. $fgshop = "";$sid = "";
  268. $users = explode('|',trim($user['shop'],'|'));
  269. foreach ($users as $value)
  270. {
  271. $fgshop .= " shop = ".$value." or";
  272. $sid .= " id = ".$value." or";
  273. }
  274. if($user['vip'] == 1)
  275. {
  276. $vip = 1;
  277. }
  278. else
  279. {
  280. $vip = 0;
  281. }
  282. }
  283. else
  284. {
  285. $vip = 0;
  286. }
  287. $post = $this->input->post(NULL, TRUE);
  288. if(isset($post['page']))
  289. {
  290. $page = $this->input->post('page',true);
  291. $perpage = $this->input->post('perpage',true);
  292. $shop = $this->input->post('shop',true);
  293. $numphone = $this->input->post('numphone',true);
  294. $name = $this->input->post('name',true);
  295. $email = $this->input->post('email',true);
  296. $address = $this->input->post('address',true);
  297. $country = $this->input->post('country',true);
  298. $level = $this->input->post('level',true);
  299. $num = $this->input->post('num',true);
  300. $timetk = $this->input->post('timetk',true);
  301. $timetj = $this->input->post('timetj',true);
  302. $timetk = strtotime($timetk);
  303. $timetj = strtotime($timetj);
  304. $where = "1=1 and type = 1 and (".rtrim($fgshop,'or').")";
  305. if($shop)
  306. {
  307. $where .= " and shop = '$shop'";
  308. }
  309. if($numphone != '')
  310. {
  311. if($numphone == '0')
  312. {
  313. $where .= " and phone = '$numphone'" ;
  314. }
  315. else
  316. {
  317. $where .= " and numphone = '$numphone' and phone != ''" ;
  318. }
  319. }
  320. if($name)
  321. {
  322. $where .= " and name like '%$name%'";
  323. }
  324. if($country)
  325. {
  326. $where .= " and country = '$country'";
  327. }
  328. if($email)
  329. {
  330. $where .= " and email like '%$email%'";
  331. }
  332. if($level != '')
  333. {
  334. $where .= " and level = '$level'";
  335. }
  336. if($address)
  337. {
  338. $where .= " and address like '%$address%'";
  339. }
  340. if($num > 0 && $num < 10 && $num != '2a')
  341. {
  342. $where .= " and num = '$num'";
  343. }
  344. else if($num > 9)
  345. {
  346. $where .= " and num > '9'";
  347. }
  348. else if($num == '2a')
  349. {
  350. $where .= " and num > '1'";
  351. }
  352. else if($num == '0')
  353. {
  354. $where .= " and num = '0'";
  355. }
  356. else
  357. {
  358. $where .= " and num >= '0'";
  359. }
  360. if($timetk && $timetj)
  361. {
  362. $where .= " and ((time > '$timetk' and time < '$timetj') or time = '0')";
  363. }
  364. //数据排序
  365. $order_str = "time desc";
  366. $numdata = array();
  367. if(empty($page))
  368. {
  369. $start = 0;
  370. $perpage = 1;
  371. }
  372. else
  373. {
  374. $start = ($page - 1)*$perpage;
  375. }
  376. //取得信息列表
  377. $info_list = $this->customer->find_all($where,'id,shop,source,name,email,phone,country,level,money,num,numphone,time,count,type',$order_str,$start,$perpage);
  378. foreach ($info_list as $key=>$value)
  379. {
  380. $shop = $this->shop->read($value['shop']);
  381. $info_list[$key]['shop'] = $shop['shopname'];
  382. $source = $this->typeclass->read($value['source']);
  383. $info_list[$key]['source'] = $source['title'];
  384. if($value['country'] != 0)
  385. {
  386. $country = $this->country->read($value['country']);
  387. $info_list[$key]['country'] = $country['name'];
  388. }
  389. else
  390. {
  391. $info_list[$key]['country'] = "未知";
  392. }
  393. if($value['level'] == 1)
  394. {
  395. $info_list[$key]['level'] = "网红";
  396. }
  397. else if($value['level'] == 2)
  398. {
  399. $info_list[$key]['level'] = "批发";
  400. }
  401. else if($value['level'] == 3)
  402. {
  403. $info_list[$key]['level'] = "店铺转线下";
  404. }
  405. else if($value['level'] == 4)
  406. {
  407. $info_list[$key]['level'] = "线下其他";
  408. }
  409. else if($value['level'] == 5)
  410. {
  411. $info_list[$key]['level'] = "店内客户";
  412. }
  413. else
  414. {
  415. $info_list[$key]['level'] = "未定义";
  416. }
  417. if($value['time'] != 0)
  418. {
  419. $info_list[$key]['time'] = date('Y-m-d',$value['time']);
  420. }
  421. else
  422. {
  423. $info_list[$key]['time'] = "无";
  424. }
  425. //$gmcs = $this->fullorder->find_count("email = '".$value['email']."' time > '$timetk' and time < '$timetj'");
  426. //$info_list[$key]['num'] = $gmcs;
  427. $info_list[$key]['numphone'] = ($value['num'] > 0)?sprintf("%01.2f",$value['money']/$value['num']):0;
  428. $info_list[$key]['type'] = "<p><a href='javascript:void(0);' class='window' data-h='/customer/mdedit/".$value['id']."' data-t='客户下单'><b>下单</b></a></p><a class='customer' data-type='2' data-t='yr' data-id='".$value['id']."' href='javascript:void(0);'>移入黑名单</a>";
  429. }
  430. $total = $this->customer->find_count($where);
  431. $pagenum = ceil($total/$perpage);
  432. $over = $total-($start+$perpage);
  433. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  434. echo json_encode($rows);exit;
  435. }
  436. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  437. $this->data['wlshop'] = $wlshop;
  438. $this->data['vip'] = $vip;
  439. $this->_Template('customer',$this->data);
  440. }
  441. public function _dgso()
  442. {
  443. $user = $this->user->get_api($_SESSION['api']);
  444. if($user)
  445. {
  446. $fgshop = "";$sid = "";
  447. $users = explode('|',trim($user['shop'],'|'));
  448. foreach ($users as $value)
  449. {
  450. $fgshop .= " shop = ".$value." or";
  451. $sid .= " id = ".$value." or";
  452. }
  453. if($user['vip'] == 1)
  454. {
  455. $vip = 1;
  456. }
  457. else
  458. {
  459. $vip = 0;
  460. }
  461. }
  462. else
  463. {
  464. $vip = 0;
  465. }
  466. $post = $this->input->post(NULL, TRUE);
  467. if(isset($post['page']))
  468. {
  469. $page = $this->input->post('page',true);
  470. $perpage = $this->input->post('perpage',true);
  471. $shop = $this->input->post('shop',true);
  472. $numphone = $this->input->post('numphone',true);
  473. $name = $this->input->post('name',true);
  474. $email = $this->input->post('email',true);
  475. $address = $this->input->post('address',true);
  476. $level = $this->input->post('level',true);
  477. $num = $this->input->post('num',true);
  478. $timetk = $this->input->post('timetk',true);
  479. $timetj = $this->input->post('timetj',true);
  480. $timetk = strtotime($timetk);
  481. $timetj = strtotime($timetj);
  482. $where = "1=1 and (".rtrim($fgshop,'or').")";
  483. if($numphone)
  484. {
  485. $where .= " and numphone = '$numphone'";
  486. }
  487. if($email)
  488. {
  489. $where .= " and email like '%$email%'";
  490. }
  491. if($address)
  492. {
  493. $where .= " and address like '%$address%'";
  494. }
  495. if($numphone || $email || $address)
  496. {
  497. $d = $this->customer->find_all($where);
  498. $data = $this->customer->find_all("address like '%".$d[0]['address']."%' or email like '%".$d[0]['email']."%' or numphone like '%".$d[0]['numphone']."%'",'id,shop,source,name,email,country,level,money,num,time,type,numphone,address');
  499. //$temp_key = array_column($data,'id'); //键值
  500. //$Newdata = array_combine($temp_key,$data) ;
  501. $cx = array();
  502. $info_list = $this->_dgcz($cx,$data);
  503. $info_list = array_values($info_list);
  504. $total = count($info_list);
  505. $pagenum = ceil($total/$perpage);
  506. $over = $total-$perpage;
  507. }
  508. else
  509. {
  510. //数据排序
  511. $order_str = "id desc";
  512. $numdata = array();
  513. if(empty($page))
  514. {
  515. $start = 0;
  516. $perpage = 1;
  517. }
  518. else
  519. {
  520. $start = ($page - 1)*$perpage;
  521. }
  522. //取得信息列表
  523. $info_list = $this->customer->find_all($where,'id,shop,source,name,email,country,level,money,num,time,type',$order_str,$start,$perpage);
  524. $total = $this->customer->find_count($where);
  525. $pagenum = ceil($total/$perpage);
  526. $over = $total-($start+$perpage);
  527. }
  528. foreach ($info_list as $key=>$value)
  529. {
  530. $shop = $this->shop->read($value['shop']);
  531. $info_list[$key]['shop'] = $shop['shopname'];
  532. $source = $this->typeclass->read($value['source']);
  533. $info_list[$key]['source'] = $source['title'];
  534. if($value['country'] != 0)
  535. {
  536. $country = $this->country->read($value['country']);
  537. $info_list[$key]['country'] = $country['name'];
  538. }
  539. else
  540. {
  541. $info_list[$key]['country'] = "未知";
  542. }
  543. if($value['level'] == 1)
  544. {
  545. $info_list[$key]['level'] = "网红";
  546. }
  547. else if($value['level'] == 2)
  548. {
  549. $info_list[$key]['level'] = "批发";
  550. }
  551. else if($value['level'] == 3)
  552. {
  553. $info_list[$key]['level'] = "店铺转线下";
  554. }
  555. else if($value['level'] == 4)
  556. {
  557. $info_list[$key]['level'] = "线下其他";
  558. }
  559. else if($value['level'] == 5)
  560. {
  561. $info_list[$key]['level'] = "店内客户";
  562. }
  563. if($value['time'] != 0)
  564. {
  565. $info_list[$key]['time'] = date('Y-m-d',$value['time']);
  566. }
  567. else
  568. {
  569. $info_list[$key]['time'] = "无";
  570. }
  571. if($value['type'] != 2)
  572. {
  573. $info_list[$key]['type'] = "<a href='javascript:void(0);' class='window' data-h='/customer/mdedit/".$value['id']."' data-t='客户下单'><b>下单</b></a>&nbsp;&nbsp;&nbsp;&nbsp;<a class='customer' data-type='2' data-t='yr' data-id='".$value['id']."' href='javascript:void(0);'>移入黑名单</a>";
  574. }
  575. else
  576. {
  577. $info_list[$key]['type'] = "黑名单客户";
  578. }
  579. unset($info_list[$key]['numphone']);
  580. unset($info_list[$key]['address']);
  581. }
  582. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  583. echo json_encode($rows);exit;
  584. }
  585. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  586. $this->data['wlshop'] = $wlshop;
  587. $this->data['vip'] = $vip;
  588. $this->_Template('customer_dgso',$this->data);
  589. }
  590. public function _dgcz($child,$data)
  591. {
  592. foreach ($data as $key => $value)
  593. {
  594. if (!isset($child[$value['id']]))
  595. {
  596. $child[$value['id']] = $value;
  597. $rows = $this->customer->find_all("address like '%".$value['address']."%' or email like '%".$value['email']."%' or numphone like '%".$value['numphone']."%'",'id,shop,source,name,email,country,level,money,num,time,type,numphone,address');
  598. $this->_dgcz($child,$rows);
  599. }
  600. }
  601. return $child;
  602. }
  603. //管理
  604. public function _black()
  605. {
  606. /**
  607. $user = $this->user->get_api($_SESSION['api']);
  608. if($user)
  609. {
  610. $fgshop = "";$sid = "";
  611. $user = explode('|',trim($user['shop'],'|'));
  612. foreach ($user as $value)
  613. {
  614. $fgshop .= " shop = ".$value." or";
  615. $sid .= " id = ".$value." or";
  616. }
  617. }
  618. **/
  619. $post = $this->input->post(NULL, TRUE);
  620. if(isset($post['page']))
  621. {
  622. $page = $this->input->post('page',true);
  623. $perpage = $this->input->post('perpage',true);
  624. $shop = $this->input->post('shop',true);
  625. $numphone = $this->input->post('numphone',true);
  626. $name = $this->input->post('name',true);
  627. $email = $this->input->post('email',true);
  628. $address = $this->input->post('address',true);
  629. $xtime = $this->input->post('xtime',true);
  630. //$where = "1=1 and type = 2 and (".rtrim($fgshop,'or').")";
  631. $timetk = $this->input->post('timetk',true);
  632. $timetj = $this->input->post('timetj',true);
  633. $timetk = strtotime($timetk);
  634. $timetj = strtotime($timetj);
  635. $where = "1=1 and type = 2";
  636. if($shop)
  637. {
  638. $where .= " and shop = '$shop'";
  639. }
  640. if($xtime)
  641. {
  642. $where .= " and typetime > '$timetk' and typetime < '$timetj'";
  643. }
  644. if($numphone != '')
  645. {
  646. if($numphone == '0')
  647. {
  648. $where .= " and phone = '$numphone'" ;
  649. }
  650. else
  651. {
  652. $where .= " and numphone = '$numphone' and phone != ''" ;
  653. }
  654. }
  655. if($name)
  656. {
  657. $where .= " and name like '%$name%'";
  658. }
  659. if($email)
  660. {
  661. $where .= " and email like '%$email%'";
  662. }
  663. $hmdaddress1 = str_replace(array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),strtolower($address));
  664. $hmdaddress2 = str_replace(array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),strtolower($address));
  665. $hmdaddress3 = str_replace(array(' avenue',' ave',' av'),array(' ave',' avenue',' ave'),strtolower($address));
  666. if($address)
  667. {
  668. $where .= " and (address like '%$address%' or address like '%$hmdaddress1%' or address like '%$hmdaddress2%' or address like '%$hmdaddress3%')";
  669. }
  670. //数据排序
  671. $order_str = "id desc";
  672. if(empty($page))
  673. {
  674. $start = 0;
  675. $perpage = 1;
  676. }
  677. else
  678. {
  679. $start = ($page - 1)*$perpage;
  680. }
  681. //取得信息列表
  682. $info_list = $this->customer->find_all($where,'id,shop,source,name,email,address,phone,count,typetime,type',$order_str,$start,$perpage);
  683. foreach ($info_list as $key=>$value)
  684. {
  685. $shop = $this->shop->read($value['shop']);
  686. $info_list[$key]['shop'] = $shop['shopname'];
  687. $source = $this->typeclass->read($value['source']);
  688. $info_list[$key]['source'] = $source['title'];
  689. if($value['typetime'] > 0)
  690. {
  691. $info_list[$key]['typetime'] = date('Y-m-d',$value['typetime']);
  692. }
  693. else
  694. {
  695. $info_list[$key]['typetime'] = '无';
  696. }
  697. $info_list[$key]['type'] = "<a class='customer' data-type='1' data-t='yc' data-id='".$value['id']."' href='javascript:void(0);'>移出</a>";
  698. }
  699. $total = $this->customer->find_count($where);
  700. $pagenum = ceil($total/$perpage);
  701. $over = $total-($start+$perpage);
  702. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'a'=>$hmdaddress1);
  703. echo json_encode($rows);exit;
  704. }
  705. if(isset($post['s']))
  706. {
  707. $id_arr = $this->input->post('s');
  708. $id_arr = explode(',',$id_arr);
  709. if(!$id_arr)
  710. {
  711. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  712. }
  713. //循环删除记录
  714. foreach ($id_arr as $v)
  715. {
  716. $this->customer->remove($v);
  717. }
  718. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  719. }
  720. //$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  721. $wlshop = $this->shop->find_all('1=1');
  722. $this->data['wlshop'] = $wlshop;
  723. $this->_Template('customer_black',$this->data);
  724. }
  725. public function _cx()
  726. {
  727. $post = $this->input->post(NULL, TRUE);
  728. if(isset($post['page']))
  729. {
  730. $page = $this->input->post('page',true);
  731. $perpage = $this->input->post('perpage',true);
  732. $shop = $this->input->post('shop',true);
  733. $numphone = $this->input->post('numphone',true);
  734. $name = $this->input->post('name',true);
  735. $email = $this->input->post('email',true);
  736. $address = $this->input->post('address',true);
  737. $xtime = $this->input->post('xtime',true);
  738. //$where = "1=1 and type = 2 and (".rtrim($fgshop,'or').")";
  739. $timetk = $this->input->post('timetk',true);
  740. $timetj = $this->input->post('timetj',true);
  741. $timetk = strtotime($timetk);
  742. $timetj = strtotime($timetj);
  743. $where = "1=1 and type = 2";
  744. if($shop)
  745. {
  746. $where .= " and shop = '$shop'";
  747. }
  748. if($xtime)
  749. {
  750. $where .= " and typetime > '$timetk' and typetime < '$timetj'";
  751. }
  752. if($numphone)
  753. {
  754. $where .= " and numphone = '$numphone'";
  755. }
  756. if($name)
  757. {
  758. $where .= " and name like '%$name%'";
  759. }
  760. if($email)
  761. {
  762. $where .= " and email like '%$email%'";
  763. }
  764. $hmdaddress1 = str_replace(array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),strtolower($address));
  765. $hmdaddress2 = str_replace(array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),strtolower($address));
  766. $hmdaddress3 = str_replace(array(' avenue',' ave',' av'),array(' ave',' avenue',' ave'),strtolower($address));
  767. if($address)
  768. {
  769. $where .= " and (address like '%$address%' or address like '%$hmdaddress1%' or address like '%$hmdaddress2%' or address like '%$hmdaddress3%')";
  770. }
  771. //数据排序
  772. $order_str = "id desc";
  773. if(empty($page))
  774. {
  775. $start = 0;
  776. $perpage = 1;
  777. }
  778. else
  779. {
  780. $start = ($page - 1)*$perpage;
  781. }
  782. //取得信息列表
  783. $info_list = $this->customer->find_all($where,'id,shop,source,name,email,address,phone,count,typetime',$order_str,$start,$perpage);
  784. foreach ($info_list as $key=>$value)
  785. {
  786. $shop = $this->shop->read($value['shop']);
  787. $info_list[$key]['shop'] = $shop['shopname'];
  788. $source = $this->typeclass->read($value['source']);
  789. $info_list[$key]['source'] = $source['title'];
  790. if($value['typetime'] > 0)
  791. {
  792. $info_list[$key]['typetime'] = date('Y-m-d',$value['typetime']);
  793. }
  794. else
  795. {
  796. $info_list[$key]['typetime'] = '无';
  797. }
  798. }
  799. $total = $this->customer->find_count($where);
  800. $pagenum = ceil($total/$perpage);
  801. $over = $total-($start+$perpage);
  802. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'a'=>$hmdaddress1);
  803. echo json_encode($rows);exit;
  804. }
  805. if(isset($post['s']))
  806. {
  807. $id_arr = $this->input->post('s');
  808. $id_arr = explode(',',$id_arr);
  809. if(!$id_arr)
  810. {
  811. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  812. }
  813. //循环删除记录
  814. foreach ($id_arr as $v)
  815. {
  816. $this->customer->remove($v);
  817. }
  818. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  819. }
  820. $wlshop = $this->shop->find_all('1=1');
  821. $this->data['wlshop'] = $wlshop;
  822. $this->_Template('customer_black_cx',$this->data);
  823. }
  824. //添加
  825. public function _add()
  826. {
  827. $user = $this->user->get_api($_SESSION['api']);
  828. if($user)
  829. {
  830. $fgshop = "";$sid = "";
  831. $user = explode('|',trim($user['shop'],'|'));
  832. foreach ($user as $value)
  833. {
  834. $fgshop .= " shop = ".$value." or";
  835. $sid .= " id = ".$value." or";
  836. }
  837. }
  838. $post = $this->input->post(NULL, TRUE);
  839. if(isset($post['shop']))
  840. {
  841. $post['shop'] = $this->input->post('shop',true);
  842. $post['source'] = $this->input->post('source',true);
  843. $post['level'] = $this->input->post('level',true);
  844. $post['country'] = $this->input->post('country',true);
  845. $name = $this->input->post('name',true);
  846. $post['name'] = str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$name);
  847. $post['phone'] = $this->input->post('phone',true);
  848. $email = $this->input->post('email',true);
  849. $post['email'] = str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$email);
  850. $post['province'] = $this->input->post('province',true);
  851. $post['city'] = $this->input->post('city',true);
  852. //$post['street'] = $this->input->post('street',true);
  853. $address = $this->input->post('address',true);
  854. $post['address'] = str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$address);
  855. //$post['address2'] = $this->input->post('address2',true);
  856. $post['count'] = $this->input->post('count',true);
  857. $post['time'] = time();
  858. $str = $post['phone'];
  859. if(!$post['shop'])
  860. {
  861. echo json_encode(array('msg'=>'店铺不能为空!','success'=>false));exit;
  862. }
  863. preg_match_all('/[0-9]/u',$str,$result);
  864. $numphone = join('',$result[0]);
  865. $post['numphone'] = $numphone;
  866. $post['zhcx'] = $post['shop'].'-'.$post['email'];
  867. $kh = $this->customer->get_email($post['email'],$post['shop']);
  868. if($kh)
  869. {
  870. echo json_encode(array('msg'=>'此客户已存在!','success'=>false));exit;
  871. }
  872. if($this->customer->insert($post))
  873. {
  874. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  875. }
  876. else
  877. {
  878. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  879. }
  880. }
  881. $country = $this->country->find_all('1=1','id,name','name asc');
  882. $this->data['country'] = $country;
  883. $wlshop = $this->shop->find_all("type = 269 and (".rtrim($sid,'or').")");
  884. $this->data['wlshop'] = $wlshop;
  885. $this->_Template('customer_add',$this->data);
  886. }
  887. //修改
  888. public function _edit($arg_array)
  889. {
  890. $user = $this->user->get_api($_SESSION['api']);
  891. if($user)
  892. {
  893. $fgshop = "";$sid = "";
  894. $user = explode('|',trim($user['shop'],'|'));
  895. foreach ($user as $value)
  896. {
  897. $fgshop .= " shop = ".$value." or";
  898. $sid .= " id = ".$value." or";
  899. }
  900. }
  901. $post = $this->input->post(NULL, TRUE);
  902. if(isset($post['id']))
  903. {
  904. $id = $this->input->post('id',true);
  905. $us = $this->customer->read($id);
  906. $post['shop'] = $this->input->post('shop',true);
  907. $post['source'] = $this->input->post('source',true);
  908. $post['level'] = $this->input->post('level',true);
  909. $post['country'] = $this->input->post('country',true);
  910. $name = $this->input->post('name',true);
  911. $post['name'] = str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$name);
  912. $post['phone'] = $this->input->post('phone',true);
  913. $email = $this->input->post('email',true);
  914. $post['email'] = str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$email);
  915. $post['province'] = $this->input->post('province',true);
  916. $post['city'] = $this->input->post('city',true);
  917. //$post['street'] = $this->input->post('street',true);
  918. $address = $this->input->post('address',true);
  919. $post['address'] = str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$address);
  920. //$post['address2'] = $this->input->post('address2',true);
  921. $post['type'] = $this->input->post('type',true);
  922. $post['count'] = $this->input->post('count',true);
  923. $str = $post['phone'];
  924. preg_match_all('/[0-9]/u',$str,$result);
  925. $numphone = join('',$result[0]);
  926. $post['numphone'] = $numphone;
  927. $post['zhcx'] = $post['shop'].'-'.$post['email'];
  928. if($this->customer->save($post,$id))
  929. {
  930. echo json_encode(array('msg'=>'操作成功!','success'=>true));exit;
  931. }
  932. else
  933. {
  934. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  935. }
  936. }
  937. $arg_array = $arg_array[0];
  938. $customer = $this->customer->read($arg_array);
  939. $this->data['customer'] = $customer;
  940. $country = $this->country->find_all('1=1','id,name','name asc');
  941. $this->data['country'] = $country;
  942. $wlshop = $this->shop->find_all("type = 269 and (".rtrim($sid,'or').")");
  943. $this->data['wlshop'] = $wlshop;
  944. if($customer['email'] != '0' && $customer['email'] != '' && $customer['email'] != '无')
  945. {
  946. $fdata = $this->fullorder->find_all('email = "'.$customer['email'].'" and shop = "'.$customer['shop'].'" and mergeid = 0','orderinfo,state,product,name,email,dtime,shouldmoney','id desc');
  947. foreach ($fdata as $k=>$v)
  948. {
  949. $d = $this->fullorder->get_orderinfo($v['orderinfo']);
  950. $fdata[$k]['orderinfo'] = "<a href='/fullorder/readonly/".$d['id']."'>".$v['orderinfo']."</a>";
  951. $typeclass = $this->typeclass->read($v['state']);
  952. $fdata[$k]['state'] = $typeclass['spare'];
  953. $fdata[$k]['dtime'] = date('Y-m-d',$v['dtime']);
  954. }
  955. $this->data['data'] = $fdata;
  956. }
  957. $this->_Template('customer_edit',$this->data);
  958. }
  959. //删除
  960. public function _del()
  961. {
  962. $post = $this->input->post(NULL, TRUE);
  963. if(isset($post['s']))
  964. {
  965. $id_arr = $this->input->post('s');
  966. $id_arr = explode(',',$id_arr);
  967. if(!$id_arr)
  968. {
  969. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  970. }
  971. //循环删除记录
  972. $a=0;
  973. foreach ($id_arr as $v)
  974. {
  975. $customer = $this->customer->read($v);
  976. if($customer['email'] != '0' && $customer['email'] != '' && $customer['email'] != '无')
  977. {
  978. $fdata = $this->fullorder->find_count('email = "'.$customer['email'].'" and shop = "'.$customer['shop'].'" and mergeid = 0');
  979. }
  980. if($fdata > 0)
  981. {
  982. $a++;
  983. continue;
  984. }
  985. else
  986. {
  987. $this->customer->remove($v);
  988. }
  989. }
  990. if($a > 0)
  991. {
  992. echo json_encode(array('del'=>$id_arr,'msg'=>'无订单客户删除成功,有订单的客户无法删除!','success'=>true));
  993. }
  994. else
  995. {
  996. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  997. }
  998. }
  999. }
  1000. //操作
  1001. public function _change()
  1002. {
  1003. $post = $this->input->post(NULL, TRUE);
  1004. if(isset($post['type']))
  1005. {
  1006. $type = $this->input->post('type',true);
  1007. $id = $this->input->post('id',true);
  1008. $count = $this->input->post('count',true);
  1009. if($this->customer->save(array('type'=>$type,'count'=>$count,'typetime'=>time()),$id))
  1010. {
  1011. echo json_encode(array('msg'=>'操作成功!','success'=>true));exit;
  1012. }
  1013. else
  1014. {
  1015. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  1016. }
  1017. }
  1018. }
  1019. //修改客户分类
  1020. public function _mdedit($arg_array)
  1021. {
  1022. $user = $this->user->get_api($_SESSION['api']);
  1023. if($user)
  1024. {
  1025. $uu = $user;
  1026. $fgshop = "";$sid = "";
  1027. $u = $user;
  1028. $user = explode('|',trim($user['shop'],'|'));
  1029. foreach ($user as $value)
  1030. {
  1031. $fgshop .= " shop = ".$value." or";
  1032. $sid .= " id = ".$value." or";
  1033. }
  1034. }
  1035. $post = $this->input->post(NULL, TRUE);
  1036. if(isset($post['shop']))
  1037. {
  1038. $fpcount = $this->input->post('fpcount',true);
  1039. if(!$fpcount)
  1040. {
  1041. echo json_encode(array('msg'=>'需要先清理浏览器缓存,刷新当前页面后再试!','success'=>false));exit;
  1042. }
  1043. $customerid = $this->input->post('customerid',true);
  1044. $shop = $this->input->post('shop',true);
  1045. $sp = $this->shop->read($shop);
  1046. $num = $this->fullorder->find_count('shop = "'.$sp['id'].'" and gtime = "'.date('Ymd',time()).'"');
  1047. $post['source'] = 1;//订单类型:1.线下订单2.PC3.手机
  1048. $post['state'] = 207;//订单状态:207等待发货
  1049. $post['review'] = 2;//审核状态:1.未送审2.待审核3.不通过4取消重审5.审核通过6.自动通过
  1050. $post['print'] = 1;//打印状态:1.不可打印2.未打印3.已打印
  1051. $post['library'] = 1;//出库状态:1.未出库2.已出库3.已退库
  1052. $post['libraryconfirm'] = 1;//出库确认:1.不允许2.允许
  1053. $post['link'] = $sp['link'];
  1054. $post['issku'] = $sp['sku'];
  1055. if($post['print'] != 3)
  1056. {
  1057. $post['librarynot'] = "订单未打印,未审核或未通过";//不能出库原因
  1058. }
  1059. $orderinfo = $this->input->post('orderinfo',true);
  1060. $post['shop'] = $sp['id'];
  1061. $post['user'] = $sp['shopuser'];
  1062. $post['number'] = $sp['shortname'].'-'.substr(date('ymd',time()),1).'-'.(substr(strval($num+1+1000),1,3));//编号
  1063. if($orderinfo != "")
  1064. {
  1065. $ordefin = $this->fullorder->get_orderinfo($orderinfo);
  1066. if($ordefin)
  1067. {
  1068. echo json_encode(array('msg'=>'订单号重复!','success'=>false));exit;
  1069. }
  1070. else
  1071. {
  1072. $post['orderinfo'] = $orderinfo;
  1073. }
  1074. }
  1075. else
  1076. {
  1077. $post['orderinfo'] = $sp['id'].date('ymdHis',time()).rand(0,1);//订单号
  1078. }
  1079. // if(empty($post['paypal'])){
  1080. // echo json_encode(array('msg'=>'交易号不可为空!','success'=>false));exit;
  1081. // }
  1082. if($post['paypal'] != '')
  1083. {
  1084. $pp = $this->fullorder->get_paypal($post['paypal']);
  1085. if($pp)
  1086. {
  1087. echo json_encode(array('msg'=>'此交易号的订单已存在!','success'=>false));exit;
  1088. }
  1089. }
  1090. $post['client'] = $this->input->post('client',true);//客户名称
  1091. $btime = $this->input->post('buytime',true);//付款时间
  1092. $post['buytime'] = strtotime($btime);//时间转UX
  1093. $post['dtime'] = time();//订单时间
  1094. $post['gtime'] = date('Ymd',time());//格式化时间
  1095. $post['pay'] = $this->input->post('pay',true);//支付方式
  1096. $post['capital'] = $this->input->post('capital',true);//资金状态
  1097. $post['type'] = $this->input->post('warehouse',true);//发货仓库
  1098. $post['currency'] = $this->input->post('currency',true);//币种
  1099. $currency = $this->typeclass->read($post['currency']);
  1100. $post['currencytitle'] = $currency['title'];//币种名称
  1101. $post['freight'] = $this->input->post('freight',true);//运费
  1102. $post['expressmoney'] = $this->input->post('expressmoney',true);//物流金额
  1103. $post['shouldmoney'] = $this->input->post('shouldmoney',true);//应收金额
  1104. $post['skje'] = $post['shouldmoney'];//收款金额
  1105. $product = $this->input->post('product');//产品名称
  1106. $product = str_replace(array('%26','%2B'),array('&','+'),$product);
  1107. $post['product'] = preg_replace('/( | | |\s)/',' ',$product);
  1108. $orderremarks = $this->input->post('orderremarks');//订单备注
  1109. $orderremarks = str_replace(array('%26','%2B'),array('&','+'),$orderremarks);
  1110. $post['orderremarks'] = preg_replace('/( | | |\s)/',' ',$orderremarks);
  1111. $shipremarks = $this->input->post('shipremarks');//仓库品名
  1112. $shipremarks = str_replace(array('%26','%2B'),array('&','+'),$shipremarks);//仓库品名
  1113. $post['shipremarks'] = preg_replace('/( | | |\s)/',' ',$shipremarks);
  1114. $post['email'] = $this->input->post('email',true);//邮箱
  1115. $name = $this->input->post('name',true);//名称
  1116. $post['name'] = preg_replace('/( | | |\s)/',' ',$name);
  1117. $post['phone'] = $this->input->post('phone',true);//电话
  1118. $post['phone'] = preg_replace('/\D/s','',$post['phone']);
  1119. $post['country'] = $this->input->post('country',true);//国家
  1120. $ct = $this->country->read($post['country']);//国家
  1121. $post['al'] = $ct['lb'];//国家二字码
  1122. $post['province'] = $this->input->post('province',true);//省、州
  1123. $post['province'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['province']); //替换开头空字符
  1124. $post['province'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['province']); //替换结尾空字符
  1125. $post['city'] = $this->input->post('city',true);//城市
  1126. $post['city'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['city']); //替换开头空字符
  1127. $post['city'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['city']); //替换结尾空字符
  1128. $post['zipcode'] = $this->input->post('zipcode',true);//邮编
  1129. $post['zipcode'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['zipcode']); //替换开头空字符
  1130. $post['zipcode'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['zipcode']); //替换结尾空字符
  1131. $post['address'] = $this->input->post('address',true);//地址
  1132. $post['printtype'] = $this->input->post('printtype',true);//打印类型
  1133. $fpdata = $this->input->post('fpdata');//购买产品内容
  1134. $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
  1135. $post['fpdata'] = $fpdata;
  1136. $post['sbpm'] = $this->input->post('sbpm',true);//申报品名
  1137. $post['zwpm'] = $this->input->post('zwpm',true);//中文品名
  1138. $post['ts'] = $this->input->post('ts',true);//条数
  1139. $post['dtsbjz'] = $this->input->post('dtsbjz',true);//单条申报价
  1140. $post['zsbjz'] = $this->input->post('zsbjz',true);//总申报价
  1141. $post['zzl'] = $this->input->post('zzl',true);//总重量
  1142. $post['zjs'] = $this->input->post('zjs',true);//总件数
  1143. $post['express'] = $this->input->post('express',true);//快递公司
  1144. $post['printtype'] = $this->input->post('printtype',true);//打印类型
  1145. $post['quantity'] = $this->input->post('quantity',true);//数量
  1146. $post['paypal'] = $this->input->post('paypal',true);//支付号
  1147. $post['guarantee'] = $this->input->post('guarantee',true);//卖家保障
  1148. $post['msg'] = $this->input->post('msg',true);//发送留言类型
  1149. $post['ioss'] = $this->input->post('ioss',true);
  1150. $post['sbpm'] = $this->input->post('sbpm',true);
  1151. $pay = $this->pay->get_typeclass($post['pay']);
  1152. $yga = $post['shouldmoney'];
  1153. $post['budget'] = 0;
  1154. if($pay)
  1155. {
  1156. $ygc = $pay['estimaterate'];//预估到账公式
  1157. $ifbudget = eval("return $yga*1.$ygc;");
  1158. $post['estimaterate'] = $pay['estimaterate'];
  1159. if($ifbudget > 0)
  1160. {
  1161. $post['budget'] = eval("return $yga*1.$ygc;");//预估到帐金额
  1162. }
  1163. }
  1164. else
  1165. {
  1166. $ygb = $sp['estimaterate'];//店铺默认到账公式
  1167. $ifbudget = eval("return $yga*1.$ygb;");
  1168. $post['estimaterate'] = $sp['estimaterate'];
  1169. if($ifbudget > 0)
  1170. {
  1171. $post['budget'] = eval("return $yga*1.$ygb;");//预估到帐金额
  1172. }
  1173. }
  1174. $baddress = $this->input->post('baddress',true);
  1175. $saddress = $this->input->post('saddress',true);
  1176. $baddress = array_reverse(explode(',',$baddress));
  1177. $saddress = array_reverse(explode(',',$saddress));
  1178. $bar = '';$sar = '';
  1179. $cr = $this->country->read($post['country']);
  1180. $baddress[1] = $cr['lb'];
  1181. $saddress[1] = $cr['lb'];
  1182. $baddress = array_reverse($baddress);
  1183. $saddress = array_reverse($saddress);
  1184. for($i=0;$i<count($baddress);$i++)
  1185. {
  1186. $bar .= $baddress[$i].',';
  1187. }
  1188. for($i=0;$i<count($saddress);$i++)
  1189. {
  1190. $sar .= $saddress[$i].',';
  1191. }
  1192. $post['baddress'] = rtrim($bar,',');//卖家保障
  1193. $post['saddress'] = rtrim($sar,',');//卖家保障
  1194. $whlabel = $this->input->post('whlabel',true);
  1195. if($post['express'] == 2 && (stripos($post['name'],'&') !== false || stripos($post['name'],"'") !== false))
  1196. {
  1197. echo json_encode(array('msg'=>'USPS收件人或公司名不可用特殊符号!','success'=>false));exit;
  1198. }
  1199. if(strlen($post['client']) > 35 || strlen($post['name']) > 35)//收件人姓名或公司名不允许超过35位
  1200. {
  1201. echo json_encode(array('msg'=>'收件人姓名或公司名不可超过35个字符!','success'=>false));exit;
  1202. }
  1203. if(($post['express'] == '5' || $post['express'] == '24' || $post['express'] == '42' || $post['express'] == '31') && $post['country'] != 192)
  1204. {
  1205. echo json_encode(array('msg'=>'非美国无法选择Fedex、DHL官方-美国!','success'=>false));exit;
  1206. }
  1207. if($post['express'] == '3' && $post['country'] != 192 && $post['country'] != 35)
  1208. {
  1209. echo json_encode(array('msg'=>'非美国和加拿大无法选择UPS!','success'=>false));exit;
  1210. }
  1211. if($post['express'] == '3' && $post['country'] == 35 && $post['zsbjz'] > 20)
  1212. {
  1213. echo json_encode(array('msg'=>'UPS加拿大最高申报不可超过20','success'=>false));exit;
  1214. }
  1215. if($post['express'] == '2' && $post['warehouse'] != 5)
  1216. {
  1217. echo json_encode(array('msg'=>'非美国仓无法选择USPS!','success'=>false));exit;
  1218. }
  1219. if($post['express'] == '99' && $post['bx'] > 0)
  1220. {
  1221. echo json_encode(array('msg'=>'此物流不允许购买保险','success'=>false));exit;
  1222. }
  1223. if($post['express'] == 42 && $post['sbpm'] != 'Human Hair Wigs' && $post['sbpm'] != 'Human Hair Goods')//$post['express'] == 3 ||
  1224. {
  1225. echo json_encode(array('msg'=>'此快递方式必须选择Human Hair Wigs/Human Hair Goods!','success'=>false));exit;
  1226. }
  1227. if($post['express'] == 24 && $post['sbpm'] != 'Hair Sample' && $post['sbpm'] != 'Human Hair Wigs' && $post['sbpm'] != 'Human Hair Goods')//$post['express'] == 3 ||
  1228. {
  1229. echo json_encode(array('msg'=>'此快递方式必须选择Hair Sample/Human Hair Wigs/Human Hair Goods!','success'=>false));exit;
  1230. }
  1231. if($post['country'] != 192 && $post['express'] == 1 && $post['sbpm'] != 'Synthetic Hair Wigs' && $post['sbpm'] != 'Synthetic Hair Goods')//$post['express'] == 3 ||
  1232. {
  1233. echo json_encode(array('msg'=>'非美国选择官方DHL必须选择Synthetic Hair Wigs/Synthetic Hair Goods','success'=>false));exit;
  1234. }
  1235. if($post['pay'] == '22' && ($post['paypal'] == '' || $post['guarantee'] == ''))
  1236. {
  1237. echo json_encode(array('msg'=>'交易号和卖家保障必须填写','success'=>false));exit;
  1238. }
  1239. if($post['pay'] == '23' && $post['paypal'] == '')
  1240. {
  1241. echo json_encode(array('msg'=>'交易号必须填写','success'=>false));exit;
  1242. }
  1243. if(empty($post['paypal'])){
  1244. echo json_encode(array('msg'=>'交易号必须填写','success'=>false));exit;
  1245. }
  1246. $express = $this->express->read($post['express']);
  1247. if($post['zsbjz'] > $express['sbjz'])
  1248. {
  1249. echo json_encode(array('msg'=>'总申报价值不可超出'.$express['sbjz'],'success'=>false));exit;
  1250. }
  1251. if($post['shouldmoney'] > $express['shouldmoney'] && $express['shouldmoney'] != 0)
  1252. {
  1253. echo json_encode(array('msg'=>'订单金额不可超出'.$express['shouldmoney'],'success'=>false));exit;
  1254. }
  1255. if($express['ioss'] == 1 && $post['ioss'] == '')
  1256. {
  1257. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  1258. }
  1259. if(strlen($post['address']) > $express['addresssize'] || strlen($post['address2']) > $express['addresssize'])
  1260. {
  1261. echo json_encode(array('msg'=>'此快递方地址不可超出'.$express['addresssize'].'个字符','success'=>false));exit;
  1262. }
  1263. if(strlen($post['address']) < 5)
  1264. {
  1265. echo json_encode(array('msg'=>'地址不可留空!','success'=>false));exit;
  1266. }
  1267. if($post['express'] == '2' && $post['zzl'] > '16' && $post['js'] == '0')
  1268. {
  1269. echo json_encode(array('msg'=>'重量大于16不可按Ground Advantage提交!','success'=>false));exit;
  1270. }
  1271. if($post['express'] == '2' && isset($post['js']) && $post['js'] == '0'&& $post['qm'] == '1')
  1272. {
  1273. echo json_encode(array('msg'=>'Ground Advantage不可使用签名服务!','success'=>false));exit;
  1274. }
  1275. if(($post['express'] == '3' || $post['express'] == '42' || $post['express'] == '24') && $post['shouldmoney'] < 1)
  1276. {
  1277. echo json_encode(array('msg'=>'零金额订单不可发 UPS/DHL官方-美国/Fedex(杭州)','success'=>false));exit;
  1278. }
  1279. if($post['express'] == '42' && $post['zsbjz'] < 1)
  1280. {
  1281. echo json_encode(array('msg'=>'零申报金额不可发 DHL官方-美国','success'=>false));exit;
  1282. }
  1283. if($post['express'] == '6' && $post['province'] == '')
  1284. {
  1285. echo json_encode(array('msg'=>'选择DPEX必须填写州信息','success'=>false));exit;
  1286. }
  1287. //仅独立站 地址美国对电话 10或者11位进行判断
  1288. if($post['country'] == 192){
  1289. if((strlen($post['phone'])!= 10) && (strlen($post['phone'])!= 11)){
  1290. echo json_encode(array('msg'=>'美国电话号码应为10/11位!','success'=>false));exit;
  1291. }
  1292. }
  1293. /**
  1294. $post['saddress']
  1295. if($post['printtype'] == 1)//如果是运单
  1296. {
  1297. $post['productdescription'] = $this->input->post('productdescription',true);
  1298. $post['customs'] = $this->input->post('customs',true);
  1299. }
  1300. **/
  1301. //开始注释 xyxg
  1302. /**
  1303. $warehousenew = $this->warehouse->read($post['type']);
  1304. $ft = array();
  1305. $ftdata = explode('|',rtrim($fpcount,'|'));
  1306. foreach ($ftdata as $va)
  1307. {
  1308. $ftitle = '';
  1309. $va = explode('-',trim($va,'-'));
  1310. foreach ($va as $v)
  1311. {
  1312. $v = $this->typeclass->read($v);
  1313. $ftitle .= $v['title'].' ';
  1314. }
  1315. $ft[] = rtrim($ftitle,' ');
  1316. }
  1317. $kcyz = $this->whlabel->get_kc($post['state'],$post['state'],$warehousenew['zd'],$warehousenew['ys'],$post['type'],$whlabel,$fpcount,$ft,$post['number'],$shop);//新添加订单老状态state和新状态state一样,不用走删除占用步奏
  1318. if($kcyz['t'] > '0')
  1319. {
  1320. echo $kcyz['m'];exit;
  1321. }
  1322. else
  1323. {
  1324. if($this->fullorder->insert($post))
  1325. {
  1326. $cusnum = $this->customer->read($customerid);
  1327. $this->customer->save(array('num'=>$cusnum['num']+1,'time'=>$post['buytime']),$customerid);
  1328. echo json_encode(array('msg'=>'下单成功','success'=>true));exit;
  1329. }
  1330. else
  1331. {
  1332. echo json_encode(array('msg'=>'下单失败,请重试','success'=>false));exit;
  1333. }
  1334. }
  1335. //结束注释
  1336. **/
  1337. $dtctitle = array();
  1338. $dictionaries = $this->typeclass->find_all();
  1339. foreach ($dictionaries as $v)
  1340. {
  1341. $dtctitle[$v['id']] = array($v['title'],$v['bqsku']);
  1342. }
  1343. $fpdata = $post['fpdata'];
  1344. if(stripos($fpdata,'-128-') !== false || stripos($fpdata,'-127-') !== false)
  1345. {
  1346. $dfp = explode(';',trim($fpdata,';'));
  1347. $fdata = '';
  1348. foreach ($dfp as $k=>$v)
  1349. {
  1350. $ptitleb = '';
  1351. $fp = explode('|',trim($v,'|'));
  1352. $fp0 = explode(',',$fp[0]);
  1353. if(isset($fp0[1]))
  1354. {
  1355. $fp1 = explode('-',trim($fp0[1],'-'));
  1356. }
  1357. else
  1358. {
  1359. $fp1 = explode('-',trim($fp[0],'-'));
  1360. }
  1361. foreach ($fp1 as $vv)
  1362. {
  1363. $ptitleb .= isset($dtctitle[$vv])?$dtctitle[$vv][0].' ':'';
  1364. }
  1365. if(isset($fp0[1]))
  1366. {
  1367. $ptitleb .= $dtctitle[$fp0[0]][1].'inch ';
  1368. $fp[1] = $ptitleb;
  1369. }
  1370. $fdata .= implode("|",$fp).";";
  1371. }
  1372. $fpdata = $fdata;
  1373. }
  1374. $warehouse = $this->warehouse->read($post['type']);
  1375. if($warehouse['bdcountry'] != 0 && $post['country'] != $warehouse['bdcountry'])
  1376. {
  1377. echo json_encode(array('msg'=>'当前国家无法选择'.$warehouse['title'].'!','success'=>false));exit;
  1378. }
  1379. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$post['shop'],$post['number'],$whlabel,$fpdata);
  1380. if($kcyz['t'] > '0')
  1381. {
  1382. echo $kcyz['m'];exit;
  1383. }
  1384. else if($kcyz['fpdata'] != '')
  1385. {
  1386. $post['whlabel'] = $kcyz['whlabel'];
  1387. $post['fpdata'] = $kcyz['fpdata'];
  1388. }
  1389. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  1390. $post['sfxh'] = $fl['sfxh'];
  1391. $post['ckfl'] = $fl['ckfl'];
  1392. //查询净重开始
  1393. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  1394. //查询净重结束
  1395. $cusnum = $this->customer->read($customerid);
  1396. $this->customer->save(array('num'=>$cusnum['num']+1,'time'=>$post['buytime']),$customerid);
  1397. unset($post['id']);
  1398. $this->fullorder->insert($post);
  1399. echo json_encode(array('msg'=>'下单成功','success'=>true));exit;
  1400. }
  1401. $arg_array = $arg_array[0];//用户ID
  1402. $customer = $this->customer->read($arg_array);//用户信息
  1403. $this->data['customer'] = $customer;
  1404. $country = $this->country->find_all('1=1','id,name','name asc');//国家
  1405. $this->data['country'] = $country;
  1406. $express = $this->express->find_all();//物流商
  1407. $this->data['express'] = $express;
  1408. $bm = $this->country->read($customer['country']);
  1409. $this->data['bm'] = $bm;
  1410. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1411. $this->data['wlshop'] = $wlshop;
  1412. $this->data['user'] = $u['userid'];
  1413. $this->_Template('customer_mdedit',$this->data);
  1414. }
  1415. //上传excel
  1416. public function _excela()
  1417. {
  1418. $dir = '/data/excel/'.date('Ymd',time()).'/';
  1419. $config['upload_path'] = '.'.$dir ;
  1420. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  1421. $config['allowed_types'] = 'xls|xlsx';
  1422. $config['max_size'] = 10240;
  1423. $this->load->library('upload', $config);
  1424. $this->upload->initialize($config);
  1425. if ($this->upload->do_upload('userfile'))
  1426. {
  1427. $full_path = $dir.$this->upload->data('file_name');
  1428. $fileName = '.' . $full_path;
  1429. if (!file_exists($fileName))
  1430. {
  1431. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  1432. }
  1433. else
  1434. {
  1435. require_once "./data/excel/PHPExcel/IOFactory.php";
  1436. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  1437. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  1438. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  1439. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  1440. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  1441. ++$column;//如果列数大于26行
  1442. $list = array();
  1443. for ($i = 2; $i <= $row; $i++) // 行数循环
  1444. {
  1445. $data = array();
  1446. for ($c = 'A'; $c != $column; $c++) // 列数循环
  1447. {
  1448. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  1449. }
  1450. $list[] = $data;
  1451. }
  1452. }
  1453. $i = 0;
  1454. $this->db->trans_begin();
  1455. foreach ($list as $key=>$value)
  1456. {
  1457. $value['1'] = $value['1']?str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$value['1']):'';
  1458. $value['7'] = $value['7']?str_replace('/( | | |\s)/','',$value['7']):'';
  1459. if($value['7'] == "" || $value['11'] == "")
  1460. {
  1461. $i++;
  1462. continue;
  1463. }
  1464. else
  1465. {
  1466. $value['7'] = str_replace('/( | | |\s)/','',$value['7']);
  1467. }
  1468. $shop = $this->shop->get_name($value['9']);
  1469. if(!$shop)
  1470. {
  1471. $i++;
  1472. continue;
  1473. }
  1474. if($value['11'] == 2)
  1475. {
  1476. $repeat = $this->customer->get_address($value['1']);//只判断地址
  1477. }
  1478. else
  1479. {
  1480. $repeat = $this->customer->find_all('email = "'.$value[7].'" and shop = "'.$shop['id'].'"');//只判断邮箱
  1481. }
  1482. /* 判断邮箱和地址
  1483. if($value['1'] == "" || $value['1'] == " ")
  1484. {
  1485. if($value['7'] == "" || $value['7'] == " ")
  1486. {
  1487. $repeat = 1;
  1488. }
  1489. else
  1490. {
  1491. $repeat = $this->customer->get_email($value['7']);
  1492. }
  1493. }
  1494. else
  1495. {
  1496. $repeat = $this->customer->get_address($value['1']);
  1497. }
  1498. */
  1499. if(isset($repeat[0]['type']))
  1500. {
  1501. if($repeat[0]['type'] == $value['11'])
  1502. {
  1503. $i++;
  1504. }
  1505. else if($repeat[0]['type'] != $value['11'])
  1506. {
  1507. $this->customer->save(array('type'=>$value['11']),$repeat[0]['id']);
  1508. }
  1509. }
  1510. else
  1511. {
  1512. $source = $this->typeclass->get_title($value['10']);
  1513. if($source)
  1514. {
  1515. $post['name'] = ($value['0'] && $value['0'] != 'NULL')?str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$value['0']):'';
  1516. $post['email'] = $value['7'];
  1517. if($value['5'] != '')
  1518. {
  1519. $country = $this->country->get_ename(str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$value['5']));
  1520. $post['country'] = $country['id'];
  1521. }
  1522. $post['level'] = $value['8']?$value['8']:5;
  1523. $post['phone'] = $value['6']?$value['6']:'';
  1524. $post['province'] = $value['3']?$value['3']:'';
  1525. $post['city'] = $value['2']?$value['2']:'';
  1526. $post['address'] = $value['1'];
  1527. $post['zipcode'] = $value['4']?$value['4']:'';
  1528. $post['shop'] = $shop['id'];
  1529. $post['source'] = $source['id'];
  1530. $post['type'] = $value['11'];
  1531. $val12 = $value['12']?$value['12']:'';
  1532. $post['count'] = $val12;
  1533. $str = $post['phone'];
  1534. preg_match_all('/[0-9]/u',$str,$result);
  1535. $numphone = join('',$result[0]);
  1536. $post['numphone'] = $numphone;
  1537. $this->customer->insert($post);
  1538. }
  1539. }
  1540. }
  1541. if ($this->db->trans_status() === FALSE)
  1542. {
  1543. $this->db->trans_commit();
  1544. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  1545. }
  1546. else
  1547. {
  1548. if(count($list) == $i)
  1549. {
  1550. $til = '导入全部失败!请检查导入信息';
  1551. }
  1552. else if(count($list) > $i && $i != 0)
  1553. {
  1554. $til = '部分导入成功!'.$i.'条信息有问题,请排查';
  1555. }
  1556. else if($i < 1)
  1557. {
  1558. $til = '导入成功!';
  1559. }
  1560. $this->db->trans_commit();
  1561. echo json_encode(array('msg'=>$til,'success'=>true));exit;
  1562. }
  1563. }
  1564. else
  1565. {
  1566. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  1567. }
  1568. }
  1569. public function _temuexcel()
  1570. {
  1571. $dir = '/data/excel/'.date('Ymd',time()).'/';
  1572. $config['upload_path'] = '.'.$dir ;
  1573. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  1574. $config['allowed_types'] = 'xls|xlsx';
  1575. $config['max_size'] = 10240;
  1576. $this->load->library('upload', $config);
  1577. $this->upload->initialize($config);
  1578. if ($this->upload->do_upload('userfile'))
  1579. {
  1580. $full_path = $dir.$this->upload->data('file_name');
  1581. $fileName = '.' . $full_path;
  1582. if (!file_exists($fileName))
  1583. {
  1584. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  1585. }
  1586. else
  1587. {
  1588. require_once "./data/excel/PHPExcel/IOFactory.php";
  1589. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  1590. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  1591. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  1592. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  1593. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  1594. ++$column;//如果列数大于26行
  1595. $list = array();
  1596. for ($i = 2; $i <= $row; $i++) // 行数循环
  1597. {
  1598. $data = array();
  1599. for ($c = 'A'; $c != $column; $c++) // 列数循环
  1600. {
  1601. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  1602. }
  1603. $list[] = $data;
  1604. }
  1605. }
  1606. $i = 0;
  1607. $gethl = $this->hl->get_hl();//获取即时汇率
  1608. $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');
  1609. $dtc = array();
  1610. foreach ($dictionaries as $v)
  1611. {
  1612. if(stripos($v['spare'],'|') !== false)//如果有多个值
  1613. {
  1614. $v['spare'] = explode('|',$v['spare']);
  1615. foreach ($v['spare'] as $k=>$vs)
  1616. {
  1617. if(stripos($v['zh'],'|') !== false)
  1618. {
  1619. $vzh = explode('|',$v['zh']);
  1620. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  1621. }
  1622. else
  1623. {
  1624. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  1625. }
  1626. }
  1627. }
  1628. else
  1629. {
  1630. $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
  1631. }
  1632. }
  1633. $dk = array();
  1634. $dictionaries2 = $this->typeclass->find_all();
  1635. foreach ($dictionaries2 as $v)
  1636. {
  1637. $dtctitle[$v['id']] = $v['title'];
  1638. $dk[$v['id']] = $v['bqsku'];
  1639. }
  1640. /* 匹配结束 */
  1641. /* 价格加入 */
  1642. $money = array();
  1643. $productdescribe = $this->productdescribe->find_all('1=1');
  1644. foreach ($productdescribe as $v)
  1645. {
  1646. $money[$v['number']] = array();
  1647. }
  1648. /* 价格加入 */
  1649. /* 匹配ID加入 */
  1650. $int = array();
  1651. $intdata = $this->typeclass->find_all('classid=14','id,spare');
  1652. foreach ($intdata as $v)
  1653. {
  1654. $v['spare'] = explode('|',$v['spare']);
  1655. $int[$v['id']] = $v['spare'][0];
  1656. }
  1657. /* 匹配ID加入 */
  1658. $zjsku = array();
  1659. $shopsku = $this->shopsku->find_all();
  1660. foreach ($shopsku as $val)
  1661. {
  1662. $ss = explode(',',trim($val['shop'],','));
  1663. foreach ($ss as $v)
  1664. {
  1665. if(isset($zjsku[$v]))
  1666. {
  1667. $zjsku[$v] .= ','.trim($val['sku'],',');
  1668. }
  1669. else
  1670. {
  1671. $zjsku[$v] = trim($val['sku'],',');
  1672. }
  1673. }
  1674. }
  1675. /* 匹配ID结束 */
  1676. $this->db->trans_begin();
  1677. foreach ($list as $key=>$value)
  1678. {
  1679. $addtess = ($value['15']!='--'?$value['15'].' ':'').($value['14']!='--'?$value['14'].' ':'').$value['13'];
  1680. $addtess = str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$addtess);
  1681. $repeat = $this->customer->find_all('phone = "'.$value[11].'" and address = "'.($value['15']!='--'?$value['15'].' ':'').($value['14']!='--'?$value['14'].' ':'').$value['13'].'" and shop = 19');//判断电话地址
  1682. $sku = $value['8'];
  1683. $je = (isset($value['28']))?$value['28']:0;
  1684. // $value['29'] = str_replace('/','-',$value['29']);
  1685. // $dtime = strtotime($value['29']);
  1686. if(!empty($value['29'])){
  1687. $value['29'] = str_replace('/','-',$value['29']);
  1688. $dtime = strtotime($value['29']);
  1689. if(empty($dtime)){
  1690. $dtime = time();
  1691. }
  1692. }else{
  1693. $dtime = time();
  1694. }
  1695. $post['name'] = ($value['10'] && $value['10'] != 'NULL')?str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$value['10']):'';
  1696. $post['email'] = $value['12'];
  1697. if($value['20'] != '')
  1698. {
  1699. $country = $this->country->get_ename(str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$value['20']));
  1700. $post['country'] = $country['id'];
  1701. }
  1702. $post['level'] = 4;
  1703. $post['phone'] = $value['11']?$value['11']:'';
  1704. $post['province'] = $value['18']?$value['18']:'';
  1705. $post['city'] = $value['17']?$value['17']:'';
  1706. $post['address'] = $addtess;
  1707. $post['zipcode'] = $value['19']?$value['19']:'';
  1708. $post['shop'] = 19;
  1709. $post['source'] = 2;
  1710. $post['type'] = 1;
  1711. $post['count'] = '';
  1712. $post['time'] = $dtime;
  1713. $str = $post['phone'];
  1714. preg_match_all('/[0-9]/u',$str,$result);
  1715. $numphone = join('',$result[0]);
  1716. $post['numphone'] = $numphone;
  1717. if(!isset($repeat[0]))
  1718. {
  1719. $this->customer->insert($post);
  1720. }
  1721. else
  1722. {
  1723. $this->customer->save(array('num'=>$repeat[0]['num']+1),$repeat[0]['id']);
  1724. }
  1725. $sbsku = '';
  1726. $whlabel = $this->whlabel->get_sku($sku);
  1727. if($whlabel)
  1728. {
  1729. $w = explode('-',trim($whlabel['features'],'-'));
  1730. foreach ($w as $v)
  1731. {
  1732. if(isset($dk[$v]))
  1733. {
  1734. $sbsku .= $dk[$v].'-';
  1735. }
  1736. }
  1737. }
  1738. $sbsku = trim($sbsku,'-');
  1739. $time = time();
  1740. $shop = $this->shop->read(19);
  1741. $ddpost['orderremarks'] = isset($value['30'])?$value['30']:'';
  1742. $ddpost['shop'] = $shop['id'];//店铺ID
  1743. $ddpost['user'] = $shop['shopuser'];//店铺负责人
  1744. $orderid = 0;
  1745. $ddpost['orderid'] = 0;
  1746. $ddpost['product'] = '';//产品名称
  1747. $ddpost['link'] = '';//产品链接
  1748. $ddpost['issku'] = $sku;
  1749. $ddpost['quantity'] = rtrim($value['3'],';');
  1750. $ddpost['clientremarks'] = '';//客户备注
  1751. //$ddpost['paypal'] = '';//交易号
  1752. $ddpost['guarantee'] = '';//卖家保障
  1753. $ddpost['parameter'] = '';//属性
  1754. $ddpost['shippingmethod'] = '';//用户选择快递方式及运费金额
  1755. $ddpost['source'] = 2;//订单类型
  1756. $ddpost['type'] = 1;//发货仓库
  1757. $ddpost['capital'] = 3;//资金支付状况,全部付款
  1758. $num = $this->fullorder->find_count('gtime = "'.date('Ymd',$dtime).'" and shop = 19');
  1759. $ddpost['number'] = $shop['shortname'].'-'.substr(date('ymd',$dtime),1).'-'.(substr(strval($num+1+1000),1,3));//编号
  1760. $ddpost['orderinfo'] = preg_replace('/[^0-9]/', '', $value['0']);//订单号
  1761. $d = $this->fullorder->get_orderinfo($ddpost['orderinfo']);
  1762. if(isset($d['id']))
  1763. {
  1764. $i++;
  1765. continue;
  1766. }
  1767. $ddpost['paypal'] = $ddpost['orderinfo'];
  1768. $ddpost['insurance'] = 0;//运输保险费用
  1769. $ddpost['baddress'] = '';
  1770. $ddpost['saddress'] = '';
  1771. $ddpost['country'] = $country['id'];//此国家的ID
  1772. $ddpost['al'] = $country['lb'];//联邦名称
  1773. $ddpost['bname'] = $post['name'];//名称
  1774. $ddpost['sname'] = $post['name'];//名称
  1775. $ddpost['client'] = $post['name'];//公司名称
  1776. $ddpost['name'] = $post['name'];//收件人名称
  1777. $ddpost['phone'] = $post['phone'];//收件人电话
  1778. $ddpost['email'] = $post['email'];//客户邮箱
  1779. $ddpost['zipcode'] = $post['zipcode'];//收件人邮编
  1780. $ddpost['province'] = $post['province'];//收件人省份
  1781. $ddpost['city'] = $post['city'];//收件人城市
  1782. $ddpost['address'] = $post['address'];//收件人地址
  1783. $ddpost['shouldmoney'] = $je;//应收金额
  1784. $ddpost['skje'] = $je;//收款金额
  1785. $ddpost['ismoney'] = '';//支付币种金额
  1786. $ddpost['shouldmoney'] = $je;//金额
  1787. $ddpost['budget'] = $je;//预估到帐金额
  1788. $ddpost['buytime'] = $dtime;//格式化付款时间
  1789. $ddpost['dtime'] = $dtime;//订单时间
  1790. $ddpost['gtime'] = date('Ymd',$dtime);//格式化订单时间
  1791. $ddpost['currencytitle'] = 'USD';//结算币种名称
  1792. $ddpost['currency'] = 219;//钱币ID
  1793. $ddpost['time'] = time();//同步时间
  1794. $ddpost['shopify'] = 0;//同步时间
  1795. $ddpost['hl'] = '6.4';//汇率
  1796. $matching = $this->api->matching($ddpost['quantity'],$sbsku,$dtc,$money,$int,$dtctitle,$shop);
  1797. $ddpost['shipremarks'] = $matching['title'];
  1798. $ddpost['cost'] = $matching['cost'];
  1799. $ddpost['purchase'] = $matching['purchase'];
  1800. $ddpost['fpdata'] = $matching['product'];
  1801. $ddpost['whlabel'] = $matching['whlabel'];
  1802. $ddpost['slpx'] = $matching['wcslpx'];
  1803. $ddpost['state'] = 207;
  1804. $ddpost['type'] = 17;
  1805. $this->fullorder->insert($ddpost);
  1806. }
  1807. if ($this->db->trans_status() === FALSE)
  1808. {
  1809. $this->db->trans_commit();
  1810. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  1811. }
  1812. else
  1813. {
  1814. if(count($list) == $i)
  1815. {
  1816. $til = '导入全部失败!请检查导入信息';
  1817. }
  1818. else if(count($list) > $i && $i != 0)
  1819. {
  1820. $til = '部分导入成功!'.$i.'条信息有问题,请排查';
  1821. }
  1822. else if($i < 1)
  1823. {
  1824. $til = '导入成功!';
  1825. }
  1826. $this->db->trans_commit();
  1827. echo json_encode(array('msg'=>$til,'success'=>true));exit;
  1828. }
  1829. }
  1830. else
  1831. {
  1832. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  1833. }
  1834. }
  1835. //代发客户导入
  1836. public function _daifakehuexcel()
  1837. {
  1838. $shopid = 0;
  1839. $user = $this->user->get_api($_SESSION['api']);
  1840. if($user)
  1841. {
  1842. $users = explode('|',trim($user['shop'],'|'));
  1843. if(count($users) == 1){
  1844. $shopid = $users[0];
  1845. }else{
  1846. echo json_encode(array('msg'=>"此账号不能用于该功能!",'success'=>true));exit;
  1847. }
  1848. }
  1849. if(empty($shopid)){
  1850. echo json_encode(array('msg'=>"系统无法识别店铺!",'success'=>true));exit;
  1851. }
  1852. $dir = '/data/excel/'.date('Ymd',time()).'/';
  1853. $config['upload_path'] = '.'.$dir ;
  1854. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  1855. $config['allowed_types'] = 'xls|xlsx';
  1856. $config['max_size'] = 10240;
  1857. $this->load->library('upload', $config);
  1858. $this->upload->initialize($config);
  1859. if ($this->upload->do_upload('userfile'))
  1860. {
  1861. $full_path = $dir.$this->upload->data('file_name');
  1862. $fileName = '.' . $full_path;
  1863. if (!file_exists($fileName))
  1864. {
  1865. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  1866. }
  1867. else
  1868. {
  1869. require_once "./data/excel/PHPExcel/IOFactory.php";
  1870. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  1871. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  1872. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  1873. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  1874. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  1875. ++$column;//如果列数大于26行
  1876. $list = array();
  1877. for ($i = 2; $i <= $row; $i++) // 行数循环
  1878. {
  1879. $data = array();
  1880. for ($c = 'A'; $c != $column; $c++) // 列数循环
  1881. {
  1882. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  1883. }
  1884. $list[] = $data;
  1885. }
  1886. }
  1887. $i = 0;
  1888. $gethl = $this->hl->get_hl();//获取即时汇率
  1889. $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');
  1890. $dtc = array();
  1891. foreach ($dictionaries as $v)
  1892. {
  1893. if(stripos($v['spare'],'|') !== false)//如果有多个值
  1894. {
  1895. $v['spare'] = explode('|',$v['spare']);
  1896. foreach ($v['spare'] as $k=>$vs)
  1897. {
  1898. if(stripos($v['zh'],'|') !== false)
  1899. {
  1900. $vzh = explode('|',$v['zh']);
  1901. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  1902. }
  1903. else
  1904. {
  1905. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  1906. }
  1907. }
  1908. }
  1909. else
  1910. {
  1911. $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
  1912. }
  1913. }
  1914. $dk = array();
  1915. $dictionaries2 = $this->typeclass->find_all();
  1916. foreach ($dictionaries2 as $v)
  1917. {
  1918. $dtctitle[$v['id']] = $v['title'];
  1919. $dk[$v['id']] = $v['bqsku'];
  1920. }
  1921. /* 匹配结束 */
  1922. /* 价格加入 */
  1923. $money = array();
  1924. $productdescribe = $this->productdescribe->find_all('1=1');
  1925. foreach ($productdescribe as $v)
  1926. {
  1927. $money[$v['number']] = array();
  1928. }
  1929. /* 价格加入 */
  1930. /* 匹配ID加入 */
  1931. $int = array();
  1932. $intdata = $this->typeclass->find_all('classid=14','id,spare');
  1933. foreach ($intdata as $v)
  1934. {
  1935. $v['spare'] = explode('|',$v['spare']);
  1936. $int[$v['id']] = $v['spare'][0];
  1937. }
  1938. /* 匹配ID加入 */
  1939. $zjsku = array();
  1940. $shopsku = $this->shopsku->find_all();
  1941. foreach ($shopsku as $val)
  1942. {
  1943. $ss = explode(',',trim($val['shop'],','));
  1944. foreach ($ss as $v)
  1945. {
  1946. if(isset($zjsku[$v]))
  1947. {
  1948. $zjsku[$v] .= ','.trim($val['sku'],',');
  1949. }
  1950. else
  1951. {
  1952. $zjsku[$v] = trim($val['sku'],',');
  1953. }
  1954. }
  1955. }
  1956. /* 匹配ID结束 */
  1957. $this->db->trans_begin();
  1958. foreach ($list as $key=>$value)
  1959. {
  1960. if(empty($value[0])){
  1961. continue;
  1962. }
  1963. $addtess = $value[7].$value[6];
  1964. $addtess = str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$addtess);
  1965. $repeat = $this->customer->find_all('phone = "'.$value[4].'" and address = "'.$addtess.'" and shop = '.$shopid);//判断电话地址
  1966. $sku = $value['2'];
  1967. $je = (isset($value['12']))?$value['12']:0;
  1968. if(!empty($value[13])){
  1969. $value['13'] = str_replace('/','-',$value['13']);
  1970. $dtime = strtotime($value['13']);
  1971. if(empty($dtime)){
  1972. $dtime = time();
  1973. }
  1974. }else{
  1975. $dtime = time();
  1976. }
  1977. $post['name'] = (!empty($value[3]))?str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$value['3']):'';
  1978. $post['email'] = $value['5'];
  1979. if($value['11'] != '')
  1980. {
  1981. $country = $this->country->get_ename(str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$value['11']));
  1982. $post['country'] = $country['id'];
  1983. }
  1984. $post['level'] = 4;
  1985. $post['phone'] = $value['4']?$value['4']:'';
  1986. $post['province'] = $value['9']?$value['9']:'';
  1987. $post['city'] = $value['8']?$value['8']:'';
  1988. $post['address'] = $addtess;
  1989. $post['zipcode'] = $value['10']?$value['10']:'';
  1990. $post['shop'] = $shopid;
  1991. $post['source'] = 10;
  1992. $post['type'] = 1;
  1993. $post['count'] = '';
  1994. $post['time'] = $dtime;
  1995. $str = $post['phone'];
  1996. preg_match_all('/[0-9]/u',$str,$result);
  1997. $numphone = join('',$result[0]);
  1998. $post['numphone'] = $numphone;
  1999. if(!isset($repeat[0]))
  2000. {
  2001. $post['num'] = 1;
  2002. $this->customer->insert($post);
  2003. }
  2004. else
  2005. {
  2006. $this->customer->save(array('num'=>$repeat[0]['num']+1),$repeat[0]['id']);
  2007. }
  2008. $sbsku = '';
  2009. $whlabel = $this->whlabel->get_sku($sku);
  2010. if($whlabel)
  2011. {
  2012. $w = explode('-',trim($whlabel['features'],'-'));
  2013. foreach ($w as $v)
  2014. {
  2015. if(isset($dk[$v]))
  2016. {
  2017. $sbsku .= $dk[$v].'-';
  2018. }
  2019. }
  2020. }
  2021. $sbsku = trim($sbsku,'-');
  2022. $time = time();
  2023. $shop = $this->shop->read($shopid);
  2024. $ddpost['orderremarks'] = '';
  2025. $ddpost['shop'] = $shop['id'];//店铺ID
  2026. $ddpost['user'] = $shop['shopuser'];//店铺负责人
  2027. $orderid = 0;
  2028. $ddpost['orderid'] = 0;
  2029. $ddpost['product'] = '';//产品名称
  2030. $ddpost['link'] = '';//产品链接
  2031. $ddpost['issku'] = $sku;
  2032. $ddpost['quantity'] = rtrim($value['1'],';');
  2033. $ddpost['clientremarks'] = '';//客户备注
  2034. $ddpost['guarantee'] = '';//卖家保障
  2035. $ddpost['parameter'] = '';//属性
  2036. $ddpost['shippingmethod'] = '';//用户选择快递方式及运费金额
  2037. $ddpost['source'] = 2;//订单类型
  2038. $ddpost['type'] = 1;//发货仓库
  2039. $ddpost['capital'] = 3;//资金支付状况,全部付款
  2040. $num = $this->fullorder->find_count('gtime = "'.date('Ymd',$dtime).'" and shop = '.$shopid);
  2041. $ddpost['number'] = $shop['shortname'].'-'.substr(date('ymd',$dtime),1).'-'.(substr(strval($num+1+1000),1,3));//编号
  2042. $ddpost['orderinfo'] = preg_replace('/[^0-9]/', '', $value['0']);//订单号
  2043. $d = $this->fullorder->get_orderinfo($ddpost['orderinfo']);
  2044. if(isset($d['id']))
  2045. {
  2046. $i++;
  2047. continue;
  2048. }
  2049. $ddpost['paypal'] = $ddpost['orderinfo'];//交易号
  2050. $ddpost['insurance'] = 0;//运输保险费用
  2051. $ddpost['baddress'] = '';
  2052. $ddpost['saddress'] = '';
  2053. $ddpost['country'] = $country['id'];//此国家的ID
  2054. $ddpost['al'] = $country['lb'];//联邦名称
  2055. $ddpost['bname'] = $post['name'];//名称
  2056. $ddpost['sname'] = $post['name'];//名称
  2057. $ddpost['client'] = $post['name'];//公司名称
  2058. $ddpost['name'] = $post['name'];//收件人名称
  2059. $ddpost['phone'] = $post['phone'];//收件人电话
  2060. $ddpost['email'] = $post['email'];//客户邮箱
  2061. $ddpost['zipcode'] = $post['zipcode'];//收件人邮编
  2062. $ddpost['province'] = $post['province'];//收件人省份
  2063. $ddpost['city'] = $post['city'];//收件人城市
  2064. $ddpost['address'] = $post['address'];//收件人地址
  2065. $ddpost['shouldmoney'] = $je;//应收金额
  2066. $ddpost['skje'] = $je;//收款金额
  2067. $ddpost['ismoney'] = '';//支付币种金额
  2068. $ddpost['shouldmoney'] = $je;//金额
  2069. $ddpost['budget'] = $je;//预估到帐金额
  2070. $ddpost['buytime'] = $dtime;//格式化付款时间
  2071. $ddpost['dtime'] = $dtime;//订单时间
  2072. $ddpost['gtime'] = date('Ymd',$dtime);//格式化订单时间
  2073. $ddpost['currencytitle'] = 'USD';//结算币种名称
  2074. $ddpost['currency'] = 219;//钱币ID
  2075. $ddpost['time'] = time();//同步时间
  2076. $ddpost['shopify'] = 0;//同步时间
  2077. $ddpost['hl'] = '6.4';//汇率
  2078. $matching = $this->api->matching($ddpost['quantity'],$sbsku,$dtc,$money,$int,$dtctitle,$shop);
  2079. $ddpost['shipremarks'] = $matching['title'];
  2080. $ddpost['cost'] = $matching['cost'];
  2081. $ddpost['purchase'] = $matching['purchase'];
  2082. $ddpost['fpdata'] = $matching['product'];
  2083. $ddpost['whlabel'] = $matching['whlabel'];
  2084. $ddpost['slpx'] = $matching['wcslpx'];
  2085. $ddpost['state'] = 207;
  2086. $ddpost['type'] = 13;
  2087. $this->fullorder->insert($ddpost);
  2088. }
  2089. if ($this->db->trans_status() === FALSE)
  2090. {
  2091. $this->db->trans_commit();
  2092. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  2093. }
  2094. else
  2095. {
  2096. if(count($list) == $i)
  2097. {
  2098. $til = '导入全部失败!请检查导入信息';
  2099. }
  2100. else if(count($list) > $i && $i != 0)
  2101. {
  2102. $til = '部分导入成功!'.$i.'条信息有问题,请排查';
  2103. }
  2104. else if($i < 1)
  2105. {
  2106. $til = '导入成功!';
  2107. }
  2108. $this->db->trans_commit();
  2109. echo json_encode(array('msg'=>$til,'success'=>true));exit;
  2110. }
  2111. }
  2112. else
  2113. {
  2114. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  2115. }
  2116. }
  2117. public function _indexexcel()//通过计数,2020/02/21已校准
  2118. {
  2119. $user = $this->user->get_api($_SESSION['api']);
  2120. if($user)
  2121. {
  2122. $fgshop = "";$sid = "";
  2123. $users = explode('|',trim($user['shop'],'|'));
  2124. foreach ($users as $value)
  2125. {
  2126. $fgshop .= " shop = ".$value." or";
  2127. $sid .= " id = ".$value." or";
  2128. }
  2129. if($user['vip'] == 1)
  2130. {
  2131. $vip = 1;
  2132. }
  2133. else
  2134. {
  2135. $vip = 0;
  2136. }
  2137. }
  2138. else
  2139. {
  2140. $vip = 0;
  2141. }
  2142. $post = $this->input->post(NULL, TRUE);
  2143. if(isset($_GET['timetk']))
  2144. {
  2145. $shop = $this->input->get('shop',true);
  2146. $numphone = $this->input->get('numphone',true);
  2147. $name = $this->input->get('name',true);
  2148. $email = $this->input->get('email',true);
  2149. $address = $this->input->get('address',true);
  2150. $level = $this->input->get('level',true);
  2151. $num = $this->input->get('num',true);
  2152. $country = $this->input->get('country',true);
  2153. $excelid = $this->input->get('sid',true);
  2154. $timetk = $this->input->get('timetk',true);
  2155. $timetj = $this->input->get('timetj',true);
  2156. $timetk = strtotime($timetk);
  2157. $timetj = strtotime($timetj);
  2158. $where = "1=1 and type = 1 and (".rtrim($fgshop,'or').")";
  2159. if($shop)
  2160. {
  2161. $where .= " and shop = '$shop'";
  2162. }
  2163. if($numphone)
  2164. {
  2165. $where .= " and numphone = '$numphone'";
  2166. }
  2167. if($name)
  2168. {
  2169. $where .= " and name like '%$name%'";
  2170. }
  2171. if($email)
  2172. {
  2173. $where .= " and email like '%$email%'";
  2174. }
  2175. if($level)
  2176. {
  2177. $where .= " and level = '$level'";
  2178. }
  2179. if($country)
  2180. {
  2181. $where .= " and country = '$country'";
  2182. }
  2183. if($address)
  2184. {
  2185. $where .= " and address like '%$address%'";
  2186. }
  2187. if($num > 0 && $num < 10 && $num != '2a')
  2188. {
  2189. $where .= " and num = '$num'";
  2190. }
  2191. else if($num > 9)
  2192. {
  2193. $where .= " and num > '9'";
  2194. }
  2195. else if($num == '2a')
  2196. {
  2197. $where .= " and num > '1'";
  2198. }
  2199. else
  2200. {
  2201. $where .= " and num >= '0'";
  2202. }
  2203. if($timetk && $timetj)
  2204. {
  2205. $where .= " and ((time > '$timetk' and time < '$timetj') or time = '0')";
  2206. }
  2207. $xzid = '';
  2208. if($excelid)
  2209. {
  2210. $excelid = explode(',',trim($excelid,','));
  2211. foreach ($excelid as $key=>$value)
  2212. {
  2213. $xzid .= " id = ".$value." or";
  2214. }
  2215. $where .= " and (".rtrim($xzid,'or').")";;
  2216. }
  2217. //数据排序
  2218. $order_str = "id desc";
  2219. $numdata = array();
  2220. if(empty($page))
  2221. {
  2222. $start = 0;
  2223. $perpage = 1;
  2224. }
  2225. else
  2226. {
  2227. $start = ($page - 1)*$perpage;
  2228. }
  2229. //取得信息列表
  2230. $info_list = $this->customer->find_all($where,'shop,name,email,phone,address,city,province,zipcode,country,level,money,num,numphone,time,count',$order_str);
  2231. foreach ($info_list as $key=>$value)
  2232. {
  2233. $shop = $this->shop->read($value['shop']);
  2234. $info_list[$key]['shop'] = $shop['shopname'];
  2235. if($value['country'] != 0)
  2236. {
  2237. $country = $this->country->read($value['country']);
  2238. $info_list[$key]['country'] = $country['name'];
  2239. }
  2240. else
  2241. {
  2242. $info_list[$key]['country'] = "未知";
  2243. }
  2244. if($value['level'] == 1)
  2245. {
  2246. $info_list[$key]['level'] = "网红";
  2247. }
  2248. else if($value['level'] == 2)
  2249. {
  2250. $info_list[$key]['level'] = "批发";
  2251. }
  2252. else if($value['level'] == 3)
  2253. {
  2254. $info_list[$key]['level'] = "店铺转线下";
  2255. }
  2256. else if($value['level'] == 4)
  2257. {
  2258. $info_list[$key]['level'] = "线下其他";
  2259. }
  2260. else if($value['level'] == 5)
  2261. {
  2262. $info_list[$key]['level'] = "店内客户";
  2263. }
  2264. if($value['time'] != 0)
  2265. {
  2266. $info_list[$key]['time'] = date('Y-m-d',$value['time']);
  2267. }
  2268. else
  2269. {
  2270. $info_list[$key]['time'] = "无";
  2271. }
  2272. $info_list[$key]['numphone'] = ($value['num'] > 0 && $value['money'] > 0)?sprintf("%01.2f",$value['money']/$value['num']):0;
  2273. if(isset($value['email']) && $user['excelpass'] == '1')
  2274. {
  2275. $emailpass = $this->setting->get_excelpass($value['email']);
  2276. $info_list[$key]['email'] = $emailpass;
  2277. }
  2278. if(isset($value['phone']) && $user['excelpass'] == '1')
  2279. {
  2280. $phone = $this->setting->get_excelpass($value['phone']);
  2281. $info_list[$key]['phone'] = $phone;
  2282. }
  2283. }
  2284. $title = "按条件导出";
  2285. $titlename = "<table border=1>
  2286. <tr align='center'>
  2287. <td>店铺</td>
  2288. <td>名称</td>
  2289. <td>邮箱</td>
  2290. <td>电话</td>
  2291. <td>详细地址</td>
  2292. <td>城市</td>
  2293. <td>省/州</td>
  2294. <td>邮编</td>
  2295. <td>国家</td>
  2296. <td>类型</td>
  2297. <td>总额</td>
  2298. <td>成交次数</td>
  2299. <td>客单价</td>
  2300. <td>最后购买日期</td>
  2301. <td>备注</td>
  2302. </tr>
  2303. </table>";
  2304. $filename = $title.".xls";
  2305. $tail = "";
  2306. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  2307. }
  2308. }
  2309. //下载excel
  2310. public function _excel()
  2311. {
  2312. if(isset($_GET['excel']))
  2313. {
  2314. if(isset($_SESSION['api']))
  2315. {
  2316. $user = $this->user->get_api($_SESSION['api']);
  2317. $usp = $user;
  2318. $fgshop = "";$sid = "";
  2319. $user = explode('|',trim($user['shop'],'|'));
  2320. foreach ($user as $value)
  2321. {
  2322. $fgshop .= " shop = ".$value." or";
  2323. $sid .= " id = ".$value." or";
  2324. }
  2325. }
  2326. $dowid = $this->input->get('a');
  2327. $wid = "";
  2328. if($dowid != "")
  2329. {
  2330. $id_arr = explode(',',rtrim($dowid,','));
  2331. $wid .= " id = 0 or";
  2332. foreach ($id_arr as $v)
  2333. {
  2334. $wid .= " id = '$v' or";
  2335. }
  2336. $wid = " and".rtrim($wid,'or');
  2337. }
  2338. $excel = $this->input->get('excel',true);
  2339. $page = $this->input->get('page',true);
  2340. $perpage = $this->input->get('perpage',true);
  2341. $shop = $this->input->get('shop',true);
  2342. $name = $this->input->get('name',true);
  2343. $country = $this->input->get('country',true);
  2344. $email = $this->input->get('email',true);
  2345. $address = $this->input->get('address',true);
  2346. $level = $this->input->get('level',true);
  2347. $num = $this->input->get('num',true);
  2348. $timetk = $this->input->get('timetk',true);
  2349. $timetj = $this->input->get('timetj',true);
  2350. $timetk = strtotime($timetk);
  2351. $timetj = strtotime($timetj);
  2352. $where = "1 = 1 and (".rtrim($fgshop,'or').")";
  2353. if($shop)
  2354. {
  2355. $where .= " and shop = '$shop'";
  2356. }
  2357. if($name)
  2358. {
  2359. $where .= " and name like '%$name%'";
  2360. }
  2361. if($email)
  2362. {
  2363. $where .= " and email like '%$email%'";
  2364. }
  2365. if($country)
  2366. {
  2367. $where .= " and country = '$country'";
  2368. }
  2369. if($level)
  2370. {
  2371. $where .= " and level = '$level'";
  2372. }
  2373. if($num != '')
  2374. {
  2375. $nu = 1;
  2376. if($num > 9)
  2377. {
  2378. $where .= " and num > '9'";
  2379. }
  2380. else if($num == '2a')
  2381. {
  2382. $where .= " and num > '1'";
  2383. }
  2384. else
  2385. {
  2386. $where .= " and num = '$num'";
  2387. }
  2388. }
  2389. else
  2390. {
  2391. $nu = 2;
  2392. $where .= " and num >= '0'";
  2393. }
  2394. if($address)
  2395. {
  2396. $where .= " and address like '%$address%'";
  2397. }
  2398. if($timetk && $timetj)
  2399. {
  2400. $where .= " and time > '$timetk' and time < '$timetj'";
  2401. }
  2402. $where .= " and type = 1";//白名单用户
  2403. $info_list = array();
  2404. if($excel == 2) //老客户列表
  2405. {
  2406. //$where = str_replace("level = '$level'","level > '1'",$where);
  2407. $info_list = $this->customer->find_all($where.$wid,'name,email,country,time,num,money,numphone','time desc');
  2408. foreach ($info_list as $key=>$value)
  2409. {
  2410. $info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  2411. if($value['country'] != 0)
  2412. {
  2413. $country = $this->country->read($value['country']);
  2414. $info_list[$key]['country'] = $country['ename'];
  2415. }
  2416. else
  2417. {
  2418. $info_list[$key]['country'] = '';
  2419. }
  2420. if($value['num'] > 0){
  2421. $info_list[$key]['numphone'] = sprintf("%01.2f",$value['money']/$value['num']);
  2422. }else{
  2423. $info_list[$key]['numphone'] = "<span style='color:red'>num异常".$value['num']."</span>";
  2424. }
  2425. if(isset($value['email']) && $usp['excelpass'] == '1')
  2426. {
  2427. $emailpass = $this->setting->get_excelpass($value['email']);
  2428. $info_list[$key]['email'] = $emailpass;
  2429. }
  2430. }
  2431. /**
  2432. foreach ($info_list as $key=>$value)
  2433. {
  2434. $value['time'] = date('Y-m-d H:i:s',$value['time']);
  2435. $d = $this->fullorder->find_count('email = "'.$value['email'].'" and shop = "'.$value['shop'].'" and mergeid = 0','orderinfo,state,product,name,email,dtime,shouldmoney','time desc');
  2436. if($d > 1)
  2437. {
  2438. $info_list[] = $v;
  2439. }
  2440. }
  2441. **/
  2442. $fzh = "<td>客户名</td><td>客户邮箱</td><td>客户国家</td><td>最近一次下单时间</td><td>购买次数</td><td>购买总金额</td><td>客单价</td>";
  2443. $title = "老客户列表";
  2444. }
  2445. else
  2446. {
  2447. $fdata = $this->customer->find_all($where.$wid,'email,shop','time desc');
  2448. foreach ($fdata as $key=>$value)
  2449. {
  2450. $d = $this->fullorder->find_all('email = "'.$value['email'].'" and shop = "'.$value['shop'].'" and mergeid = 0 and extra_status = 0 ','orderinfo,state,product,shipremarks,name,email,country,dtime,shouldmoney','time desc');
  2451. if($nu == 2)
  2452. {
  2453. if(count($d) > 1)
  2454. {
  2455. foreach ($d as $k=>$v)
  2456. {
  2457. $v['dtime'] = date('Y-m-d H:i:s',$v['dtime']);
  2458. $typeclass = $this->typeclass->read($v['state']);
  2459. $v['state'] = $typeclass['spare'];
  2460. if($v['country'] != 0)
  2461. {
  2462. $country = $this->country->read($v['country']);
  2463. $v['country'] = $country['ename'];
  2464. }
  2465. else
  2466. {
  2467. $v['country'] = '';
  2468. }
  2469. if(isset($v['email']) && $usp['excelpass'] == '1')
  2470. {
  2471. $emailpass = $this->setting->get_excelpass($v['email']);
  2472. $v['email'] = $emailpass;
  2473. }
  2474. $info_list[] = $v;
  2475. }
  2476. }
  2477. }
  2478. else
  2479. {
  2480. foreach ($d as $k=>$v)
  2481. {
  2482. $v['dtime'] = date('Y-m-d H:i:s',$v['dtime']);
  2483. $typeclass = $this->typeclass->read($v['state']);
  2484. $v['state'] = $typeclass['spare'];
  2485. if($v['country'] != 0)
  2486. {
  2487. $country = $this->country->read($v['country']);
  2488. $v['country'] = $country['ename'];
  2489. }
  2490. else
  2491. {
  2492. $v['country'] = '';
  2493. }
  2494. if(isset($v['email']) && $usp['excelpass'] == '1')
  2495. {
  2496. $emailpass = $this->setting->get_excelpass($v['email']);
  2497. $v['email'] = $emailpass;
  2498. }
  2499. $info_list[] = $v;
  2500. }
  2501. }
  2502. }
  2503. $fzh = "<td>订单号</td><td>订单状态</td><td>产品名</td><td>仓库品名</td><td>客户名</td><td>客户邮箱</td><td>客户国家</td><td>下单时间</td><td>订单金额</td>";
  2504. $title = "老客户订单列表";
  2505. }
  2506. $titlename = "<table border=1>
  2507. <tr>"
  2508. .$fzh.
  2509. "</tr>
  2510. </table>";
  2511. $tail = "\n";
  2512. $filename = $title.'-'.date('Ymd',time()).".xls";
  2513. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  2514. }
  2515. }
  2516. //下载excel模板
  2517. public function _bankdown()
  2518. {
  2519. if(isset($_GET['bankdown']))
  2520. {
  2521. $numphone = $this->input->post('numphone',true);
  2522. $xtime = $this->input->get('xtime',true);
  2523. //$where = "1=1 and type = 2 and (".rtrim($fgshop,'or').")";
  2524. $shop = $this->input->get('shop',true);
  2525. $name = $this->input->get('name',true);
  2526. $email = $this->input->get('email',true);
  2527. $address = $this->input->get('address',true);
  2528. $type = $this->input->get('type',true);
  2529. $id = $this->input->get('id',true);
  2530. $timetk = $this->input->get('timetk',true);
  2531. $timetj = $this->input->get('timetj',true);
  2532. $timetk = strtotime($timetk);
  2533. $timetj = strtotime($timetj);
  2534. if($type)
  2535. {
  2536. $where = "type = '$type'";
  2537. }
  2538. else
  2539. {
  2540. $where = "id != 0";
  2541. }
  2542. if($id)
  2543. {
  2544. $id = explode('|',trim($id,'|'));
  2545. $downid = '';
  2546. foreach ($id as $value)
  2547. {
  2548. $downid .= " id = ".$value." or";
  2549. }
  2550. $where .= " and (".rtrim($downid,'or').")";
  2551. }
  2552. if(!$shop)
  2553. {
  2554. $user = $this->user->get_api($_SESSION['api']);
  2555. $usp = $user;
  2556. $fgshop = "";$sid = "";
  2557. $user = explode('|',trim($user['shop'],'|'));
  2558. foreach ($user as $value)
  2559. {
  2560. $fgshop .= " shop = ".$value." or";
  2561. $sid .= " id = ".$value." or";
  2562. }
  2563. $where .= " and (".rtrim($fgshop,'or').")";
  2564. }
  2565. else
  2566. {
  2567. $where .= " and shop = '$shop'";
  2568. }
  2569. if($email)
  2570. {
  2571. $where .= " and email = '$email'";
  2572. }
  2573. if($name)
  2574. {
  2575. $where .= " and name = '$name'";
  2576. }
  2577. if($address)
  2578. {
  2579. $where .= " and address = '$address'";
  2580. }
  2581. if($xtime)
  2582. {
  2583. $where .= " and typetime > '$timetk' and typetime < '$timetj'";
  2584. }
  2585. $info_list = $this->customer->find_all($where,'name,address,city,province,zipcode,country,phone,email,level,shop,source,type,count,typetime');
  2586. foreach ($info_list as $key=>$v)
  2587. {
  2588. $country = $this->country->read($v['country']);
  2589. $info_list[$key]['country'] = $country['ename'];
  2590. if($v['level'] == 1)
  2591. {
  2592. $info_list[$key]['level'] = '网红';
  2593. }
  2594. else if($v['level'] == 2)
  2595. {
  2596. $info_list[$key]['level'] = '批发';
  2597. }
  2598. else if($v['level'] == 3)
  2599. {
  2600. $info_list[$key]['level'] = '店铺转线下';
  2601. }
  2602. else if($v['level'] == 4)
  2603. {
  2604. $info_list[$key]['level'] = '线下其他';
  2605. }
  2606. else if($v['level'] == 5)
  2607. {
  2608. $info_list[$key]['level'] = '店内';
  2609. }
  2610. else
  2611. {
  2612. $info_list[$key]['level'] = '未知';
  2613. }
  2614. if($v['typetime'] != 0)
  2615. {
  2616. $info_list[$key]['typetime'] = date('Y-m-d',$v['typetime']);
  2617. }
  2618. else
  2619. {
  2620. $info_list[$key]['typetime'] = "无";
  2621. }
  2622. $shop = $this->shop->read($v['shop']);
  2623. $info_list[$key]['shop'] = $shop['shopname'];
  2624. $source = $this->typeclass->read($v['source']);
  2625. $info_list[$key]['source'] = $source['title'];
  2626. }
  2627. $titledata = array('姓名','详细地址','城市','省/州','邮编','国家','电话','邮箱','类型(1:网红2:批发3:店铺转线下4:线下其他5:店内)','所属店铺(必须ERP已有店铺)','来源(数据字典的户来源需存在)','黑白名单(白名单填1或黑名单填2)','备注','客户分类时间');
  2628. $fzh = "";
  2629. foreach ($titledata as $v)
  2630. {
  2631. $fzh .= "<td>".$v."</td>";
  2632. }
  2633. $title = "客户导出";
  2634. $titlename = "<table border=1>
  2635. <tr>"
  2636. .$fzh.
  2637. "</tr>
  2638. </table>";
  2639. $tail = "\n";
  2640. $filename = $title.".xls";
  2641. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  2642. }
  2643. }
  2644. //下载excel模板
  2645. public function _down()
  2646. {
  2647. if(isset($_GET['excela']))
  2648. {
  2649. $title = "客户导入模板";
  2650. $titledata = array(array('姓名','详细地址','城市','省/州','邮编','国家','电话','邮箱','类型(1:网红2:批发3:店铺转线下4:线下其他5:店内)','所属店铺(必须ERP已有店铺)','来源(数据字典的户来源需存在)','黑白名单(白名单填1或黑名单填2)','备注'),array('lekia waites','700 Sandy Plains rd suite b14','marietta','Georgia','30066','United States','4047322519','lwaites@ccccare.com','5','supernovahair','独立站','1','备注'));
  2651. $filename = $title.".xls";
  2652. $this->customer->get_excel($titledata,$filename);
  2653. }
  2654. }
  2655. public function _newold()
  2656. {
  2657. if(isset($_SESSION['api']))
  2658. {
  2659. $user = $this->user->get_api($_SESSION['api']);
  2660. $usp = $user;
  2661. $fgshop = "";$sid = "";
  2662. $usersp = explode('|',trim($user['shop'],'|'));
  2663. foreach ($usersp as $value)
  2664. {
  2665. $fgshop .= " shop = ".$value." or";
  2666. $sid .= " id = ".$value." or";
  2667. }
  2668. }
  2669. $post = $this->input->post(NULL, TRUE);
  2670. if(isset($post['timek']))
  2671. {
  2672. $new = array();$old = array();$time=array();
  2673. $timek = $this->input->post('timek',true);
  2674. $timej = $this->input->post('timej',true);
  2675. $k = strtotime($timek)-24*3600;//少一天为增加选择开始天时间
  2676. $j = strtotime($timej);
  2677. $n = ($j-$k)/(24*3600);
  2678. if($n < 1)
  2679. {
  2680. $n = 1;
  2681. }
  2682. for($i=1;$i<$n;$i++)
  2683. {
  2684. $nnum = 0;$onum = 0;
  2685. $t = $j-($n*24*60*60)+($i*24*60*60);
  2686. $time[] = date('Y-m-d',$t);
  2687. $ct = strtotime(date('Ymd',$t));
  2688. $ctj = strtotime(date('Ymd',$t+24*3600));
  2689. $info_list = $this->fullorder->find_all("mergeid = '0' and dtime > '$ct' and dtime < '$ctj' and (".rtrim($fgshop,'or').")");
  2690. foreach ($info_list as $value)
  2691. {
  2692. if($value['email'] != '0' && $value['email'] != '' && $value['email'] != '无')
  2693. {
  2694. $gnum = $this->fullorder->find_count("email = '".$value['email']."' and shop = '".$value['shop']."' and mergeid = 0");
  2695. if($gnum >1)
  2696. {
  2697. $onum += 1;
  2698. }
  2699. else
  2700. {
  2701. $nnum += 1;
  2702. }
  2703. }
  2704. else
  2705. {
  2706. $nnum += 1;
  2707. }
  2708. }
  2709. $new[] = $nnum;
  2710. $old[] = $onum;
  2711. }
  2712. echo @json_encode(array('time'=>$time,'cnew'=>$new,'cold'=>$old,'success'=>true));exit;
  2713. }
  2714. $this->_Template('customer_newold',$this->data);
  2715. }
  2716. }