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(); + } }