Customer.php 95 KB

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