stat.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2021/7/8 0008
  6. * Time: 10:07
  7. */
  8. ?>
  9. <style>
  10. @media screen and (max-width: 1370px) {
  11. #stat_pay {
  12. min-width: 1131px;
  13. }
  14. }
  15. .order_stat{
  16. background: #FFF;
  17. padding: 10px 10px 0;
  18. margin-bottom: 10px;
  19. }
  20. .title{
  21. font-size: 18px;
  22. font-weight: bold;
  23. display: flex;
  24. align-items: center;
  25. height: 40px;
  26. }
  27. .order_stat > .title > .time{
  28. font-size: 13px;
  29. font-weight: 400;
  30. color: #BFBFBF;
  31. margin-left: 20px;
  32. flex: 1;
  33. }
  34. .order_stat .stat_details{
  35. padding: 30px 0;
  36. display: flex;
  37. }
  38. .stat_details .order_module{
  39. flex: 1;
  40. background: #F2F2F2;
  41. margin: 0 5px;
  42. padding: 20px 25px;
  43. }
  44. .order_module{
  45. display: flex;
  46. flex-direction: column;
  47. }
  48. .order_module:last-child{
  49. margin-right: 0;
  50. }
  51. .order_module:first-child{
  52. margin-left: 0;
  53. }
  54. .price{
  55. font-size: 22px;
  56. font-weight: bold;
  57. flex: 1;
  58. word-break: break-all;
  59. }
  60. .oirder_modul_title{
  61. font-size: 12px;
  62. margin-bottom: 10px;
  63. display: flex;
  64. align-items: center;
  65. }
  66. .oirder_modul_title .text{
  67. margin-right: 10px;
  68. }
  69. .stat_icon{
  70. font-size: 19px;
  71. color: #BFBFBF;
  72. }
  73. .total{
  74. display: flex;
  75. margin-bottom: 10px;
  76. }
  77. .pay_total{
  78. flex: 1;
  79. flex-basis: 764px;
  80. background: #FFF;
  81. padding: 10px 10px 15px;
  82. }
  83. .pay_total:last-child{
  84. margin-left: 12px;
  85. }
  86. .el-date-editor .el-range-separator{
  87. padding: 0;
  88. }
  89. .pay_modules{
  90. margin-top: 20px;
  91. display: flex;
  92. flex-wrap: wrap;
  93. }
  94. .module{
  95. /* width: 350px; */
  96. width: 46%;
  97. background: #F7F7F7;
  98. padding: 20px 25px;
  99. margin-bottom: 15px;
  100. display: flex;
  101. }
  102. .module_two{
  103. width: 33%;
  104. background: #F7F7F7;
  105. padding: 20px 25px;
  106. margin-bottom: 15px;
  107. display: flex;
  108. }
  109. .module:nth-child(2n){
  110. margin-left: 30px
  111. }
  112. .no_open{
  113. flex: 1;
  114. color: #2E8FF4;
  115. display: flex;
  116. align-items: center;
  117. justify-content: flex-end;
  118. }
  119. .pay_button{
  120. display: flex;
  121. border: 1px solid #2E8FF4;
  122. border-radius: 4px;
  123. color: #464646;
  124. }
  125. .pay_button div{
  126. background: #FFF;
  127. padding: 10px;
  128. font-size: 14px;
  129. font-weight: 500;
  130. width: 80px;
  131. height: 36px;
  132. border-radius: 4px;
  133. text-align: center;
  134. }
  135. .pay_button .pay_button_sel{
  136. background: #2E8FF4;
  137. color: #FFF;
  138. border-radius: 0;
  139. }
  140. .pay_img{
  141. width: 56px;
  142. height: 56px;
  143. margin-right: 20px;
  144. }
  145. .assets{
  146. color: #848484;
  147. }
  148. .data_chart{
  149. background: #FFF;
  150. padding: 10px 10px 15px;
  151. width: 100%;
  152. position: relative;
  153. /* display: flex; */
  154. }
  155. .data_chart_time{
  156. position: absolute;
  157. top: 10px;
  158. right: 50px;
  159. display: flex;
  160. font-size: 16px;
  161. }
  162. .sel_time{
  163. margin-right: 20px;
  164. padding-bottom: 5px;
  165. }
  166. .sel_time:hover{
  167. cursor:pointer
  168. }
  169. .sel_color{
  170. border-bottom: 2px solid #5ED9A9;
  171. }
  172. .stat_chart{
  173. height:500px;
  174. /* width: 82rem; */
  175. width: 90%;
  176. }
  177. </style>
  178. <div id="stat_pay" v-cloak>
  179. <div class="order_stat">
  180. <div class="title">
  181. <div>订单概况</div>
  182. <div class="time">更新时间:{{update_order_time}}</div>
  183. <el-date-picker
  184. v-model="order_time"
  185. type="month"
  186. placeholder="选择日期"
  187. @change="updateOrderTime"
  188. format='yyyy-MM'
  189. value-format='yyyy-MM'>
  190. </el-date-picker>
  191. <!-- <el-date-picker
  192. v-model="order_time"
  193. type="daterange"
  194. align="right"
  195. unlink-panels
  196. format='yyyy-MM-dd'
  197. range-separator="至"
  198. start-placeholder="开始日期"
  199. end-placeholder="结束日期"
  200. @change="updateOrderTime"
  201. >
  202. </el-date-picker> -->
  203. </div>
  204. <div class="stat_details">
  205. <div class="order_module" v-for="(item,index) in orderTotalArr" :key="item.type">
  206. <div class="oirder_modul_title">
  207. <div class="text">{{item.name}}</div>
  208. <el-tooltip class="item" effect="dark" v-if="item.prompt" :content="item.prompt" placement="bottom">
  209. <i class="el-icon-question stat_icon"></i>
  210. </el-tooltip>
  211. </div>
  212. <div class="price">
  213. {{item.value}}
  214. </div>
  215. </div>
  216. </div>
  217. </div>
  218. <div class="total">
  219. <div class="pay_total">
  220. <div class="title">
  221. <div style="flex:1">支付统计</div>
  222. <!-- <el-date-picker
  223. v-model="order_time"
  224. type="daterange"
  225. align="right"
  226. unlink-panels
  227. range-separator="至"
  228. start-placeholder="开始日期"
  229. end-placeholder="结束日期"
  230. >
  231. </el-date-picker> -->
  232. </div>
  233. <div class="pay_modules">
  234. <div class="module" v-for="(item,index) in rechargeArr" :key="item.type">
  235. <div class="order_module">
  236. <div class="oirder_modul_title" style="margin-bottom: 17px">{{item.name}}</div>
  237. <div class="price">{{item.value}}</div>
  238. <el-link type="info" :underline="false"
  239. style="margin-top: 10px;font-size: 10px;display: flex;justify-content: left">
  240. 含已退款: {{item.refund_value}}
  241. </el-link>
  242. </div>
  243. <!-- <div class="no_open" v-if="item.is_open == 0">-->
  244. <!-- 未开通-->
  245. <!-- </div>-->
  246. </div>
  247. </div>
  248. </div>
  249. <div class="pay_total">
  250. <div class="title">
  251. <div style="flex:1">会员账户资产</div>
  252. <div class="pay_button">
  253. <!-- <div @click="upButton(1)" :class="{pay_button_sel: buttonType == 1}">账户资产</div> -->
  254. <!-- <div @click="upButton(2)" :class="{pay_button_sel: buttonType == 2}">货币</div> -->
  255. <div @click="getAssetsDialog" :class="{pay_button_sel: buttonType == 1}">查看</div>
  256. </div>
  257. </div>
  258. <div class="pay_modules">
  259. <div class="module_two" style="background:#FFF;" v-for="(item,index) in memberAssets" :key="item.type">
  260. <image class="pay_img" :src="item.img"></image>
  261. <div class="assets">
  262. <div>{{item.name}}</div>
  263. <div style="color: #000;margin-top: 5px;">{{item.value}}</div>
  264. </div>
  265. </div>
  266. </div>
  267. </div>
  268. </div>
  269. <div class="data_chart">
  270. <div ref="stat_chart" style="background: #FFF;" class="stat_chart"></div>
  271. <div class="data_chart_time">
  272. <div class="sel_time" :class="{sel_color: chartTimeType == 1}" style="margin-right: 20px;" @click="getChart(1)">近七天</div>
  273. <div class="sel_time" :class="{sel_color: chartTimeType == 2}" @click="getChart(2)">近一个月</div>
  274. </div>
  275. </div>
  276. <el-dialog :close-on-click-modal="false" title="查看" :visible.sync="dialogVisible" width="50%">
  277. <div class="pay_total">
  278. <div class="title">
  279. <el-date-picker
  280. v-model="account_assets_daily_time"
  281. type="date"
  282. @change="updateAccountAssetsDailyTime"
  283. :picker-options="pickerOptions"
  284. placeholder="选择日期"
  285. format="yyyy-MM-dd"
  286. value-format="yyyy-MM-dd"
  287. >
  288. </el-date-picker>
  289. </div>
  290. <div class="text-tip" style="color:red;">仅可查到{{account_assets_daily_limit_date}}后的数据</div>
  291. <div class="pay_modules">
  292. <div class="module_two" style="background:#FFF;" v-for="(item,index) in accountAssetsDaily" :key="item.type">
  293. <image class="pay_img" :src="item.img"></image>
  294. <div class="assets">
  295. <div>{{item.name}}</div>
  296. <div style="color: #000;margin-top: 5px;">{{item.value}}</div>
  297. </div>
  298. </div>
  299. </div>
  300. </div>
  301. </el-dialog>
  302. </div>
  303. <script>
  304. new Vue({
  305. el: '#stat_pay',
  306. data(){
  307. return {
  308. update_order_time: '',
  309. order_time: [],
  310. buttonType: 1,
  311. user_total: null,
  312. order_total: null,
  313. //订单概况
  314. orderTotalArr: {
  315. "order_money":{
  316. type: 'order_amount',
  317. name: '下单总金额',
  318. value: '0.00',
  319. prompt: '平台订单产生的总金额包含待付款和已付款',
  320. },
  321. "not_pay_money":{
  322. type: 'nopaid_amount',
  323. name: '下单待付款',
  324. value: '0.00',
  325. prompt: '平台产生的待支付或已失效订单金额',
  326. },
  327. "pay_money":{
  328. type: 'paid_amount',
  329. name: '下单已付款',
  330. value: '0.00',
  331. prompt: '订单已支付的实际金额',
  332. },
  333. "refund_order_money":{
  334. type: 'refund_amount',
  335. name: '退款金额',
  336. value: '0.00',
  337. prompt: '平台产生的订单退款金额',
  338. },
  339. "deduction_money":{
  340. type: 'discount_amount',
  341. name: '抵扣金额',
  342. value: '0.00',
  343. prompt: '(订单金额-实际支付金额=抵扣金额) 不计算货币',
  344. },
  345. "recharge_money":{
  346. type: 'recharge_amount',
  347. name: '充值金额',
  348. value: '0.00',
  349. prompt: '',
  350. }
  351. },
  352. //支付统计
  353. rechargeArr: {
  354. "balance":{
  355. name: '余额支付',
  356. value: '0.00',
  357. refund_value: '0.00',
  358. },
  359. "wechat":{
  360. name: '微信支付',
  361. value: '0.00',
  362. refund_value: '0.00',
  363. },
  364. "alipay":{
  365. name: '支付宝支付',
  366. value: '0.00',
  367. refund_value: '0.00',
  368. },
  369. "joinpay_pay":{
  370. name: '汇聚支付',
  371. value: '0.00',
  372. refund_value: '0.00',
  373. }
  374. },
  375. // 会员资产
  376. memberAssets: {},
  377. accountInfo: {
  378. "commission_total":{
  379. type: 'income',
  380. value: '0.00',
  381. name: '待提现佣金(元)',
  382. img: 'resources/img/stat/income.png',
  383. },
  384. "balance_total":{
  385. type: 'balance',
  386. value: '0.00',
  387. name: '未使用余额(元)',
  388. img: 'resources/img/stat/balance.png',
  389. },
  390. "score_total":{
  391. type: 'score',
  392. value: '0.00',
  393. name: '未使用积分',
  394. img: 'resources/img/stat/integral.png',
  395. }
  396. },
  397. chartTimeType: 0,
  398. currencyInfo: [],
  399. chartTimeArr: [],
  400. paid_amount_arr: [],
  401. settle_income_arr: [],
  402. dialogVisible:false,
  403. account_assets_daily_time: '',
  404. account_assets_daily_limit_date: '',
  405. pickerOptions: {
  406. disabledDate: (time) => {
  407. return time.getTime() < (new Date(this.account_assets_daily_limit_date).getTime() - 8.64e7);
  408. },
  409. },
  410. account_assets_daily_date: '',
  411. accountAssetsDaily: {
  412. "commission_total": {
  413. type: 'income',
  414. value: '0.00',
  415. name: '待提现佣金(元)',
  416. img: 'resources/img/stat/income.png',
  417. },
  418. "balance_total": {
  419. type: 'balance',
  420. value: '0.00',
  421. name: '未使用余额(元)',
  422. img: 'resources/img/stat/balance.png',
  423. },
  424. "score_total": {
  425. type: 'score',
  426. value: '0.00',
  427. name: '未使用积分',
  428. img: 'resources/img/stat/integral.png',
  429. }
  430. },
  431. }
  432. },
  433. created(){
  434. this.getAssets();
  435. this.getData();
  436. this.getChart();
  437. this.getAssetsDaily();
  438. this.$nextTick(v => {
  439. this.statChart();
  440. })
  441. },
  442. methods:{
  443. getData(){
  444. let that = this;
  445. that.currencyInfo = [];
  446. //that.memberAssets = [];
  447. let date = {
  448. r: '/mall/finance/stat'
  449. }
  450. if(this.order_time){
  451. // date.start_date = this.order_time[0];
  452. // date.end_date = this.order_time[1];
  453. date.order_time = this.order_time;
  454. }
  455. request({
  456. params: date,
  457. method: 'get',
  458. }).then(res => {
  459. if (res.data.code == 0) {
  460. that.update_order_time = res.data.data.update_time;
  461. that.order_time = res.data.data.date;
  462. //订单概况
  463. for (let field in this.orderTotalArr) {
  464. if (res.data.data.orderStatistics[field]) {
  465. this.orderTotalArr[field]['value'] = res.data.data.orderStatistics[field];
  466. } else {
  467. this.orderTotalArr[field]['value'] = '0.00';
  468. }
  469. }
  470. //支付统计
  471. that.rechargeArr = res.data.data.payment_data;
  472. that.memberAssets.push(...that.accountInfo);
  473. }
  474. }).catch(e => {
  475. });
  476. },
  477. //会员账户资产
  478. getAssets(){
  479. let date = {
  480. r: '/mall/finance/account-assets'
  481. }
  482. request({
  483. params: date,
  484. method: 'get',
  485. }).then(res=>{
  486. console.log(res.data.data)
  487. for (let i in this.accountInfo) {
  488. this.accountInfo[i]['value'] = res.data.data[i].toFixed(2);
  489. }
  490. this.memberAssets = this.accountInfo;
  491. }).catch(e => {
  492. });
  493. },
  494. upButton(type){
  495. if(this.butbuttonType == type){
  496. return;
  497. }
  498. this.buttonType = type;
  499. this.memberAssets = [];
  500. if(type == 2){
  501. this.memberAssets.push(...this.currencyInfo);
  502. }else{
  503. //this.memberAssets.push(...this.accountInfo);
  504. }
  505. },
  506. //图表
  507. getChart(type = 1){
  508. if(this.chartTimeType == type){
  509. return;
  510. }
  511. this.chartTimeType = type;
  512. let that = this;
  513. that.chartTimeArr = [];
  514. that.paid_amount_arr = [];
  515. that.settle_income_arr = [];
  516. request({
  517. params: {
  518. r: '/mall/finance/income',
  519. date_type: this.chartTimeType
  520. },
  521. method: 'get',
  522. }).then(res => {
  523. if(res.data.code == 0){
  524. res.data.data.forEach(v => {
  525. that.chartTimeArr.push(v.stat_date);
  526. that.paid_amount_arr.push(v.pay_money.toFixed(2));
  527. that.settle_income_arr.push(v.settled_commission_total.toFixed(2));
  528. });
  529. that.$nextTick(v => {
  530. that.statChart();
  531. })
  532. }
  533. })
  534. },
  535. statChart(){
  536. let echartStat = echarts.init(this.$refs.stat_chart);
  537. let option = {
  538. title: {
  539. text: '收支趋势'
  540. },
  541. tooltip: {
  542. trigger: 'axis'
  543. },
  544. legend: {
  545. x:'center', //可设定图例在左、右、居中
  546. y:'bottom', //可设定图例在上、下、居中
  547. data: ['已结算佣金', '佣金支出']
  548. },
  549. grid: {
  550. left: '1%',
  551. right: '4%',
  552. bottom: '8%',
  553. containLabel: true
  554. },
  555. xAxis: {
  556. type: 'category',
  557. boundaryGap: true, // false 不留白
  558. data: this.chartTimeArr
  559. },
  560. yAxis: {
  561. type: 'value',
  562. // name:'收支趋势'
  563. },
  564. series: [
  565. {
  566. name: '已结算佣金',
  567. type: 'line',
  568. stack: '总量',
  569. itemStyle : {
  570. normal : {
  571. color:'#5ED9A9',
  572. lineStyle:{
  573. color:'#5ED9A9'
  574. }
  575. }
  576. },
  577. data: this.settle_income_arr
  578. },
  579. {
  580. name: '佣金支出',
  581. type: 'line',
  582. stack: '总量',
  583. itemStyle : {
  584. normal : {
  585. color:'#5B8FF9',
  586. lineStyle:{
  587. color:'#5B8FF9'
  588. }
  589. }
  590. },
  591. data: this.paid_amount_arr
  592. }
  593. ]
  594. };
  595. echartStat.setOption(option)
  596. setTimeout(function (){
  597. window.onresize = function () {
  598. echartStat.resize();
  599. }
  600. },200)
  601. },
  602. updateOrderTime(v){
  603. this.order_time = v;
  604. this.getData();
  605. },
  606. toFormatDate: function (date) {
  607. let y = date.getFullYear();
  608. let MM = date.getMonth() + 1;
  609. MM = MM < 10 ? ('0' + MM) : MM;
  610. let d = date.getDate();
  611. d = d < 10 ? ('0' + d) : d;
  612. return y + '-' + MM + '-' + d;
  613. },
  614. getAssetsDialog(){
  615. this.dialogVisible = true;
  616. },
  617. updateAccountAssetsDailyTime(v){
  618. console.log('date date', v);
  619. this.getAssetsDaily(v);
  620. },
  621. getAssetsDaily(search_date = null){
  622. let date = {
  623. r: '/mall/finance/account-assets-daily',
  624. date: search_date,
  625. }
  626. request({
  627. params: date,
  628. method: 'get',
  629. }).then(res=>{
  630. this.account_assets_daily_limit_date = res.data.data.limit_date
  631. this.accountAssetsDaily.balance_total.value = res.data.data.balance_surplus_nums;
  632. this.accountAssetsDaily.commission_total.value = res.data.data.commission_surplus_nums;
  633. this.accountAssetsDaily.score_total.value = res.data.data.score_surplus_nums;
  634. console.log('123', this.accountAssetsDaily);
  635. }).catch(e => {
  636. });
  637. },
  638. }
  639. })
  640. </script>