Record.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xurongyao <763569752@qq.com>
  5. * Date: 2018/6/14 下午5:25
  6. */
  7. namespace app\admin\controller\record;
  8. use app\admin\controller\AuthController;
  9. use app\admin\model\store\{StoreProduct, StoreCouponUser};
  10. use app\admin\model\order\StoreOrder;
  11. use app\admin\model\ump\{StoreBargain, StoreSeckill, StoreCombination};
  12. use crmeb\services\{JsonService, UtilService as Util};
  13. use app\admin\model\user\{User, UserBill, UserExtract};
  14. /**
  15. * 微信充值记录
  16. * Class UserRecharge
  17. * @package app\admin\controller\user
  18. */
  19. class Record extends AuthController
  20. {
  21. /**
  22. * 显示操作记录
  23. */
  24. public function index()
  25. {
  26. }
  27. /**
  28. * 显示订单记录
  29. */
  30. public function chart_order()
  31. {
  32. $this->assign([
  33. 'is_layui' => true,
  34. 'year' => get_month()
  35. ]);
  36. return $this->fetch();
  37. }
  38. public function get_echarts_order()
  39. {
  40. $where = Util::getMore([
  41. ['type', ''],
  42. ['status', ''],
  43. ['data', ''],
  44. ]);
  45. return JsonService::successful(StoreOrder::getEchartsOrder($where));
  46. }
  47. /**
  48. * 显示产品记录
  49. */
  50. public function chart_product()
  51. {
  52. $this->assign([
  53. 'is_layui' => true,
  54. 'year' => get_month()
  55. ]);
  56. return $this->fetch();
  57. }
  58. /**
  59. * 获取产品曲线图数据
  60. */
  61. public function get_echarts_product($type = '', $data = '')
  62. {
  63. return JsonService::successful(StoreProduct::getChatrdata($type, $data));
  64. }
  65. /**
  66. * 获取销量
  67. */
  68. public function get_echarts_maxlist($data = '')
  69. {
  70. return JsonService::successful(StoreProduct::getMaxList(compact('data')));
  71. }
  72. /**
  73. * 获取利润
  74. */
  75. public function get_echarts_profity($data = '')
  76. {
  77. return JsonService::successful(StoreProduct::ProfityTop10(compact('data')));
  78. }
  79. /**
  80. * 获取缺货列表
  81. */
  82. public function getLackList()
  83. {
  84. $where = Util::getMore([
  85. ['page', 1],
  86. ['limit', 20],
  87. ]);
  88. return JsonService::successlayui(StoreProduct::getLackList($where));
  89. }
  90. /**
  91. * 表单快速修改
  92. */
  93. public function editField($id = '')
  94. {
  95. $post = $this->request->post();
  96. StoreProduct::beginTrans();
  97. try {
  98. StoreProduct::edit($post, $id);
  99. StoreProduct::commitTrans();
  100. return JsonService::successful('修改成功');
  101. } catch (\Exception $e) {
  102. StoreProduct::rollbackTrans();
  103. return JsonService::fail($e->getMessage());
  104. }
  105. }
  106. //获取差评
  107. public function getnegativelist()
  108. {
  109. $where = Util::getMore([
  110. ['page', 1],
  111. ['limit', 10],
  112. ]);
  113. return JsonService::successful(StoreProduct::getnegativelist($where));
  114. }
  115. /**
  116. * 获取退货
  117. */
  118. public function getTuiPriesList()
  119. {
  120. return JsonService::successful(StoreProduct::TuiProductList());
  121. }
  122. //营销统计
  123. /**
  124. * 显示积分统计
  125. */
  126. public function chart_score()
  127. {
  128. $this->assign([
  129. 'is_layui' => true,
  130. 'year' => get_month()
  131. ]);
  132. return $this->fetch();
  133. }
  134. /**
  135. * 获取积分头部信息
  136. */
  137. public function getScoreBadgeList($data = '')
  138. {
  139. return JsonService::successful(UserBill::getScoreBadgeList(compact('data')));
  140. }
  141. /**
  142. * 获取积分曲线图和柱状图
  143. */
  144. public function getScoreCurve($data = '', $limit = 20)
  145. {
  146. return JsonService::successful(UserBill::getScoreCurve(compact('data', 'limit')));
  147. }
  148. /**
  149. * 显示优惠券统计
  150. */
  151. public function chart_coupon()
  152. {
  153. $this->assign([
  154. 'is_layui' => true,
  155. 'year' => get_month()
  156. ]);
  157. return $this->fetch();
  158. }
  159. /**
  160. * 获取优惠劵头部信息
  161. */
  162. public function getCouponBadgeList($data = '')
  163. {
  164. return JsonService::successful(StoreCouponUser::getCouponBadgeList(compact('data')));
  165. }
  166. /**
  167. * 获取优惠劵数据图表
  168. */
  169. public function getConponCurve($data = '')
  170. {
  171. return JsonService::successful(StoreCouponUser::getConponCurve(compact('data')));
  172. }
  173. /**
  174. * 显示拼团统计
  175. */
  176. public function chart_combination()
  177. {
  178. $this->assign([
  179. 'is_layui' => true,
  180. 'year' => get_month()
  181. ]);
  182. return $this->fetch();
  183. }
  184. /**
  185. * 显示砍价统计
  186. */
  187. public function chart_bargain()
  188. {
  189. $this->assign([
  190. 'is_layui' => true,
  191. 'year' => get_month()
  192. ]);
  193. return $this->fetch();
  194. }
  195. /**
  196. * 显示秒杀统计
  197. */
  198. public function chart_seckill()
  199. {
  200. $this->assign([
  201. 'is_layui' => true,
  202. 'year' => get_month()
  203. ]);
  204. return $this->fetch();
  205. }
  206. //财务统计
  207. /**
  208. * 显示反佣统计
  209. */
  210. public function chart_rebate()
  211. {
  212. $this->assign([
  213. 'is_layui' => true,
  214. 'year' => get_month()
  215. ]);
  216. return $this->fetch();
  217. }
  218. //获取用户返佣柱状图
  219. public function getUserBillBrokerage($data = '')
  220. {
  221. return JsonService::successful(UserBill::getUserBillChart(compact('data')));
  222. }
  223. //获取用户返佣头部信息
  224. public function getRebateBadge($data = '')
  225. {
  226. return JsonService::successful(UserBill::getRebateBadge(compact('data')));
  227. }
  228. //获得 返佣列表,带分页
  229. public function getFanList($page = 1, $limit = 20)
  230. {
  231. return JsonService::successful(UserBill::getFanList(compact('page', 'limit')));
  232. }
  233. //获得 返佣总次数
  234. public function getFanCount()
  235. {
  236. return JsonService::successful(UserBill::getFanCount());
  237. }
  238. /**
  239. * 显示充值统计
  240. */
  241. public function chart_recharge()
  242. {
  243. $this->assign([
  244. 'is_layui' => true,
  245. 'year' => get_month()
  246. ]);
  247. return $this->fetch();
  248. }
  249. /**
  250. * 获取用户充值柱状图和曲线图
  251. */
  252. public function getEchartsRecharge($data = '')
  253. {
  254. return JsonService::successful(UserBill::getEchartsRecharge(compact('data')));
  255. }
  256. /**
  257. * 显示提现统计
  258. */
  259. public function chart_cash()
  260. {
  261. $this->assign([
  262. 'is_layui' => true,
  263. 'year' => get_month()
  264. ]);
  265. return $this->fetch();
  266. }
  267. //获取提现头部信息
  268. public function getExtractHead($data = '')
  269. {
  270. return JsonService::successful(UserExtract::getExtractHead(compact('data')));
  271. }
  272. //会员统计
  273. /**
  274. * 显示用户统计
  275. */
  276. public function user_chart()
  277. {
  278. $this->assign([
  279. 'is_layui' => true,
  280. 'year' => get_month()
  281. ]);
  282. return $this->fetch();
  283. }
  284. /**
  285. * 获取头部信息
  286. *
  287. * 人数 增长 分销人数 分销增长
  288. */
  289. public function getBadgeList($data = '', $is_promoter = '', $status = '')
  290. {
  291. return JsonService::successful(User::getBadgeList(compact('data', 'is_promoter', 'status')));
  292. }
  293. /*
  294. * 获取用户增长曲线图
  295. *
  296. */
  297. public function getUserChartList($data = '', $is_promoter = '', $status = '')
  298. {
  299. return JsonService::successful(User::getUserChartList(compact('data', 'is_promoter', 'status')));
  300. }
  301. /*
  302. * 获取提现分布图和提现人数金额曲线图
  303. *
  304. */
  305. public function getExtractData($data = '')
  306. {
  307. return JsonService::successful(UserExtract::getExtractList(compact('data')));
  308. }
  309. /*
  310. * 分销会员统计
  311. *
  312. */
  313. public function user_distribution_chart()
  314. {
  315. $limit = 10;
  316. $top10list = User::getUserDistributionTop10List($limit);
  317. $this->assign([
  318. 'is_layui' => true,
  319. 'limit' => $limit,
  320. 'year' => get_month(),
  321. 'commissionList' => $top10list['commission'],
  322. 'extractList' => $top10list['extract'],
  323. ]);
  324. return $this->fetch();
  325. }
  326. /*
  327. * 获取分销会员统计会员头部详情
  328. *
  329. */
  330. public function getDistributionBadgeList($data = '')
  331. {
  332. return JsonService::successful(User::getDistributionBadgeList(compact('data')));
  333. }
  334. /*
  335. * 获取分销会员统计图表数据
  336. *
  337. * $data 时间范围
  338. *
  339. */
  340. public function getUserDistributionChart($data = '')
  341. {
  342. return JsonService::successful(User::getUserDistributionChart(compact('data')));
  343. }
  344. /**
  345. * 会员业务
  346. */
  347. public function user_business_chart()
  348. {
  349. $limit = 10;
  350. $top10list = User::getUserTop10List($limit);
  351. $this->assign([
  352. 'is_layui' => true,
  353. 'limit' => $limit,
  354. 'year' => get_month(),
  355. 'integralList' => $top10list['integral'],
  356. 'moneyList' => $top10list['now_money'],
  357. 'shopcountList' => $top10list['shopcount'],
  358. 'orderList' => $top10list['order'],
  359. 'lastorderList' => $top10list['lastorder']
  360. ]);
  361. return $this->fetch();
  362. }
  363. /*
  364. * 获取 会员业务的
  365. * 购物会员统计
  366. * 分销商业务人数和提现人数统计
  367. * 分销商业务佣金和提现金额统计
  368. * 曲线图
  369. * $data 时间
  370. */
  371. public function getUserBusinessChart($data = '')
  372. {
  373. return JsonService::successful(User::getUserBusinessChart(compact('data')));
  374. }
  375. /*
  376. * 获取 会员业务
  377. * 会员总余额 分销商总佣金 分销商总佣金余额 分销商总提现佣金 本月分销商业务佣金 本月分销商佣金提现金额
  378. * 上月分销商业务佣金 上月分销商佣金提现金额
  379. * $where 查询条件
  380. *
  381. * return array
  382. */
  383. public function getUserBusinesHeade($data)
  384. {
  385. return JsonService::successful(User::getUserBusinesHeade(compact('data')));
  386. }
  387. /**
  388. * 显示用户属性统计
  389. */
  390. public function user_attr()
  391. {
  392. $this->assign([
  393. 'is_layui' => true,
  394. 'year' => get_month()
  395. ]);
  396. return $this->fetch();
  397. }
  398. /**
  399. * 获取用户属性统计
  400. */
  401. public function getEchartsData($data = '')
  402. {
  403. return JsonService::successful(User::getEchartsData(compact('data')));
  404. }
  405. //排行榜
  406. /**
  407. * 显示产品排行榜
  408. */
  409. public function ranking_saleslists()
  410. {
  411. $this->assign([
  412. 'is_layui' => true,
  413. ]);
  414. return $this->fetch();
  415. }
  416. /*
  417. *获取产品排行 带分页
  418. */
  419. public function getSaleslists($start_time = '', $end_time = '', $title = '', $page = 1, $limit = 20)
  420. {
  421. return JsonService::successlayui(StoreProduct::getSaleslists(compact('start_time', 'end_time', 'title', 'page', 'limit')));
  422. }
  423. /*
  424. *生成表格,并下载
  425. */
  426. public function save_product_export($start_time = '', $end_time = '', $title = '')
  427. {
  428. return JsonService::successlayui(StoreProduct::SaveProductExport(compact('start_time', 'end_time', 'title')));
  429. }
  430. /*
  431. *获取单个商品的详情
  432. */
  433. public function product_info($id = '')
  434. {
  435. if ($id == '') $this->failed('缺少商品id');
  436. if (!StoreProduct::be(['id' => $id])) return $this->failed('商品不存在!');
  437. $this->assign([
  438. 'is_layui' => true,
  439. 'year' => get_month(),
  440. 'id' => $id,
  441. ]);
  442. return $this->fetch();
  443. }
  444. /*
  445. *获取单个商品的详情头部信息
  446. */
  447. public function getProductBadgeList($id = '', $data = '')
  448. {
  449. return JsonService::successful(StoreProduct::getProductBadgeList($id, $data));
  450. }
  451. /*
  452. *获取单个商品的销售曲线图
  453. */
  454. public function getProductCurve($id = '', $data = '', $limit = 20)
  455. {
  456. return JsonService::successful(StoreProduct::getProductCurve(compact('id', 'data', 'limit')));
  457. }
  458. /*
  459. *获取单个商品的销售总条数
  460. */
  461. public function getProductCount($id, $data = '')
  462. {
  463. return JsonService::successful(StoreProduct::setWhere(compact('data'))
  464. ->where('a.product_id', $id)
  465. ->join('user c', 'c.uid=a.uid')
  466. ->where('a.is_pay', 1)
  467. ->count());
  468. }
  469. /*
  470. *获取单个商品的销售列表
  471. */
  472. public function getSalelList($data = '', $id = 0, $page = 1, $limit = 20)
  473. {
  474. return JsonService::successful(StoreProduct::getSalelList(compact('data', 'id', 'page', 'limit')));
  475. }
  476. /**
  477. * 显示反佣排行榜
  478. */
  479. public function ranking_commission()
  480. {
  481. $this->assign([
  482. 'is_layui' => true,
  483. 'year' => get_month()
  484. ]);
  485. return $this->fetch();
  486. }
  487. public function getcommissionlist($page = 1, $limit = 20)
  488. {
  489. return JsonService::successful(UserExtract::where('status', 1)
  490. ->field(['real_name', 'extract_price', 'balance'])
  491. ->order('extract_price desc')
  492. ->page($page, $limit)
  493. ->select());
  494. }
  495. public function getmonthcommissionlist($page = 1, $limit = 20)
  496. {
  497. return JsonService::successful(UserExtract::where('status', 1)
  498. ->whereTime('add_time', 'month')
  499. ->field(['real_name', 'extract_price', 'balance'])
  500. ->order('extract_price desc')
  501. ->page($page, $limit)
  502. ->select());
  503. }
  504. //获取佣金返现总条数
  505. public function getCommissonCount()
  506. {
  507. return JsonService::successful(UserExtract::where('status', 1)->count());
  508. }
  509. //获取本月佣金返现条数
  510. public function getMonthCommissonCount()
  511. {
  512. return JsonService::successful(UserExtract::where('status', 1)->whereTime('add_time', 'month')->count());
  513. }
  514. /**
  515. * 显示积分排行榜
  516. */
  517. public function ranking_point()
  518. {
  519. $this->assign([
  520. 'is_layui' => true,
  521. 'year' => get_month()
  522. ]);
  523. return $this->fetch();
  524. }
  525. //获取所有积分排行总人数
  526. public function getPountCount()
  527. {
  528. return JsonService::successful(User::where('status', 1)->where('integral', '<>', 0)->count());
  529. }
  530. //获取积分排行列表
  531. public function getpointList($page = 1, $limit = 20)
  532. {
  533. return JsonService::successful(($list = User::where('status', 1)
  534. ->where('integral', '<>', 0)
  535. ->field('nickname,integral')
  536. ->order('integral desc')
  537. ->page($page, $limit)
  538. ->select()) && count($list) ? $list->toArray() : []);
  539. }
  540. //获取本月积分排行别表
  541. public function getMonthpountList($page = 1, $limit = 20)
  542. {
  543. return JsonService::successful(($list = User::where('status', 1)
  544. ->where('integral', '<>', 0)
  545. ->whereTime('add_time', 'month')
  546. ->order('integral desc')
  547. ->field('nickname,integral')
  548. ->page($page, $limit)
  549. ->select()) && count($list) ? $list->toArray() : []);
  550. }
  551. public function getMonthPountCount()
  552. {
  553. return JsonService::successful(User::where('status', 1)->where('integral', '<>', 0)->whereTime('add_time', 'month')->count());
  554. }
  555. /**
  556. *
  557. * 显示下级会员排行榜
  558. */
  559. public function ranking_lower()
  560. {
  561. echo " 复购率 复购增长率 活跃度 活跃率 分销总金额 增长率 消费会员 非消费会员 消费排行榜 积分排行榜 余额排行榜 分销总金额排行榜 分销人数排行榜 分销余额排行榜 购物金额排行榜 购物次数排行榜 提现排行榜 ";
  562. }
  563. /**
  564. * 获取砍价产品曲线图数据
  565. */
  566. public function get_mark_echarts_product($type = '', $data = '', $model = 0)
  567. {
  568. if (!$model) return JsonService::successful(StoreBargain::getChatrdata($type, $data));
  569. if ($model) return JsonService::successful(StoreSeckill::getChatrdata($type, $data));
  570. }
  571. /**
  572. * 获取拼团产品曲线图数据
  573. */
  574. public function get_combination_echarts_product($type = '', $data = '')
  575. {
  576. return JsonService::successful(StoreCombination::getChatrdata($type, $data));
  577. }
  578. /*
  579. * 获取拼团销量
  580. */
  581. public function get_combination_maxlist($data = '')
  582. {
  583. return JsonService::successful(StoreCombination::getMaxList(compact('data')));
  584. }
  585. /*
  586. * 拼团盈利
  587. */
  588. public function get_combination_profity($data = '')
  589. {
  590. return JsonService::successful(StoreCombination::ProfityTop10(compact('data')));
  591. }
  592. /*
  593. * 拼团退货
  594. */
  595. public function get_combination_refund_list()
  596. {
  597. $where = Util::getMore([
  598. ['page', 1],
  599. ['limit', 20],
  600. ]);
  601. return JsonService::successlayui(StoreCombination::getBargainRefundList($where));
  602. }
  603. /**
  604. * 获取销量
  605. */
  606. public function get_mark_echarts_maxlist($data = '', $model = 0)
  607. {
  608. if (!$model) return JsonService::successful(StoreBargain::getMaxList(compact('data')));
  609. if ($model) return JsonService::successful(StoreSeckill::getMaxList(compact('data')));
  610. }
  611. /**
  612. * 获取利润
  613. */
  614. public function get_mark_echarts_profity($data = '', $model = 0)
  615. {
  616. if (!$model) return JsonService::successful(StoreBargain::ProfityTop10(compact('data')));
  617. if ($model) return JsonService::successful(StoreSeckill::ProfityTop10(compact('data')));
  618. }
  619. /**
  620. * 获取补货的砍价产品
  621. */
  622. public function get_mark_lack_list($model = 0)
  623. {
  624. $where = Util::getMore([
  625. ['page', 1],
  626. ['limit', 20],
  627. ]);
  628. if (!$model) return JsonService::successlayui(StoreBargain::getLackList($where));
  629. if ($model) return JsonService::successlayui(StoreSeckill::getLackList($where));
  630. }
  631. /**
  632. * 获取砍价产品的评论
  633. */
  634. public function get_mark_negative_list($model = 0)
  635. {
  636. $where = Util::getMore([
  637. ['page', 1],
  638. ['limit', 20],
  639. ]);
  640. if (!$model) return JsonService::successlayui(StoreBargain::getNegativeList($where));
  641. if ($model) return JsonService::successlayui(StoreSeckill::getNegativeList($where));
  642. }
  643. /**
  644. * 获取砍价产品的退货
  645. */
  646. public function get_mark_bargain_refund_list($model = 0)
  647. {
  648. $where = Util::getMore([
  649. ['page', 1],
  650. ['limit', 20],
  651. ]);
  652. if (!$model) return JsonService::successlayui(StoreBargain::getBargainRefundList($where));
  653. if ($model) return JsonService::successlayui(StoreSeckill::getBargainRefundList($where));
  654. }
  655. }