index.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. $urlManager = Yii::$app->urlManager;
  4. //ComponentHelper::loadComponentView('com-search', __DIR__);
  5. ?>
  6. <style>
  7. .el-tabs__nav-wrap::after {
  8. height: 1px;
  9. }
  10. .table-body {
  11. background-color: #fff;
  12. position: relative;
  13. padding-bottom: 50px;
  14. margin-bottom: 10px;
  15. border: 1px solid #EBEEF5;
  16. }
  17. .table-body .el-tabs {
  18. margin-left: 10px;
  19. }
  20. .table-body .el-tabs__nav-scroll {
  21. width: 120px;
  22. margin-left: 30px;
  23. }
  24. .table-body .el-tabs__item {
  25. height: 32px;
  26. line-height: 32px;
  27. }
  28. .table-body .clean {
  29. color: #92959B;
  30. margin-left: 20px;
  31. cursor: pointer;
  32. font-size: 15px;
  33. }
  34. .num-info {
  35. display: flex;
  36. width: 100%;
  37. height: 60px;
  38. font-size: 28px;
  39. color: #303133;
  40. }
  41. .num-info .num-info-item {
  42. text-align: center;
  43. width: 25%;
  44. border-left: 1px dashed #EFF1F7;
  45. }
  46. .num-info .num-info-item:first-of-type {
  47. border-left: 0;
  48. }
  49. .info-item-name {
  50. font-size: 16px;
  51. color: #92959B;
  52. }
  53. .tab-pay {
  54. position: absolute;
  55. bottom: 0;
  56. right: 50px;
  57. }
  58. .tab-pay .el-tabs__item {
  59. height: 56px;
  60. line-height: 56px;
  61. }
  62. .pay-info {
  63. padding: 40px 0;
  64. display: flex;
  65. justify-content: space-between;
  66. }
  67. .pay-info .pay-info-item {
  68. padding-top: 45px;
  69. width: 22%;
  70. margin: 0 1.5%;
  71. text-align: center;
  72. font-size: 26px;
  73. /*border: 1px solid #EBEEF5;*/
  74. border-radius: 10px;
  75. height: 150px;
  76. position: relative;
  77. cursor: pointer;
  78. }
  79. .pay-info .pay-info-item.active {
  80. border: 1px solid #3399FF;
  81. }
  82. .pay-info .pay-info-item img {
  83. display: none;
  84. }
  85. .pay-info .pay-info-item.active img {
  86. position: absolute;
  87. top: 0;
  88. left: 0;
  89. display: block;
  90. }
  91. .echarts-title {
  92. color: #92959B;
  93. display: flex;
  94. font-size: 16px;
  95. margin-left: 45px;
  96. }
  97. .echarts-title-item {
  98. margin-right: 45px;
  99. display: flex;
  100. align-items: center;
  101. }
  102. .echarts-title-item .echarts-title-icon {
  103. height: 16px;
  104. width: 16px;
  105. margin-right: 10px;
  106. background-color: #3399ff;
  107. }
  108. .table-area {
  109. margin-top: 20px;
  110. display: flex;
  111. justify-content: space-between;
  112. }
  113. .table-area .el-card {
  114. width: 49.5%;
  115. color: #303133;
  116. }
  117. .el-tabs__header {
  118. margin-bottom: 0 !important;
  119. }
  120. .el-card__header {
  121. position: relative;
  122. }
  123. .sort-active {
  124. color: #3399ff;
  125. }
  126. .select-item {
  127. border: 1px solid #3399ff;
  128. margin-top: -1px !important;
  129. }
  130. .el-popper .popper__arrow, .el-popper .popper__arrow::after {
  131. display: none;
  132. }
  133. .el-select-dropdown__item.hover, .el-select-dropdown__item:hover {
  134. background-color: #3399ff;
  135. color: #fff;
  136. }
  137. .table-area .el-card__header {
  138. padding: 14px 20px;
  139. }
  140. .text-omit {
  141. width: 380px;
  142. overflow: hidden;
  143. text-overflow: ellipsis;
  144. white-space: nowrap;
  145. }
  146. .el-dialog {
  147. min-width:300px;
  148. }
  149. </style>
  150. <div id="app" v-cloak>
  151. <el-card v-loading="loading" shadow="never" style="border:0;min-width: 1200px;"
  152. body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  153. <div slot="header">
  154. <div style="display:flex;justify-content:space-between;">
  155. <span style="padding: 5px 10px;">数据概况</span>
  156. <div style="padding: 5px 10px;background-color: red;font-weight:bold;color:#fff;">
  157. <span v-if="store.expire_time > 0">门店有效期至 {{store.expire_time | dateTimeFormat('Y-m-d')}}</span>
  158. <span v-else>无限期</span>
  159. </div>
  160. </div>
  161. </div>
  162. <div class="table-body">
  163. <!-- 数据总览 -->
  164. <div class="num-info">
  165. <div class="num-info-item">
  166. <div class="info-item-name">
  167. <span>待发货订单(笔)</span>
  168. </div>
  169. <div>{{store.no_delivery_counts}}</div>
  170. </div>
  171. <div class="num-info-item">
  172. <div class="info-item-name">待售后订单(笔)</div>
  173. <div>{{store.after_sale_counts}}</div>
  174. </div>
  175. <div class="num-info-item">
  176. <div class="info-item-name">待付款订单(笔)</div>
  177. <div>{{store.no_pay_counts}}</div>
  178. </div>
  179. <div class="num-info-item">
  180. <div class="info-item-name">已售罄商品(个)</div>
  181. <div>{{store.sell_out_counts}}</div>
  182. </div>
  183. </div>
  184. </div>
  185. <!-- 销售情况 -->
  186. <el-card shadow="never">
  187. <div slot="header">
  188. <span>经营概况</span>
  189. <div class="tab-pay">
  190. <el-tabs v-model="activeDay" @tab-click="tab_pay">
  191. <el-tab-pane label="昨日" name="one"></el-tab-pane>
  192. <el-tab-pane label="近7天" name="seven"></el-tab-pane>
  193. <el-tab-pane label="近30天" name="thirty"></el-tab-pane>
  194. </el-tabs>
  195. </div>
  196. </div>
  197. <!-- 选择框 -->
  198. <div class="pay-info">
  199. <div class="pay-info-item" >
  200. <img src="statics/img/mall/statistic/active.png" alt="">
  201. <div >成交额</div>
  202. <div class="info-item-name">¥:{{today_data.sales_money}}</div>
  203. <div class="info-item-name">昨日:{{yesterday_data.sales_money}}</div>
  204. </div>
  205. <div class="pay-info-item" >
  206. <img src="statics/img/mall/statistic/active.png" alt="">
  207. <div >新增会员</div>
  208. <div class="info-item-name">{{today_data.add_user_nums}}</div>
  209. <div class="info-item-name">昨日:{{yesterday_data.add_user_nums}}</div>
  210. </div>
  211. <div class="pay-info-item" >
  212. <img src="statics/img/mall/statistic/active.png" alt="">
  213. <div >订单数</div>
  214. <div class="info-item-name">{{today_data.order_nums}}</div>
  215. <div class="info-item-name">昨日:{{yesterday_data.order_nums}}</div>
  216. </div>
  217. <div class="pay-info-item" >
  218. <img src="statics/img/mall/statistic/active.png" alt="">
  219. <div >收银台</div>
  220. <div class="info-item-name">¥:{{today_data.cashier_sales_money}}</div>
  221. <div class="info-item-name">昨日:{{yesterday_data.cashier_sales_money}}</div>
  222. </div>
  223. <div class="pay-info-item" >
  224. <img src="statics/img/mall/statistic/active.png" alt="">
  225. <div >结算佣金</div>
  226. <div class="info-item-name">¥:{{today_data.settlement_commission}}</div>
  227. <div class="info-item-name">昨日:{{yesterday_data.settlement_commission}}</div>
  228. </div>
  229. </div>
  230. </el-card>
  231. <br/>
  232. <el-card shadow="never">
  233. <div slot="header">
  234. <span>图表</span>
  235. <div class="tab-pay">
  236. </div>
  237. </div>
  238. <div class="echarts-title">
  239. <div class="echarts-title-item" v-if="order">
  240. <div class="echarts-title-icon"></div>
  241. <div>门店销售额</div>
  242. </div>
  243. <div class="echarts-title-item" v-if="price">
  244. <div style="background-color: #FFA360;" class="echarts-title-icon"></div>
  245. <div>收银台销售额</div>
  246. </div>
  247. </div>
  248. <div id="echarts" style="height:18rem;"></div>
  249. </el-card>
  250. <div class="table-area">
  251. <el-card shadow="never">
  252. <div slot="header">
  253. <span style="float: left;height: 32px;line-height: 32px">商品销量排行(TOP5)</span>
  254. <div flex="dir:right" style="">
  255. </div>
  256. </div>
  257. <el-table v-loading="goods_loading" :row-style="{height:'63px'}"
  258. :header-cell-style="{background:'#F3F5F6','color':'#303133'}" :data="goods_top_list">
  259. <el-table-column align="center" label="排名">
  260. <template slot-scope="scope">
  261. <img style="margin-top: 3px" v-if="scope.$index == 0"
  262. src="resources/img/mall/statistic/first.png" alt="">
  263. <img style="margin-top: 3px" v-else-if="scope.$index == 1"
  264. src="resources/img/mall/statistic/sec.png" alt="">
  265. <img style="margin-top: 3px" v-else-if="scope.$index == 2"
  266. src="resources/img/mall/statistic/third.png" alt="">
  267. <span v-else-if="scope.$index < 9">0{{scope.$index+1}}</span>
  268. <span v-else>{{scope.$index+1}}</span>
  269. </template>
  270. </el-table-column>
  271. <el-table-column prop="name" width="400" label="商品">
  272. <template slot-scope="scope">
  273. <div class="text-omit">{{scope.row.goods_name}}</div>
  274. </template>
  275. </el-table-column>
  276. <el-table-column prop="pay_money" label="销售额" width="150"
  277. :label-class-name="goodsProp == 'pay_money' ? 'sort-active': ''">
  278. <template slot-scope="scope">
  279. {{scope.row.sales_money ? scope.row.sales_money.toFixed(2) : 0}}
  280. </template>
  281. </el-table-column>
  282. </el-table>
  283. </el-card>
  284. <el-card shadow="never">
  285. <div slot="header">
  286. <span style="float: left;height: 32px;line-height: 32px">会员消费排行(TOP5)</span>
  287. <div flex="dir:right" style="">
  288. </div>
  289. </div>
  290. <el-table v-loading="user_loading" :row-style="{height:'63px'}"
  291. :header-cell-style="{background:'#F3F5F6','color':'#303133'}" :data="user_top_list">
  292. <el-table-column align="center" label="排名">
  293. <template slot-scope="scope">
  294. <img style="margin-top: 3px" v-if="scope.$index == 0"
  295. src="resources/img/mall/statistic/first.png" alt="">
  296. <img style="margin-top: 3px" v-else-if="scope.$index == 1"
  297. src="resources/img/mall/statistic/sec.png" alt="">
  298. <img style="margin-top: 3px" v-else-if="scope.$index == 2"
  299. src="resources/img/mall/statistic/third.png" alt="">
  300. <span v-else-if="scope.$index < 9">0{{scope.$index+1}}</span>
  301. <span v-else>{{scope.$index+1}}</span>
  302. </template>
  303. </el-table-column>
  304. <el-table-column prop="name" label="用户" width="400">
  305. <template slot-scope="scope">
  306. <com-image style="margin-right: 10px;float: left;" :src="scope.row.avatar_url" :default_src = "'/resources/img/common/default-avatar.png'" width="32px"
  307. height="32px">
  308. </com-image>
  309. <span class="text-omit"
  310. style="height: 32px;line-height: 32px;display: inline-block;width: 280px">{{scope.row.nickname}}</span>
  311. </template>
  312. </el-table-column>
  313. <el-table-column prop="pay_money" label="消费总金额" width="150"
  314. :label-class-name="userProp == 'pay_money.toFixed(2)' ? 'sort-active': ''"
  315. >
  316. </el-table-column>
  317. </el-table>
  318. </el-card>
  319. </div>
  320. <el-dialog
  321. title="提醒"
  322. :visible.sync="dialogVisible"
  323. width="20%"
  324. top="30vh"
  325. :before-close="handleClose">
  326. <div style="display:flex;justify-content:center;align-items:center;padding-top:10px;">
  327. <span><i class="el-icon-alarm-clock" style="font-size:30px;color:red;"></i></span>
  328. <span style="margin-left:5px;">门店有效期至{{store.expire_time | dateTimeFormat('Y-m-d')}}</span>
  329. </div>
  330. <span slot="footer" class="dialog-footer">
  331. <el-button @click="dialogVisible = false">取 消</el-button>
  332. </span>
  333. </el-dialog>
  334. </el-card>
  335. </div>
  336. <script>
  337. const app = new Vue({
  338. el: '#app',
  339. data() {
  340. return {
  341. // 今天
  342. today: '',
  343. // 七天前
  344. weekDay: '',
  345. // 30天前
  346. monthDay: '',
  347. // 加载动画
  348. loading: false,
  349. goods_loading: false,
  350. user_loading: false,
  351. // 销售情况选中情况
  352. order: true,
  353. price: true,
  354. people: true,
  355. num: true,
  356. // 日期选中状态
  357. activeName: '',
  358. day:1,
  359. // 搜索内容
  360. search: {
  361. mch: null,
  362. time: null,
  363. date_start: null,
  364. date_end: null,
  365. platform: '',
  366. pay_type: '',
  367. },
  368. // 总体数据
  369. all_data: {
  370. goods_num: "0",
  371. order_num: "0",
  372. pro_order: "0",
  373. user_count: "0",
  374. wait_send_num: "0"
  375. },
  376. // 店铺列表
  377. mch_list: [],
  378. // 销售总计
  379. table_data: {
  380. order_num: 0,
  381. total_pay_price: 0,
  382. user_count: 0,
  383. goods_num: 0,
  384. },
  385. // 销售情况
  386. table_list: {
  387. order_num: '0',
  388. total_pay_price: '0',
  389. user_num: '0',
  390. goods_num: '0',
  391. },
  392. // 商品排行
  393. goods_top_list: [],
  394. // 用户排行
  395. user_top_list: [],
  396. // 时段
  397. pay_day: [],
  398. // 图表X轴
  399. echarts_item: ['门店销售额', '收银台销售额'],
  400. // 图表参数
  401. series: [
  402. {
  403. name: '门店销售额',
  404. type: 'line',
  405. data: []
  406. },
  407. {
  408. name: '收银台销售额',
  409. type: 'line',
  410. data: []
  411. },
  412. ],
  413. activeDay: 'one',
  414. sort_order: null,
  415. userProp: '',
  416. goodsProp: '',
  417. user_url: '<?= $urlManager->createUrl('mall/data-statistics/users_top')?>',
  418. goods_url: '<?= $urlManager->createUrl('mall/data-statistics/goods_top')?>',
  419. is_mch_role: true,
  420. store:{},
  421. today_data:{},
  422. yesterday_data:{},
  423. dialogVisible: false,
  424. };
  425. },
  426. methods: {
  427. // 获取数据
  428. getList() {
  429. this.loading = true;
  430. this.series[0].data = [];
  431. this.series[1].data = [];
  432. this.order_num = 0;
  433. this.total_pay_price = 0;
  434. this.user_num = 0;
  435. this.goods_num = 0;
  436. this.pay_day = [];
  437. const _csrf = '<?=Yii::$app->request->csrfToken?>';
  438. request({
  439. params: {
  440. r: 'store/client/index/index',
  441. },
  442. data: {
  443. _csrf,
  444. date_start: this.search.date_start,
  445. date_end: this.search.date_end,
  446. mch_id: this.search.mch,
  447. platform: this.search.platform,
  448. pay_type: this.search.pay_type,
  449. },
  450. method: 'post',
  451. }).then(e => {
  452. this.loading = false;
  453. if (e.data.code == 0) {
  454. // this.all_data = e.data.data;
  455. //this.mch_list = e.data.data.mch_list;
  456. this.goods_top_list = e.data.data.goods_ranking_list;
  457. this.user_top_list = e.data.data.user_ranking_list;
  458. this.today_data = e.data.data.today_data;
  459. this.yesterday_data = e.data.data.yesterday_data;
  460. this.store = e.data.data.store;
  461. if (e.data.data.store.is_alert) this.dialogVisible = true;
  462. this.tab_pays(e.data.data.table_list,[]);
  463. } else {
  464. this.$message.error(e.data.msg);
  465. }
  466. }).catch(e => {
  467. this.loading = false;
  468. });
  469. },
  470. //排行榜数据
  471. // 生成图表
  472. form() {
  473. let that = this;
  474. var myChart = echarts.init(document.getElementById('echarts'));
  475. myChart.setOption({
  476. tooltip: {
  477. trigger: 'axis',
  478. backgroundColor: '#fff',
  479. textStyle: {color: '#303133'},
  480. padding: 20,
  481. extraCssText: 'box-shadow: 0 0 4px rgba(0, 0, 0.1);'
  482. },
  483. legend: {
  484. show: false,
  485. data: that.echarts_item
  486. },
  487. color: ['#3399FF', '#FFA360', '#4BC282', '#FF8585'],
  488. grid: {
  489. left: '0',
  490. right: '4%',
  491. bottom: '3%',
  492. containLabel: true
  493. },
  494. xAxis: {
  495. type: 'category',
  496. boundaryGap: false,
  497. data: that.pay_day
  498. },
  499. yAxis: {
  500. splitLine: {
  501. show: true,
  502. lineStyle: {
  503. type: 'dashed'
  504. }
  505. },
  506. axisLine: {
  507. show: false
  508. },
  509. axisLabel: {
  510. show: false
  511. },
  512. axisLabel: {
  513. show: false
  514. },
  515. type: 'value'
  516. },
  517. series: that.series
  518. });
  519. myChart.showLoading({text: '正在加载数据'});
  520. },
  521. // 切换图表区间
  522. tab_pays(table_list,table_data) {
  523. this.order = true;
  524. this.price = true;
  525. this.people = true;
  526. this.num = true;
  527. this.series[0].data = [];
  528. this.series[1].data = [];
  529. this.sales_money = 0;
  530. this.cashier_sales_money = 0;
  531. this.user_num = 0;
  532. this.goods_num = 0;
  533. this.pay_day = [];
  534. this.form();
  535. let date_start;
  536. let date_end;
  537. if (this.activeDay == 'seven') {
  538. this.day = 7;
  539. } else {
  540. this.day = 1;
  541. }
  542. this.table_list = table_list;
  543. this.table_data = table_data;
  544. for (let i = 0; i < this.table_list.length; i++) {
  545. this.pay_day.push(this.table_list[i].created_at)
  546. this.series[0].data.push(this.table_list[i].sales_money);
  547. this.series[1].data.push(this.table_list[i].cashier_sales_money);
  548. //支付订单数 支付金额 支付人数 支付件数
  549. }
  550. this.form();
  551. var myChart = echarts.init(document.getElementById('echarts'));
  552. myChart.hideLoading();
  553. },
  554. tab_pay() {
  555. request({
  556. params: {
  557. r: 'store/client/index/to-pay',
  558. },
  559. data: {
  560. activeDay: this.activeDay,
  561. },
  562. method: 'post',
  563. }).then(e => {
  564. this.loading = false;
  565. if (e.data.code == 0) {
  566. this.today_data = e.data.data.today_data;
  567. } else {
  568. this.$message.error(e.data.msg);
  569. }
  570. }).catch(e => {
  571. this.loading = false;
  572. });
  573. },
  574. handleClose(done) {
  575. done();
  576. }
  577. },
  578. created() {
  579. this.getList();
  580. this.tab_pay();
  581. },
  582. })
  583. </script>