From 38b1e3aab1de80ea5484a22c54dc7b0fdfa2330b Mon Sep 17 00:00:00 2001 From: xucong <850806214@qq.com> Date: Thu, 15 May 2025 15:51:09 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=8F=90=E4=BA=A4=E7=BC=BA=E5=A4=B1=E7=9A=84?= =?UTF-8?q?=E4=B8=9C=E8=A5=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/RechargeController.php | 13 ++++++- app/api/logic/RechargeLogic.php | 43 +++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/app/api/controller/RechargeController.php b/app/api/controller/RechargeController.php index b63c35f..98285a5 100755 --- a/app/api/controller/RechargeController.php +++ b/app/api/controller/RechargeController.php @@ -69,5 +69,16 @@ class RechargeController extends BaseApiController return $this->data(RechargeLogic::config($this->userId)); } - + /** + * 充值记录 + */ + public function rechargeRecord() + { + $get = $this->request->get(); + $get['page_no'] = $get['page_no'] ?? $this->page_no; + $get['page_size'] = $get['page_size'] ?? $this->page_size; + $get['user_id'] = $this->userId; + $result = RechargeLogic::rechargeRecord($get); + return $this->success('',$result); + } } \ No newline at end of file diff --git a/app/api/logic/RechargeLogic.php b/app/api/logic/RechargeLogic.php index 3fe2e45..c1413e8 100755 --- a/app/api/logic/RechargeLogic.php +++ b/app/api/logic/RechargeLogic.php @@ -19,6 +19,7 @@ use app\common\logic\BaseLogic; use app\common\model\recharge\RechargeOrder; use app\common\model\user\User; use app\common\service\ConfigService; +use think\facade\Db; /** @@ -79,7 +80,49 @@ class RechargeLogic extends BaseLogic ]; } + /** + * 充值记录 + */ + public static function rechargeRecord($get) + { + $list = Db::name('recharge_order') + ->field('order_sn, order_amount, give_money, create_time') + ->where([ + 'user_id' => $get['user_id'], + 'pay_status' => 1 + ]) + ->order('create_time', 'desc') + ->page($get['page_no'], $get['page_size']) + ->select(); + $count = Db::name('recharge_order') + ->where([ + 'user_id' => $get['user_id'], + 'pay_status' => 1 + ]) + ->count(); + + foreach($list as &$item) { + $item['create_time'] = date('Y-m-d h:i:s', $item['create_time']); + if($item['give_money'] > 0) { + $item['desc'] = '充值'. $item['order_amount'] . '赠送' . $item['give_money']; + }else{ + $item['desc'] = '充值'. $item['order_amount']; + } + $item['total'] = $item['order_amount'] + $item['give_money']; // 充值金额 + 赠送金额 + } + + $result = [ + 'count' => $count, + 'list' => $list, + 'more' => is_more($count, $get['page_no'], $get['page_size']), + 'count' => $count, + 'page_no' => $get['page_no'], + 'page_size' => $get['page_size'] + ]; + + return $result; + } } \ No newline at end of file