From 3e1e5aee869ad76bc39a4e223746cda6b06d2b3a Mon Sep 17 00:00:00 2001 From: wanyongkang <937888580@qq.com> Date: Wed, 25 Nov 2020 09:58:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=B4=E6=8A=A4=E7=94=A8=E6=88=B7=E9=94=80?= =?UTF-8?q?=E5=94=AE=E7=BB=9F=E8=AE=A1=E2=80=94=E2=80=94=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/manager/controller/UserFollow.php | 46 +++++++++++++++++++++++++-- app/manager/model/ProductOrder.php | 16 +++++++++- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/app/manager/controller/UserFollow.php b/app/manager/controller/UserFollow.php index 9eca5bc..a8cde4b 100644 --- a/app/manager/controller/UserFollow.php +++ b/app/manager/controller/UserFollow.php @@ -5,7 +5,7 @@ * @Author: kangkang * @Date: 2020-10-13 19:52:37 * @LastEditors: Please set LastEditors - * @LastEditTime: 2020-11-24 15:55:55 + * @LastEditTime: 2020-11-25 09:51:47 */ namespace app\manager\controller; @@ -296,8 +296,48 @@ class UserFollow extends Controller } $id = $_GET['id']; $index = $_GET['index']; - $user_score_model = new UserScore; - \result($user_score_model->getUserCost($id, $index)); + $where = ''; + $list = []; + + $product_order_model = new ProductOrder; + $product_order_enum = new ProductOrderEnum; + + if (isset($_GET['search'])) { + $search = $_GET['search']; + $flag = date("d", time()) == date("t", time()); + $date1 = date("Y-m-01", strtotime("-1 month")); + $date2 = $flag ? date("Y-m-t H:i:s", strtotime("-1 month")) : date("Y-m-d H:i:s", strtotime("-1 month")); + $date3 = date("Y-m-01", time()); + $date4 = date("Y-m-d H:i:s", time()); + if (!empty($search['last_month']['s_time'])) { + $date1 = date('Y-m-d', strtotime($search['last_month']['s_time'])); + $date2 = date('Y-m-d H:i:s', strtotime($search['last_month']['e_time'])); + } elseif (!empty($search['new_month']['s_time'])) { + $date3 = date('Y-m-d', strtotime($search['new_month']['s_time'])); + $date4 = date('Y-m-d H:i:s', strtotime($search['new_month']['e_time'])); + } + } + + switch ($index) { + case 2: + //上月 + $where .= " UpdateTime>='" . $date1 . "' and UpdateTime<='" . $date2 . "' "; + break; + case 3: + //本月 + $where .= " UpdateTime>='" . $date3 . "' and UpdateTime<='" . $date4 . "' "; + break; + } + + $data = $product_order_model->getUserCost($id, $index, $where); + + foreach ($data as $info) { + $info['OrderType'] = $product_order_enum::$OrderType[$info['OrderType']]; + $info['PayType'] = $product_order_enum::$ScoreName[$info['PayType']]; + $list[] = $info; + } + + \result($list); } /** diff --git a/app/manager/model/ProductOrder.php b/app/manager/model/ProductOrder.php index 56ed425..11ae495 100644 --- a/app/manager/model/ProductOrder.php +++ b/app/manager/model/ProductOrder.php @@ -5,7 +5,7 @@ * @Author: kangkang * @Date: 2020-10-16 14:44:02 * @LastEditors: Please set LastEditors - * @LastEditTime: 2020-11-24 15:53:12 + * @LastEditTime: 2020-11-25 09:46:23 */ namespace app\manager\model; @@ -203,4 +203,18 @@ class ProductOrder extends Model ->group(['UserId'],$having) ->fetchAll(); } + + /** + * @description: 获取用户所有的消费记录 + * @param {*} + * @return {*} + */ + public function getUserCost($user_id, $index, $where='') + { + return $this->field('UpdateTime,OrderNo,OrderType,ProductName,PackageName,PaymentAmount,Accounts,ConnectCount,PayType') + ->where(['UserId' => $user_id]) + ->where($where) + ->order('Id desc') + ->fetchAll(); + } }