Customer.php 95 KB

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