Manage.php 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073
  1. <?php
  2. namespace Mail\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. #代理商日数据统计
  7. public function day_api(){
  8. $day = Dever::input('day');
  9. if($day){
  10. $start = strtotime($day);
  11. $end = $start+86400-1;
  12. }else{
  13. $start=mktime(0,0,0,date('m'),date('d'),date('Y'));
  14. $end = $start+86400-1;
  15. }
  16. $time = Dever::maketime(date('Y-m-d'),'00:00:00');
  17. $where = array();
  18. $where['fstart'] = $start;
  19. $where['fend'] = $end;
  20. $w = array();
  21. $fstart = Dever::input('start', date('Y-m-01', $start));
  22. $w['fstart'] = Dever::maketime($fstart . ' 00:00:00');
  23. $w['fend'] = strtotime(date('Y-m-d 23:59:59',
  24. strtotime($fstart."+1 month - 1 day")));;
  25. $data = array();
  26. $data['start'] = date('Y-m-d',$start);
  27. $data['day'] = $this->content_api($where,1);
  28. $data['money'] = $this->c_api($where);
  29. $data['week'] = $this->zhou_api($start);
  30. $data['all'] = $this->content_api($w,2);
  31. $data['all_money'] = $this->c_api($w);
  32. $data['time'] = $this->day_time_api($w);
  33. $data['data'] = Dever::json_encode($data['time']);
  34. $data['money_time'] = $this->money_time_api($w);
  35. $data['qu_money'] = Dever::json_encode($data['money_time']);
  36. $data['xzhou'] = $this->button_day_api($w,1);
  37. $data['zhou'] = Dever::json_encode($data['xzhou']);
  38. return Dever::render('census', $data);
  39. }
  40. public function zhou_api($time='',$format="Y-m-d"){
  41. $time = $time != '' ? $time : time();
  42. $week = date('w', $time);
  43. $date = [];
  44. if($week == 0){
  45. $week = 7;
  46. }
  47. for ($i=1; $i<=7; $i++){
  48. $date[$i] = date($format ,strtotime( '+' . $i-$week .' days', $time));
  49. }
  50. $start = strtotime($date[1]);
  51. $end = strtotime($date[7])+86400-1;
  52. $where = array();
  53. $where['fstart'] = $start;
  54. $where['fend'] = $end;
  55. $data = array();
  56. $data['week'] = date('Y.m.d',$start).' - '.date('Y.m.d',$end);
  57. $data['all'] = $this->content_api($where,2);
  58. $data['all_money'] = $this->c_api($where);
  59. return $data;
  60. }
  61. #按时间统计
  62. public function content_api($where,$type){
  63. $data = array();
  64. if($type == 2){
  65. $data['time'] = date('Y.m',$where['fstart']);
  66. }elseif($type == 1){
  67. $data['time'] = date('Y.m.d',$where['fstart']);
  68. }
  69. #确认代理商订单数
  70. $where['status'] = 4;
  71. $data['num'] = Dever::db('agent/order')->getNum($where);
  72. #确认订单总费用
  73. $money = Dever::db('agent/order')->getCash($where);
  74. if($money['total']){
  75. $data['money'] = $money['total'];
  76. }else{
  77. $data['money'] = 0;
  78. }
  79. #确认代理费
  80. $dl_money = Dever::db('agent/order')->getDailiCash($where);
  81. if($dl_money['total']){
  82. $data['dl_money'] = $dl_money['total'];
  83. }else{
  84. $data['dl_money'] = 0;
  85. }
  86. #确认软件服务费
  87. $soft_money = Dever::db('agent/order')->getSoftCash($where);
  88. if($soft_money['total']){
  89. $data['soft_money'] = $soft_money['total'];
  90. }else{
  91. $data['soft_money'] = 0;
  92. }
  93. $wh['status'] = 3;
  94. $wh['fstart'] = $where['fstart'];
  95. $wh['fend'] = $where['fend'];
  96. $cash = Dever::db('agent/soft_cash')->getTotal($wh);
  97. if($cash['total']){
  98. $data['cash'] = $cash['total'];
  99. }else{
  100. $data['cash'] = 0;
  101. }
  102. $data['soft_cash'] = $data['soft_money'] + $data['cash'];
  103. #期权价值
  104. $option_money = Dever::db('agent/order')->getOptionPrice($where);
  105. if($option_money['total']){
  106. $data['option_money'] = $option_money['total'];
  107. }else{
  108. $data['option_money'] = 0;
  109. }
  110. return $data;
  111. }
  112. #各角色的金额,数量,原始期权价值,软件服务费
  113. public function c_api($where){
  114. $role = Dever::db('setting/role')->getAll(array('id'=>1,'state'=>1));
  115. foreach($role as $k => $v){
  116. $where['role'] = $v['id'];
  117. $data[$k]['name'] = $v['name'];
  118. $where['status'] = 2;
  119. $data[$k]['num'] = Dever::db('agent/member')->getNum($where);
  120. $where['status'] = 4;
  121. $dl = Dever::db('agent/order')->getSum($where);
  122. if($dl['total']){
  123. $data[$k]['money'] = $dl['total'];
  124. }else{
  125. $data[$k]['money'] = 0;
  126. }
  127. #期权价值:
  128. $option_money = Dever::db('agent/order')->getOptionPrice($where);
  129. if($option_money['total']){
  130. $data[$k]['option_money'] = $option_money['total'];
  131. }else{
  132. $data[$k]['option_money'] = 0;
  133. }
  134. #软件服务费
  135. $soft_money = Dever::db('agent/order')->getSoftCash($where);
  136. if($soft_money['total']){
  137. $data[$k]['soft_money'] = $soft_money['total'];
  138. }else{
  139. $data[$k]['soft_money'] = 0;
  140. }
  141. $wh['role'] = $v['id'];
  142. $wh['status'] = 3;
  143. $wh['fstart'] = $where['fstart'];
  144. $wh['fend'] = $where['fend'];
  145. $cash = Dever::db('agent/soft_cash')->getTotal($wh);
  146. if($cash['total']){
  147. $data[$k]['cash'] = $cash['total'];
  148. }else{
  149. $data[$k]['cash'] = 0;
  150. }
  151. }
  152. return $data;
  153. }
  154. #数据趋势
  155. public function day_time_api($w){
  156. $time = date('m',time()) - date('m',$w['fstart']);
  157. $start = date('Y-m-01',$w['fstart']);
  158. if($time<=0){
  159. $w['fend'] = time();
  160. }elseif($time>0){
  161. $w['fend'] = strtotime(date('Y-m-d 23:59:59',
  162. strtotime($start."+1 month - 1 day")));
  163. }
  164. $days = ($w['fend']-$w['fstart'])/86400+1;
  165. // 保存每天日期
  166. $day = array();
  167. $data = array();
  168. for($i=0; $i<$days; $i++){
  169. $day[] = array($w['fstart']+(86400*$i),$w['fstart']+(86400*$i)+86400);
  170. }
  171. $res = array();
  172. $res['num'] = array();
  173. foreach($day as $k => $v){
  174. $where['fstart'] = $v[0];
  175. $where['fend'] =$v[1]-1;
  176. $data[$k]['time'] = date('m.d',$v[0]);
  177. #确认代理商订单数
  178. $where['status'] = 4;
  179. $res['num'][] = Dever::db('agent/order')->getNum($where);
  180. }
  181. // print_R($where);die;
  182. $data = array();
  183. $data['name'] = '数量';
  184. $data['type'] = 'line';
  185. // $data['stack'] = 'Total';
  186. $data['data'] = $res['num'];
  187. return $data;
  188. }
  189. #金额趋势
  190. public function money_time_api($w){
  191. $time = date('m',time()) - date('m',$w['fstart']);
  192. $start = date('Y-m-01',$w['fstart']);
  193. if($time<=0){
  194. $w['fend'] = time();
  195. }elseif($time>0){
  196. $w['fend'] = strtotime(date('Y-m-d 23:59:59',
  197. strtotime($start."+1 month - 1 day")));
  198. }
  199. $days = ($w['fend']-$w['fstart'])/86400+1;
  200. // 保存每天日期
  201. $day = array();
  202. $data = array();
  203. for($i=0; $i<$days; $i++){
  204. $day[] = array($w['fstart']+(86400*$i),$w['fstart']+(86400*$i)+86400);
  205. }
  206. $res = array();
  207. $res['money'] = array();
  208. foreach($day as $k => $v){
  209. $where['fstart'] = $v[0];
  210. $where['fend'] =$v[1]-1;
  211. $data[$k]['time'] = date('m.d',$v[0]);
  212. #确认订单总费用
  213. $money = Dever::db('agent/order')->getCash($where);
  214. if($money['total']){
  215. $res['money'][] = $money['total'];
  216. }else{
  217. $res['money'][] = 0;
  218. }
  219. }
  220. $money = array();
  221. $money['name'] = '金额';
  222. $money['type'] = 'line';
  223. $money['data'] = $res['money'];
  224. return $money;
  225. }
  226. #趋势底部日期
  227. public function button_day_api($w,$type){
  228. $time = date('m',time()) - date('m',$w['fstart']);
  229. $start = date('Y-m-01',$w['fstart']);
  230. if($time<=0){
  231. $w['fend'] = time();
  232. }elseif($time>0){
  233. $w['fend'] = strtotime(date('Y-m-d 23:59:59',
  234. strtotime($start."+1 month - 1 day")));
  235. }
  236. $days = ($w['fend']-$w['fstart'])/86400+1;
  237. if($type ==1){
  238. $daysd = $days-1;
  239. }else{
  240. $daysd = $days;
  241. }
  242. // 保存每天日期
  243. $day = array();
  244. $data = array();
  245. for($i=0; $i<$daysd; $i++){
  246. $day[] = date('m.d',$w['fstart']+(86400*$i));
  247. }
  248. $data['type'] = 'category';
  249. $data['boundaryGap'] = false;
  250. $data['date'] = $day;
  251. return $day;
  252. }
  253. #代理商日统计
  254. public function index_api(){
  255. $title = '代理商日数据统计';
  256. $data = Dever::db('mail/feature')->find(array('key'=>'lib/cron.day'));
  257. $email = explode(',',$data['email_id']);
  258. foreach($email as $k => $v){
  259. $res[] = Dever::db('mail/email')->find(array('id'=>$v));
  260. }
  261. $content = $this->index_api();
  262. foreach($res as $key => $val){
  263. $this->send($val['email'], $val['name'], $title, $content);
  264. }
  265. }
  266. #代理商统计发送邮件
  267. public function send($email, $username, $title, $content)
  268. {
  269. $config = Dever::config('base', 'project')->email;
  270. Dever::apply('src/PHPMailer', 'email');
  271. Dever::apply('src/Exception', 'email');
  272. Dever::apply('src/SMTP', 'email');
  273. $mail = new \PHPMailer\PHPMailer\PHPMailer();
  274. $mail->isSMTP();
  275. //$mail->SMTPDebug = 2;
  276. $mail->CharSet = 'UTF-8';
  277. $mail->Host = $config['smtp'];
  278. $mail->Port = 465;
  279. $mail->SMTPSecure = 'ssl';
  280. $mail->SMTPAuth = true;
  281. $mail->Username = $config['username'];
  282. $mail->Password = $config['password'];
  283. $mail->setFrom($config['from'][0], '统计');
  284. $mail->addAddress($email, $username);
  285. $mail->Subject = "=?utf-8?B?" . base64_encode($title) . "?=";
  286. $mail->Body = $content;
  287. $mail->isHTML(true);
  288. //$mail->addAttachment($file);
  289. if (!$mail->send()) {
  290. Dever::alert("Mailer Error: " . $mail->ErrorInfo);
  291. } else {
  292. return 'ok';
  293. }
  294. }
  295. #期权统计
  296. public function option_api(){
  297. #主账户数量
  298. $data['account'] = Dever::db('option/account')->getCount(array('state'=>1));
  299. #所有数量
  300. $data['member'] = Dever::db('option/member')->getCount(array('state'=>1));
  301. #已认证完成
  302. $data['y_num'] = Dever::db('option/account')->getCount(array('audit'=>3,'state'=>1));
  303. #尚未任何交付的
  304. $data['no_num'] = Dever::db('option/bill_jiaofu')->getCount(array('status'=>2,'state'=>1));
  305. #原始期权待交付
  306. $yq_nonum = Dever::db('option/bill_jiaofu')->getCash(array('status'=>2,'type'=>2,'state'=>1));
  307. if($yq_nonum['total']){
  308. $data['yq_nonum'] = $yq_nonum['total'];
  309. }else{
  310. $data['yq_nonum'] = 0;
  311. }
  312. #原始期权已交付未发放
  313. $yq_nof = Dever::db('option/bill_jiaofu')->getCash(array('status'=>1,'type'=>2,'state'=>1));
  314. if($yq_nof['total']){
  315. $data['yq_nof'] = $yq_nof['total'];
  316. }else{
  317. $data['yq_nof'] = 0;
  318. }
  319. #原始期权已发放
  320. $yq_fnum = Dever::db('option/bill_fafang')->getCash(array('status'=>1,'type'=>2,'state'=>1));
  321. if($yq_fnum['total']){
  322. $data['yq_fnum'] = $yq_fnum['total'];
  323. }else{
  324. $data['yq_fnum'] = 0;
  325. }
  326. #期权待交付
  327. $q_nonum = Dever::db('option/bill_jiaofu')->getCash(array('status'=>2,'type'=>1,'state'=>1));
  328. if($q_nonum['total']){
  329. $data['q_nonum'] = $q_nonum['total'];
  330. }else{
  331. $data['q_nonum'] = 0;
  332. }
  333. #期权已交付未发放
  334. $q_nof = Dever::db('option/bill_jiaofu')->getCash(array('status'=>1,'type'=>1,'state'=>1));
  335. if($q_nof['total']){
  336. $data['q_nof'] = $q_nof['total'];
  337. }else{
  338. $data['q_nof'] = 0;
  339. }
  340. #期权已发放
  341. $q_fnum = Dever::db('option/bill_fafang')->getCash(array('status'=>1,'type'=>1,'state'=>1));
  342. if($q_fnum['total']){
  343. $data['q_fnum'] = $q_fnum['total'];
  344. }else{
  345. $data['q_fnum'] = 0;
  346. }
  347. return Dever::render('qiquan', $data);
  348. }
  349. #代理商期权待交付
  350. public function option_nopay_api($start,$end,$type=false){
  351. $start = Dever::input('start',$start);
  352. $end = Dever::input('end',$end);
  353. if($start && $end){
  354. $start = strtotime($start);
  355. $end = strtotime($end);
  356. }else{
  357. $start=Dever::maketime(date('Y-m-01') . ' 00:00:00');
  358. $end = strtotime(date('Y-m-d 23:59:59',
  359. strtotime(date('Y-m-01')."+1 month - 1 day")));
  360. }
  361. $where['start'] = $start;
  362. $where['end'] = $end;
  363. $where['state'] = 1;
  364. $rest = array();
  365. $rest['start'] = date('Y-m-d',$start);
  366. $rest['end'] = date('Y-m-d',$end);
  367. $rest['data'] = array();
  368. $data = Dever::db('agent/order')->getAll($where);
  369. if($data){
  370. foreach($data as $k => $v){
  371. #单独购买的软件服务费
  372. $cash = Dever::db('agent/soft_cash')->getTotal(array('fstart'=>$start,'fend'=>$end,'mid'=>$v['mid']));
  373. $data[$k]['buy_cash'] = $cash['total'];
  374. $option = Dever::db('agent/soft_cash')->getPrice(array('fstart'=>$start,'fend'=>$end,'mid'=>$v['mid']));
  375. $data[$k]['y_price'] = $option['total'];
  376. }
  377. $rest['page'] = Dever::page("current");
  378. $rest['data'] = $data;
  379. if($type == 1){
  380. return $rest['data'];
  381. }else{
  382. return Dever::render('option_nopay', $rest);
  383. }
  384. }else{
  385. return Dever::render('option_nopay', $rest);
  386. }
  387. }
  388. #代理商期权待交付导出
  389. public function out_option_nopay_api(){
  390. $start = Dever::input('start');
  391. $end = Dever::input('end');
  392. if($start && $end){
  393. $start = strtotime($start);
  394. $end = strtotime($end);
  395. }else{
  396. $start=Dever::maketime(date('Y-m-01') . ' 00:00:00');
  397. $end = strtotime(date('Y-m-d 23:59:59',
  398. strtotime(date('Y-m-01')."+1 month - 1 day")));
  399. }
  400. $data = $this->option_nopay_api($start,$end,1);
  401. $header = array('用户姓名', '手机号', '身份证号', '软件服务费(订单)', '软件服务费(购买)', '原始期权', '期权赠送');
  402. if($data){
  403. $body = array();
  404. foreach($data as $k => $v){
  405. $d = array
  406. (
  407. $v['name'],
  408. $v['mobile'],
  409. $v['idcard'],
  410. $v['soft_cash'],
  411. $v['buy_cash'],
  412. $v['y_price'],
  413. $v['option_price'],
  414. );
  415. $body[] = $d;
  416. }
  417. $file = '代理商期权待交付';
  418. Dever::excelExport($body, $header, $file);
  419. }
  420. }
  421. #代理商期权发放统计
  422. public function option_grant_api($start,$end,$type=false){
  423. $start = Dever::input('start',$start);
  424. $end = Dever::input('end',$end);
  425. if($start && $end){
  426. $start = strtotime($start);
  427. $end = strtotime($end);
  428. }else{
  429. $start=Dever::maketime(date('Y-m-01') . ' 00:00:00');
  430. $end = strtotime(date('Y-m-d 23:59:59',
  431. strtotime(date('Y-m-01')."+1 month - 1 day")));
  432. }
  433. $data = array();
  434. $data['start'] = date('Y-m-d',$start);
  435. $data['end'] = date('Y-m-d',$end);
  436. $res = Dever::db('agent/member')->getAll(array('start'=>$start,'end'=>$end,'state'=>1));
  437. foreach($res as $k=>$v){
  438. $role = Dever::db('setting/role')->find($v['role']);
  439. $res[$k]['role_name'] = $role['name'];
  440. $res[$k]['cv_num'] = Dever::db('agent/member')->getNum(array('parent_mid'=>$v['id'],'fstart'=>$start,'fend'=>$end,'role'=>8,'state'=>1));
  441. $res[$k]['ck_num'] = Dever::db('agent/member')->getNum(array('parent_mid'=>$v['id'],'fstart'=>$start,'fend'=>$end,'role'=>6,'state'=>1));
  442. $res[$k]['cash'] = Dever::db('bill/cash')->getCash(array('mid'=>$v['id'],'type'=>'1,2','state'=>1));
  443. }
  444. $data['page'] = Dever::page("current");
  445. $data['data'] = $res;
  446. if($type == 1){
  447. return $res;
  448. }else{
  449. return Dever::render('option_grant', $data);
  450. }
  451. }
  452. #期权发放导出
  453. public function out_option_grant_api(){
  454. $start = Dever::input('start');
  455. $end = Dever::input('end');
  456. if($start && $end){
  457. $start = strtotime($start);
  458. $end = strtotime($end);
  459. }else{
  460. $start=Dever::maketime(date('Y-m-01') . ' 00:00:00');
  461. $end = strtotime(date('Y-m-d 23:59:59',
  462. strtotime(date('Y-m-01')."+1 month - 1 day")));
  463. }
  464. $data = $this->option_grant_api($start,$end,1);
  465. $header = array('用户姓名', '手机号', '身份证号', '角色', '完成团队业绩', '完成直推创v', '完成直推创客');
  466. if($data){
  467. $body = array();
  468. foreach($data as $k => $v){
  469. $d = array
  470. (
  471. $v['name'],
  472. $v['mobile'],
  473. $v['idcard'],
  474. $v['role_name'],
  475. $v['group_sell'],
  476. $v['cv_num'],
  477. $v['ck_num'],
  478. );
  479. $body[] = $d;
  480. }
  481. $file = '代理商期权发放';
  482. Dever::excelExport($body, $header, $file);
  483. }
  484. }
  485. #软件服务费数据统计
  486. public function soft_cash_api(){
  487. $start = Dever::input('start');
  488. $end = Dever::input('end');
  489. $where = array();
  490. if($start && $end){
  491. $where['fstart'] = strtotime($start.'00:00:00');
  492. $where['fend'] = strtotime($end.'23:59:59');
  493. }else{
  494. $where['fstart']=Dever::maketime(date('Y-m-01') . ' 00:00:00');
  495. $where['fend'] = strtotime(date('Y-m-d 23:59:59',
  496. strtotime(date('Y-m-01')."+1 month - 1 day")));
  497. }
  498. $where['state'] = 1;
  499. $data = array();
  500. $data['start'] = date('Y-m-d',$where['fstart']);
  501. $data['end'] = date('Y-m-d',$where['fend']);
  502. #软件服务费的已确认数量
  503. $where['soft_cash']=1;
  504. $where['status'] = 4;
  505. $order = Dever::db('agent/order')->getSoftNum($where);
  506. $where['status'] = 3;
  507. $soft_cash = Dever::db('agent/soft_cash')->getSoftNum($where);
  508. $data['num'] = $order + $soft_cash;
  509. #软件服务费未确认的数量
  510. $where['status'] = '-2,-1,1,2,3';
  511. $order = Dever::db('agent/order')->getSoftNoNum($where);
  512. $where['status'] = '1,2';
  513. $soft_cash = Dever::db('agent/soft_cash')->getSoftNoNum($where);
  514. $data['no_num'] = $order + $soft_cash;
  515. #总数量
  516. $data['total_num'] = $data['num'] + $data['no_num'];
  517. #已确认软件服务费
  518. $where['status'] = 4;
  519. $order = Dever::db('agent/order')->getSoftCash($where);
  520. $where['status'] = 3;
  521. $soft_cash = Dever::db('agent/soft_cash')->getSoftCash($where);
  522. $data['money'] = $order['total'] + $soft_cash['total'];
  523. #未确认软件服务费
  524. $where['status'] = '-2,-1,1,2,3';
  525. $order = Dever::db('agent/order')->getSoftNoCash($where);
  526. $where['status'] = '1,2';
  527. $soft_cash = Dever::db('agent/soft_cash')->getSoftNoCash($where);
  528. $data['no_money'] = $order['total'] + $soft_cash['total'];
  529. #总钱数
  530. $data['total_money'] = $data['money'] + $data['no_money'];
  531. #合同已确认数量:
  532. $where['status'] = 2;
  533. $data['a_num'] = Dever::db('agent/member_agreement')->getNum($where);
  534. #合同未确认数量:
  535. $where['status'] = 1;
  536. $data['a_nonum'] = Dever::db('agent/member_agreement')->getNoNum($where);
  537. $data['a_totalnum'] = $data['a_num'] + $data['a_nonum'];
  538. #合同已确认软件服务费
  539. $where['status'] = 2;
  540. $price = Dever::db('agent/member_agreement')->getPrice($where);
  541. if($price['total']){
  542. $data['a_price'] = $price['total'];
  543. }else{
  544. $data['a_price'] = 0;
  545. }
  546. #合同未确认软件服务费
  547. $where['status'] = 1;
  548. $noprice = Dever::db('agent/member_agreement')->getNoPrice($where);
  549. if($noprice['total']){
  550. $data['a_noprice'] = $noprice['total'];
  551. }else{
  552. $data['a_noprice'] = 0;
  553. }
  554. #总钱数
  555. $data['total_price'] = $data['a_price'] + $data['a_noprice'];
  556. return Dever::render('soft_cash', $data);
  557. }
  558. #采购价-成本价
  559. public function caigou($where){
  560. $data = Dever::db('shop/buy_order')->getNewAll($where);
  561. $res = array();
  562. foreach($data as $k => $v){
  563. // $goods_id,$skuid
  564. $order_goods = Dever::db('shop/buy_order_goods')->select(array('order_id' => $v['id']));
  565. foreach($order_goods as $k1 => $v1){
  566. $goods = Dever::load('goods/lib/info')->getPayInfo($v1['goods_id'], $v1['sku_id']);
  567. if($goods['c_price'] && $goods['c_price'] >= 0){
  568. $data[$k]['money'] = $v['price'] - $goods['c_price'];
  569. }else{
  570. $data[$k]['money'] = $v['price'];
  571. }
  572. }
  573. }
  574. $money = 0;
  575. foreach($data as $k1 => $v1){
  576. $money +=$v1['money'];
  577. }
  578. return $money;
  579. }
  580. public function ls($where){
  581. // print_R($where);die;
  582. $shop = Dever::db('mail/area_entry')->getNewAll($where);
  583. $data = array();
  584. $data['price'] = 0;
  585. foreach($shop as $k => $v){
  586. $shop[$k]['shop'] = Dever::db('shop/info')->find(array('area'=>$where['area'],'id'=>$v['shop_id']));
  587. }
  588. foreach($shop as $k => $v){
  589. if(!$v['shop']){
  590. unset($shop[$k]);
  591. }
  592. }
  593. foreach($shop as $k=>$v){
  594. $data['price'] +=$v['cprice'];
  595. }
  596. $data['num'] = count($shop);
  597. return $data;
  598. }
  599. #区域分润
  600. public function area_api(){
  601. $month = Dever::input('month', date('Y-m'));
  602. $start_time = $month .'-01 00:00:00';
  603. $where = array();
  604. $end_time = date('Y-m-d', strtotime($start_time. ' +1 month -1 day')).' 23:59:59';
  605. $where['start'] = Dever::maketime($start_time);
  606. $where['end'] = Dever::maketime($end_time);
  607. $where['state'] = 1;
  608. $data = array();
  609. $shop = Dever::db('shop/info')->getAreaAll(array('state'=>1));
  610. foreach($shop as $k=>$v){
  611. $data[$v['city']]=$v;
  612. }
  613. foreach($data as $k => $v){
  614. $w['month'] = $where['start'];
  615. #城市
  616. if($v['city']>0){
  617. $where['area'] = $v['city'];
  618. $data[$k]['citys']['area'] = $v['province'].','.$v['city'];
  619. $jia = $this->caigou($where);
  620. $data[$k]['citys']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
  621. $data[$k]['citys']['price']= $jia * 0.01;
  622. // $data[$k]['citys']['price']= round($data[$k]['citys']['money']['total']) * 0.3*0.01;
  623. $mid = Dever::db('agent/member')->getAreaAll($where);
  624. $w['citys']['area'] = $v['city'];
  625. if($mid && $mid['id']){
  626. $data[$k]['citys']['mid'] = $mid['id'];
  627. }else{
  628. $data[$k]['citys']['mid'] = '';
  629. }
  630. $where['city'] = $v['city'];
  631. $data[$k]['citys']['num'] = Dever::db('shop/info')->getSerachNum($where);
  632. #体验店
  633. $t_shop = Dever::db('shop/info')->getAreaAll(array('city'=>$v['city'],'type'=>1,'state'=>1));
  634. $data[$k]['citys']['type'] = array_column($t_shop,'id');
  635. $where['type_id'] = implode(',',$data[$k]['citys']['type']);
  636. $data[$k]['citys']['t_num'] = count($t_shop);
  637. if($data[$k]['citys']['t_num']>0){
  638. $data[$k]['citys']['t_price'] = Dever::db('shop/buy_order')->getSerachTMoney($where);
  639. }else{
  640. $data[$k]['citys']['t_price'] = 0;
  641. }
  642. #零售店
  643. $shop_area = $this->ls($where);
  644. $data[$k]['citys']['l_price'] =$shop_area['price'] * 0.01;
  645. $data[$k]['citys']['l_num'] = $shop_area['num'];
  646. $data[$k]['citys']['price'] = $data[$k]['citys']['price'] + $data[$k]['citys']['l_price'];
  647. $w['mid'] = $data[$k]['citys']['mid'];
  648. $w['area'] = $data[$k]['citys']['area'];
  649. $w['price'] = $data[$k]['citys']['price'];
  650. $w['c_price'] = $data[$k]['citys']['money']['total'];
  651. $w['num'] = $data[$k]['citys']['num'];
  652. $w['t_num'] = $data[$k]['citys']['t_num'];
  653. $w['t_price'] = $data[$k]['citys']['t_price']['total'];
  654. $w['l_num'] = $data[$k]['citys']['l_num'];
  655. $w['l_price'] = $shop_area['price'];
  656. $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['citys']['area']));
  657. if(!$shop){
  658. Dever::db('mail/area_stat')->insert($w);
  659. }else{
  660. $w['where_id'] = $shop['id'];
  661. Dever::db('mail/area_stat')->update($w);
  662. }
  663. }
  664. #区县
  665. if($v['county']>0){
  666. $where['area'] = $v['county'];
  667. $data[$k]['countys']['area'] = $v['province'].','.$v['city'].','.$v['county'];
  668. $data[$k]['countys']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
  669. $jia = $this->caigou($where);
  670. $data[$k]['countys']['price']= $jia *0.03;
  671. // $data[$k]['countys']['price']= round($data[$k]['countys']['money']['total']) * 0.3*0.03;
  672. $mid = Dever::db('agent/member')->getAreaAll($where);
  673. if($mid && $mid['id']){
  674. $data[$k]['countys']['mid'] = $mid['id'];
  675. }else{
  676. $data[$k]['countys']['mid'] = '';
  677. }
  678. $wh['county'] = $v['county'];
  679. $data[$k]['countys']['num'] = Dever::db('shop/info')->getSerachNum($wh);
  680. // #体验店
  681. $t_shop = Dever::db('shop/info')->getAreaAll(array('county'=>$v['county'],'type'=>1,'state'=>1));
  682. $data[$k]['countys']['type'] = array_column($t_shop,'id');
  683. $where['type_id'] = implode(',',$data[$k]['countys']['type']);
  684. $data[$k]['countys']['t_num'] = count($t_shop);
  685. if($data[$k]['countys']['t_num']>0){
  686. $data[$k]['countys']['t_price'] = Dever::db('shop/buy_order')->getSerachTMoney($where);
  687. }else{
  688. $data[$k]['countys']['t_price'] = 0;
  689. }
  690. #零售店
  691. $shop_area = $this->ls($where);
  692. $data[$k]['countys']['l_price'] = $shop_area['price'] * 0.03;
  693. $data[$k]['countys']['l_num'] = $shop_area['num'];
  694. $data[$k]['countys']['price'] = $data[$k]['countys']['price'] + $data[$k]['countys']['l_price'];
  695. $w['mid'] = $data[$k]['countys']['mid'];
  696. $w['area'] = $data[$k]['countys']['area'];
  697. $w['price'] = $data[$k]['countys']['price'];
  698. $w['num'] = $data[$k]['countys']['num'];
  699. $w['c_price'] = $data[$k]['countys']['money']['total'];
  700. $w['t_num'] = $data[$k]['countys']['t_num'];
  701. $w['t_price'] = $data[$k]['countys']['t_price']['total'];
  702. $w['l_num'] = $data[$k]['countys']['l_num'];
  703. $w['l_price'] = $shop_area['price'];
  704. $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['countys']['area']));
  705. if(!$shop){
  706. Dever::db('mail/area_stat')->insert($w);
  707. }else{
  708. $w['where_id'] = $shop['id'];
  709. Dever::db('mail/area_stat')->update($w);
  710. }
  711. }
  712. #街道
  713. if($v['town']>0){
  714. $where['area'] = $v['town'];
  715. $data[$k]['towns']['area'] = $v['province'].','.$v['city'].','.$v['county'].','.$v['town'];
  716. $data[$k]['towns']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
  717. $jia = $this->caigou($where);
  718. $data[$k]['towns']['price'] = $jia * 0.05;
  719. // $data[$k]['towns']['price']= round($data[$k]['towns']['money']['total']) * 0.3*0.05;
  720. $mid = Dever::db('agent/member')->getAreaAll($where);
  721. if($mid && $mid['id']){
  722. $data[$k]['towns']['mid'] = $mid['id'];
  723. }else{
  724. $data[$k]['towns']['mid'] = '';
  725. }
  726. $whe['town'] = $v['town'];
  727. $data[$k]['towns']['num'] = Dever::db('shop/info')->getSerachNum($whe);
  728. #体验店
  729. $t_shop = Dever::db('shop/info')->getAreaAll(array('town'=>$v['town'],'type'=>1,'state'=>1));
  730. $data[$k]['towns']['type'] = array_column($t_shop,'id');
  731. $where['type_id'] = implode(',',$data[$k]['towns']['type']);
  732. $data[$k]['towns']['t_num'] = count($t_shop);
  733. if($data[$k]['towns']['t_num']>0){
  734. $data[$k]['towns']['t_price'] = Dever::db('shop/buy_order')->getSerachTMoney($where);
  735. }else{
  736. $data[$k]['towns']['t_price'] = 0;
  737. }
  738. #零售店
  739. $shop_area = $this->ls($where);
  740. $data[$k]['towns']['l_price'] =$shop_area['price'] * 0.05;
  741. $data[$k]['towns']['l_num'] = $shop_area['num'];
  742. $data[$k]['towns']['price'] = $data[$k]['towns']['price'] + $data[$k]['towns']['l_price'];
  743. $w['mid'] = $data[$k]['towns']['mid'];
  744. $w['area'] = $data[$k]['towns']['area'];
  745. $w['price'] = $data[$k]['towns']['price'];
  746. $w['num'] = $data[$k]['towns']['num'];
  747. $w['c_price'] = $data[$k]['towns']['money']['total'];
  748. $w['t_num'] = $data[$k]['towns']['t_num'];
  749. $w['t_price'] = $data[$k]['towns']['t_price']['total'];
  750. $w['l_num'] = $data[$k]['towns']['l_num'];
  751. $w['l_price'] = $shop_area['price'];
  752. $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['towns']['area']));
  753. if(!$shop){
  754. Dever::db('mail/area_stat')->insert($w);
  755. }else{
  756. $w['where_id'] = $shop['id'];
  757. Dever::db('mail/area_stat')->update($w);
  758. }
  759. }
  760. }
  761. return 'ok';
  762. }
  763. // public function area_api(){
  764. // #零售店的采购金额*0.4
  765. // $month = Dever::input('month', date('Y-m'));
  766. // $start_time = $month .'-01 00:00:00';
  767. // $where = array();
  768. // $end_time = date('Y-m-d', strtotime($start_time. ' +1 month -1 day')).' 23:59:59';
  769. // $where['start'] = Dever::maketime($start_time);
  770. // $where['end'] = Dever::maketime($end_time);
  771. // $where['state'] = 1;
  772. // $data = array();
  773. // $shop = Dever::db('shop/info')->getAreaAll(array('state'=>1));
  774. // foreach($shop as $k=>$v){
  775. // $data[$v['city']]=$v;
  776. // }
  777. // $shop_area = Dever::db('mail/area_entry')->getAll($where);
  778. // $res = array();
  779. // if($shop_area){
  780. // foreach($shop_area as $k => $v){
  781. // if($v['area']){
  782. // $area = explode(',',$v['area']);
  783. // if($area && isset($area[0])){
  784. // $res[$k]['province'] = $area[0];
  785. // }
  786. // if ($area && isset($area[1])){
  787. // $res[$k]['city'] = $area[1];
  788. // }else{
  789. // $res[$k]['city'] = 0;
  790. // }
  791. // if($area && isset($area[2])){
  792. // $res[$k]['county'] = $area[2];
  793. // }else{
  794. // $res[$k]['county'] = 0;
  795. // }
  796. // if($area && isset($area[3])){
  797. // $res[$k]['town'] = $area[3];
  798. // }else{
  799. // $res[$k]['town'] = 0;
  800. // }
  801. // }
  802. // }
  803. // }
  804. // $data = array_values($data);
  805. // $data = array_merge($data,$res);
  806. // // print_R($data);die;
  807. // $result=array_unique($data, SORT_REGULAR);
  808. // $rest=array();
  809. // foreach($data as $k=>$v){
  810. // $rest[$v['county']]=$v;
  811. // }
  812. // $data=array_values($rest);
  813. // foreach ($data as $k => $v) {
  814. // $edition[] = $v['province'];
  815. // }
  816. // array_multisort($edition, SORT_ASC, $data);
  817. // foreach($data as $k => $v){
  818. // $w['month'] = $where['start'];
  819. // #城市
  820. // if($v['city']>0){
  821. // $where['area'] = $v['city'];
  822. // $data[$k]['citys']['area'] = $v['province'].','.$v['city'];
  823. // $data[$k]['citys']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
  824. // $data[$k]['citys']['price']= round($data[$k]['citys']['money']['total']) * 0.3*0.01;
  825. // $mid = Dever::db('agent/member')->getAreaAll($where);
  826. // $w['citys']['area'] = $v['city'];
  827. // if($mid && $mid['id']){
  828. // $data[$k]['citys']['mid'] = $mid['id'];
  829. // }else{
  830. // $data[$k]['citys']['mid'] = '';
  831. // }
  832. // $where['city'] = $v['city'];
  833. // $data[$k]['citys']['num'] = Dever::db('shop/info')->getSerachNum($where);
  834. // #体验店
  835. // $t_shop = Dever::db('shop/info')->getAreaAll(array('city'=>$v['city'],'type'=>1,'state'=>1));
  836. // $data[$k]['citys']['type'] = array_column($t_shop,'id');
  837. // $where['type_id'] = implode(',',$data[$k]['citys']['type']);
  838. // $data[$k]['citys']['t_num'] = count($t_shop);
  839. // if($data[$k]['citys']['t_num']>0){
  840. // $data[$k]['citys']['t_price'] = Dever::db('shop/buy_order')->getSerachTMoney($where);
  841. // }else{
  842. // $data[$k]['citys']['t_price'] = 0;
  843. // }
  844. // #零售店
  845. // $entry = Dever::db('mail/area_entry')->getNum($where);
  846. // if ($entry && $entry['num']){
  847. // $data[$k]['citys']['l_num'] = $entry['num'];
  848. // $data[$k]['citys']['num'] = $data[$k]['citys']['num'] + $data[$k]['citys']['l_num'];
  849. // }else{
  850. // $data[$k]['citys']['l_num'] = 0;
  851. // }
  852. // $entry_price = Dever::db('mail/area_entry')->getPrice($where);
  853. // if ($entry_price && $entry_price['cprice'] ){
  854. // $data[$k]['citys']['l_price'] = $entry_price['cprice'] * 0.4;
  855. // $data[$k]['citys']['price'] = $data[$k]['citys']['price'] + $data[$k]['citys']['l_price'];
  856. // }else{
  857. // $data[$k]['citys']['l_price'] = 0;
  858. // }
  859. // $w['mid'] = $data[$k]['citys']['mid'];
  860. // $w['area'] = $data[$k]['citys']['area'];
  861. // $w['price'] = $data[$k]['citys']['price'];
  862. // $w['c_price'] = $data[$k]['citys']['money']['total'];
  863. // $w['num'] = $data[$k]['citys']['num'];
  864. // $w['t_num'] = $data[$k]['citys']['t_num'];
  865. // $w['t_price'] = $data[$k]['citys']['t_price']['total'];
  866. // $w['l_num'] = $data[$k]['citys']['l_num'];
  867. // $w['l_price'] = $data[$k]['citys']['l_price'];
  868. // $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['citys']['area']));
  869. // if(!$shop){
  870. // Dever::db('mail/area_stat')->insert($w);
  871. // }else{
  872. // $w['where_id'] = $shop['id'];
  873. // Dever::db('mail/area_stat')->update($w);
  874. // }
  875. // }
  876. // #区县
  877. // if($v['county']>0){
  878. // $where['area'] = $v['county'];
  879. // $data[$k]['countys']['area'] = $v['province'].','.$v['city'].','.$v['county'];
  880. // $data[$k]['countys']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
  881. // $data[$k]['countys']['price']= round($data[$k]['countys']['money']['total']) * 0.3*0.03;
  882. // $mid = Dever::db('agent/member')->getAreaAll($where);
  883. // if($mid && $mid['id']){
  884. // $data[$k]['countys']['mid'] = $mid['id'];
  885. // }else{
  886. // $data[$k]['countys']['mid'] = '';
  887. // }
  888. // $wh['county'] = $v['county'];
  889. // $data[$k]['countys']['num'] = Dever::db('shop/info')->getSerachNum($wh);
  890. // // #体验店
  891. // $t_shop = Dever::db('shop/info')->getAreaAll(array('county'=>$v['county'],'type'=>1,'state'=>1));
  892. // $data[$k]['countys']['type'] = array_column($t_shop,'id');
  893. // $where['type_id'] = implode(',',$data[$k]['countys']['type']);
  894. // $data[$k]['countys']['t_num'] = count($t_shop);
  895. // if($data[$k]['countys']['t_num']>0){
  896. // $data[$k]['countys']['t_price'] = Dever::db('shop/buy_order')->getSerachTMoney($where);
  897. // }else{
  898. // $data[$k]['countys']['t_price'] = 0;
  899. // }
  900. // #零售店
  901. // $entry = Dever::db('mail/area_entry')->getNum($where);
  902. // if ($entry && $entry['num']){
  903. // $data[$k]['countys']['l_num'] = $entry['num'];
  904. // $data[$k]['countys']['num'] = $data[$k]['countys']['num'] + $data[$k]['countys']['l_num'];
  905. // }else{
  906. // $data[$k]['countys']['l_num'] = 0;
  907. // }
  908. // $entry_price = Dever::db('mail/area_entry')->getPrice($where);
  909. // if ($entry_price && $entry_price['cprice'] ){
  910. // $data[$k]['countys']['l_price'] = $entry_price['cprice'] * 0.4;
  911. // $data[$k]['countys']['price'] = $data[$k]['countys']['price'] + $data[$k]['countys']['l_price'];
  912. // }else{
  913. // $data[$k]['countys']['l_price'] = 0;
  914. // }
  915. // $w['mid'] = $data[$k]['countys']['mid'];
  916. // $w['area'] = $data[$k]['countys']['area'];
  917. // $w['price'] = $data[$k]['countys']['price'];
  918. // $w['num'] = $data[$k]['countys']['num'];
  919. // $w['c_price'] = $data[$k]['countys']['money']['total'];
  920. // $w['t_num'] = $data[$k]['countys']['t_num'];
  921. // $w['t_price'] = $data[$k]['countys']['t_price']['total'];
  922. // $w['l_num'] = $data[$k]['countys']['l_num'];
  923. // $w['l_price'] = $data[$k]['countys']['l_price'];
  924. // $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['countys']['area']));
  925. // if(!$shop){
  926. // Dever::db('mail/area_stat')->insert($w);
  927. // }else{
  928. // $w['where_id'] = $shop['id'];
  929. // Dever::db('mail/area_stat')->update($w);
  930. // }
  931. // }
  932. // #街道
  933. // if($v['town']>0){
  934. // $where['area'] = $v['town'];
  935. // $data[$k]['towns']['area'] = $v['province'].','.$v['city'].','.$v['county'].','.$v['town'];
  936. // $data[$k]['towns']['money'] = Dever::db('shop/buy_order')->getSerachMoney($where);
  937. // $data[$k]['towns']['price']= round($data[$k]['towns']['money']['total']) * 0.3*0.05;
  938. // $mid = Dever::db('agent/member')->getAreaAll($where);
  939. // if($mid && $mid['id']){
  940. // $data[$k]['towns']['mid'] = $mid['id'];
  941. // }else{
  942. // $data[$k]['towns']['mid'] = '';
  943. // }
  944. // $whe['town'] = $v['town'];
  945. // $data[$k]['towns']['num'] = Dever::db('shop/info')->getSerachNum($whe);
  946. // #体验店
  947. // $t_shop = Dever::db('shop/info')->getAreaAll(array('town'=>$v['town'],'type'=>1,'state'=>1));
  948. // $data[$k]['towns']['type'] = array_column($t_shop,'id');
  949. // $where['type_id'] = implode(',',$data[$k]['towns']['type']);
  950. // $data[$k]['towns']['t_num'] = count($t_shop);
  951. // if($data[$k]['towns']['t_num']>0){
  952. // $data[$k]['towns']['t_price'] = Dever::db('shop/buy_order')->getSerachTMoney($where);
  953. // }else{
  954. // $data[$k]['towns']['t_price'] = 0;
  955. // }
  956. // #零售店
  957. // $entry = Dever::db('mail/area_entry')->getNum($where);
  958. // if ($entry && $entry['num']){
  959. // $data[$k]['towns']['l_num'] = $entry['num'];
  960. // $data[$k]['towns']['num'] = $data[$k]['towns']['num'] + $data[$k]['towns']['l_num'];
  961. // }else{
  962. // $data[$k]['towns']['l_num'] = 0;
  963. // }
  964. // $entry_price = Dever::db('mail/area_entry')->getPrice($where);
  965. // if ($entry_price && $entry_price['cprice'] ){
  966. // $data[$k]['towns']['l_price'] = $entry_price['cprice'] * 0.4;
  967. // $data[$k]['towns']['price'] = $data[$k]['towns']['price'] + $data[$k]['towns']['l_price'];
  968. // }else{
  969. // $data[$k]['towns']['l_price'] = 0;
  970. // }
  971. // $w['mid'] = $data[$k]['towns']['mid'];
  972. // $w['area'] = $data[$k]['towns']['area'];
  973. // $w['price'] = $data[$k]['towns']['price'];
  974. // $w['num'] = $data[$k]['towns']['num'];
  975. // $w['c_price'] = $data[$k]['towns']['money']['total'];
  976. // $w['t_num'] = $data[$k]['towns']['t_num'];
  977. // $w['t_price'] = $data[$k]['towns']['t_price']['total'];
  978. // $w['l_num'] = $data[$k]['towns']['l_num'];
  979. // $w['l_price'] = $data[$k]['towns']['l_price'];
  980. // $shop = Dever::db('mail/area_stat')->find(array('month'=>$w['month'],'area'=>$data[$k]['towns']['area']));
  981. // if(!$shop){
  982. // Dever::db('mail/area_stat')->insert($w);
  983. // }else{
  984. // $w['where_id'] = $shop['id'];
  985. // Dever::db('mail/area_stat')->update($w);
  986. // }
  987. // }
  988. // }
  989. // return 'ok';
  990. // }
  991. public function area_member($id){
  992. $info = Dever::db('mail/area_stat')->find($id);
  993. if($info['mid']){
  994. $member = Dever::db('agent/member')->find($info['mid']);
  995. $res = $member['name']."<br/>".$member['mobile'];
  996. }else{
  997. $res = '-';
  998. }
  999. return $res;
  1000. }
  1001. public function entry_member($id){
  1002. $info = Dever::db('mail/area_entry')->find($id);
  1003. if($info['shop_id']){
  1004. $member = Dever::db('shop/info')->find($info['shop_id']);
  1005. // print_R($member);die;
  1006. $res = $member['name'].'<br/>'.$member['sid'];
  1007. }else{
  1008. $res = '-';
  1009. }
  1010. return $res;
  1011. }
  1012. public function updateArea_entry($id,$name,$data){
  1013. $sid = Dever::param('sid',$data);
  1014. $month = Dever::param('month',$data);
  1015. if ($id && $sid) {
  1016. $info = Dever::db('mail/area_entry')->find($id);
  1017. $member = Dever::db('shop/info')->find(array('sid'=>$sid));
  1018. // print_R($member);die;
  1019. $where['where_id'] = $id ;
  1020. $where['shop_id'] = $member['id'];
  1021. $where['month'] = strtotime($month);
  1022. Dever::db('mail/area_entry')->update($where);
  1023. }
  1024. }
  1025. }