sale-statistics.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. $urlManager = Yii::$app->urlManager;
  4. ComponentHelper::loadComponentView('com-search', __DIR__);
  5. ComponentHelper::loadComponentView('com-header', __DIR__);
  6. ?>
  7. <style>
  8. .el-tabs__nav-wrap::after {
  9. height: 1px;
  10. }
  11. .table-body {
  12. background-color: #fff;
  13. position: relative;
  14. margin-bottom: 10px;
  15. border: 1px solid #EBEEF5;
  16. }
  17. .table-body .search .el-tabs {
  18. margin-left: 10px;
  19. }
  20. .table-body .search .el-tabs__nav-scroll {
  21. width: 120px;
  22. margin-left: 30px;
  23. }
  24. .table-body .search .el-tabs__header {
  25. margin-bottom: 0;
  26. }
  27. .table-body .search .el-tabs__item {
  28. height: 32px;
  29. line-height: 32px;
  30. }
  31. .table-body .search .el-form-item {
  32. margin-bottom: 0
  33. }
  34. .table-body .search .clean {
  35. color: #92959B;
  36. margin-left: 20px;
  37. cursor: pointer;
  38. font-size: 15px;
  39. }
  40. .table-area {
  41. margin: 10px 0;
  42. display: flex;
  43. justify-content: space-between;
  44. }
  45. .table-area .el-card {
  46. width: 49.5%;
  47. color: #303133;
  48. }
  49. .num-info {
  50. display: flex;
  51. width: 100%;
  52. height: 60px;
  53. font-size: 24px;
  54. color: #303133;
  55. margin: 20px 0;
  56. }
  57. .num-info .num-info-item {
  58. text-align: center;
  59. flex-grow: 1;
  60. border-left: 1px dashed #EFF1F7;
  61. }
  62. .num-info .num-info-item:first-of-type {
  63. border-left: 0;
  64. }
  65. .info-item-name {
  66. font-size: 14px;
  67. color: #92959B;
  68. }
  69. .select-item {
  70. border: 1px solid #3399ff;
  71. margin-top: -1px!important;
  72. }
  73. .el-popper .popper__arrow, .el-popper .popper__arrow::after {
  74. display: none;
  75. }
  76. .el-select-dropdown__item.hover, .el-select-dropdown__item:hover {
  77. background-color: #3399ff;
  78. color: #fff;
  79. }
  80. </style>
  81. <div id="app" v-cloak>
  82. <el-card v-loading="loading" shadow="never" style="border:0" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  83. <div slot="header">
  84. <com-header @export-data="exportData" :url="url" :new-search="JSON.stringify(search)">数据概况</com-header>
  85. </div>
  86. <div class="table-body">
  87. <com-search
  88. @to-search="toSearch"
  89. @search="searchList"
  90. :new-search="search"
  91. :is-show-pay-type="true"
  92. :is-show-keyword="false"
  93. :day-data="{'today':today, 'weekDay': weekDay, 'monthDay': monthDay}">
  94. </com-search>
  95. </div>
  96. <div class="table-area">
  97. <el-card shadow="never">
  98. <div slot="header">
  99. <span>总成交</span>
  100. </div>
  101. <div class="num-info">
  102. <div class="num-info-item">
  103. <div>{{all.pay_num||0}}</div>
  104. <div class="info-item-name">付款订单数/个</div>
  105. </div>
  106. <div class="num-info-item">
  107. <div>{{all.pay_goods_num||0}}</div>
  108. <div class="info-item-name">付款件数/件</div>
  109. </div>
  110. <div class="num-info-item">
  111. <div>{{all.user_num||0}}</div>
  112. <div class="info-item-name">付款人数/人</div>
  113. </div>
  114. <div class="num-info-item">
  115. <div>{{all.pay_money||0}}</div>
  116. <div class="info-item-name">付款金额/元</div>
  117. </div>
  118. </div>
  119. </el-card>
  120. <el-card shadow="never">
  121. <div slot="header">
  122. <span>今日实时成交</span>
  123. </div>
  124. <div class="num-info">
  125. <div class="num-info-item">
  126. <div>{{now.pay_num||0}}</div>
  127. <div class="info-item-name">付款订单数/个</div>
  128. </div>
  129. <div class="num-info-item">
  130. <div>{{now.pay_goods_num||0}}</div>
  131. <div class="info-item-name">付款件数/件</div>
  132. </div>
  133. <div class="num-info-item">
  134. <div>{{now.user_num||0}}</div>
  135. <div class="info-item-name">付款人数/人</div>
  136. </div>
  137. <div class="num-info-item">
  138. <div>{{now.pay_money||0}}</div>
  139. <div class="info-item-name">付款金额/元</div>
  140. </div>
  141. </div>
  142. </el-card>
  143. </div>
  144. <div class="table-body" style="padding: 20px">
  145. <!-- <el-tabs v-model="search.status" @tab-click="tab_order">-->
  146. <!-- <el-tab-pane label="全部" name="0"></el-tab-pane>-->
  147. <!-- <el-tab-pane label="已完成订单" name="1"></el-tab-pane>-->
  148. <!-- <el-tab-pane label="已取消订单" name="2"></el-tab-pane>-->
  149. <!-- <el-tab-pane label="已完成售后订单" name="3"></el-tab-pane>-->
  150. <!-- </el-tabs>-->
  151. <el-table v-loading="list_loading" :header-cell-style="{background:'#F3F5F6','color':'#303133',padding: '6px 0',fontWeight: '400'}" :data="list">
  152. <el-table-column prop="date" label="日期"></el-table-column>
  153. <el-table-column prop="user_num" label="付款人数"></el-table-column>
  154. <el-table-column prop="order_num" label="付款订单数"></el-table-column>
  155. <el-table-column prop="order_money" label="付款金额"></el-table-column>
  156. <el-table-column prop="goods_num" label="付款件数"></el-table-column>
  157. </el-table>
  158. <div style="margin-top: 10px;" flex="box:last cross:center">
  159. <div style="visibility: hidden">
  160. <el-button plain type="primary" size="small">批量操作1</el-button>
  161. <el-button plain type="primary" size="small">批量操作2</el-button>
  162. </div>
  163. <div>
  164. <el-pagination
  165. v-if="pagination"
  166. style="display: inline-block;float: right;"
  167. background
  168. :page-size="pagination.defaultPageSize"
  169. @current-change="pageChange"
  170. layout="prev, pager, next"
  171. :current-page="pagination.current_page"
  172. :total="pagination.totalCount">
  173. </el-pagination>
  174. </div>
  175. </div>
  176. </div>
  177. </el-card>
  178. </div>
  179. <script>
  180. const app = new Vue({
  181. el: '#app',
  182. data() {
  183. return {
  184. url: '<?= $urlManager->createUrl('mall/order-statistics/index')?>',
  185. loading: false,
  186. list_loading: false,
  187. mch_name:'',
  188. // 今天
  189. today: '',
  190. // 七天前
  191. weekDay: '',
  192. // 30天前
  193. monthDay: '',
  194. // 搜索内容
  195. search: {
  196. mch_id: null,
  197. time: null,
  198. platform: '',
  199. status: '0',
  200. },
  201. all: {goods_num:0,user_num:0,total_pay_price:0,pay_num:0},
  202. list: [],
  203. mch_list: [],
  204. now: {goods_num:0,user_num:0,total_pay_price:0,pay_num:0},
  205. pagination: [],
  206. page: 1,
  207. isShowPayType:true,
  208. isShowKeyword:false,
  209. statusObj: {
  210. '0': {
  211. order_num: "付款订单数",
  212. order_money: "付款金额",
  213. goods_num: "付款件数"
  214. },
  215. '1': {
  216. order_num: "完成订单数",
  217. order_money: "完成订单金额",
  218. goods_num: "完成订单商品件数"
  219. },
  220. '2': {
  221. order_num: "取消订单数",
  222. order_money: "取消订单金额",
  223. goods_num: "取消订单商品件数"
  224. },
  225. '3': {
  226. order_num: "退款订单数",
  227. order_money: "退款订单金额",
  228. goods_num: "退款订单商品件数"
  229. }
  230. }
  231. };
  232. },
  233. methods: {
  234. tabMch() {
  235. for(let i = 0; i< this.mch_list.length;i++) {
  236. if(this.mch_list[i].id == this.search.mch_id) {
  237. this.mch_name = this.mch_list[i].name
  238. }
  239. }
  240. this.getList();
  241. },
  242. // 切页
  243. pageChange(currentPage) {
  244. this.page = currentPage;
  245. this.getList();
  246. },
  247. // 获取数据
  248. getList() {
  249. this.loading = true;
  250. request({
  251. params: {
  252. r: 'mall/statistics/sale-statistics',
  253. status: this.search.status,
  254. date_start: this.search.date_start,
  255. date_end: this.search.date_end,
  256. platform: this.search.platform,
  257. pay_type: this.search.pay_type,
  258. page: this.page,
  259. },
  260. method: 'get',
  261. }).then(e => {
  262. this.loading = false;
  263. if (e.data.code === 0) {
  264. this.list = e.data.data.list;
  265. this.pagination = e.data.data.pagination;
  266. this.now = e.data.data.now_data;
  267. this.all = e.data.data.all_data;
  268. }
  269. }).catch(e => {
  270. this.loading = false;
  271. });
  272. },
  273. // 切换订单状态
  274. tab_order() {
  275. this.list_loading = true;
  276. request({
  277. params: {
  278. r: 'mall/statistics/sale-statistics',
  279. status: this.search.status,
  280. mch_id: this.search.mch_id,
  281. date_start: this.search.date_start,
  282. date_end: this.search.date_end,
  283. platform: this.search.platform,
  284. },
  285. method: 'get',
  286. }).then(e => {
  287. this.list_loading = false;
  288. if (e.data.code === 0) {
  289. this.list = e.data.data.list;
  290. this.pagination = e.data.data.pagination;
  291. } else {
  292. this.$message.error(e.data.msg);
  293. }
  294. }).catch(e => {
  295. this.list_loading = false;
  296. });
  297. },
  298. toSearch(searchData) {
  299. this.search = searchData;
  300. this.page = 1;
  301. this.getList();
  302. },
  303. searchList(searchData) {
  304. this.search = searchData;
  305. this.page = 1;
  306. this.getList();
  307. },
  308. exportData() {
  309. request({
  310. params: {
  311. r: 'mall/statistics/export'
  312. },
  313. data : {type: 'sale-statistics'},
  314. method: 'post',
  315. }).then(e => {
  316. if (e.data.code == 0) {
  317. this.$message.success(e.data.msg);
  318. } else {
  319. this.$message.error(e.data.msg);
  320. }
  321. this.goods_loading = false;
  322. this.user_loading = false;
  323. }).catch(e => {
  324. this.goods_loading = false;
  325. this.user_loading = false;
  326. this.$message.error('未知错误');
  327. });
  328. }
  329. },
  330. created() {
  331. this.getList();
  332. let date = new Date();
  333. let timestamp = date.getTime();
  334. let seperator1 = "-";
  335. let year = date.getFullYear();
  336. let nowMonth = date.getMonth() + 1;
  337. let strDate = date.getDate();
  338. if (nowMonth >= 1 && nowMonth <= 9) {
  339. nowMonth = "0" + nowMonth;
  340. }
  341. if (strDate >= 0 && strDate <= 9) {
  342. strDate = "0" + strDate;
  343. }
  344. this.today = year + seperator1 + nowMonth + seperator1 + strDate;
  345. let week = new Date(timestamp - 7 * 24 * 3600 * 1000)
  346. let weekYear = week.getFullYear();
  347. let weekMonth = week.getMonth() + 1;
  348. let weekStrDate = week.getDate();
  349. if (weekMonth >= 1 && weekMonth <= 9) {
  350. weekMonth = "0" + weekMonth;
  351. }
  352. if (weekStrDate >= 0 && weekStrDate <= 9) {
  353. weekStrDate = "0" + weekStrDate;
  354. }
  355. this.weekDay = weekYear + seperator1 + weekMonth + seperator1 + weekStrDate;
  356. let month = new Date(timestamp - 30 * 24 * 3600 * 1000);
  357. let monthYear = month.getFullYear();
  358. let monthMonth = month.getMonth() + 1;
  359. let monthStrDate = month.getDate();
  360. if (monthMonth >= 1 && monthMonth <= 9) {
  361. monthMonth = "0" + monthMonth;
  362. }
  363. if (monthStrDate >= 0 && monthStrDate <= 9) {
  364. monthStrDate = "0" + monthStrDate;
  365. }
  366. this.monthDay = monthYear + seperator1 + monthMonth + seperator1 + monthStrDate;
  367. }
  368. })
  369. </script>