diff --git a/app/adminapi/validate/recharge/RechargeRefundValidate.php b/app/adminapi/validate/recharge/RechargeRefundValidate.php index e394ac2ff..ba13a9795 100755 --- a/app/adminapi/validate/recharge/RechargeRefundValidate.php +++ b/app/adminapi/validate/recharge/RechargeRefundValidate.php @@ -36,8 +36,8 @@ class RechargeRefundValidate extends BaseValidate ]; protected $message = [ - 'recharge_id.require' => '参数缺失', - 'record_id.require' => '参数缺失', + 'recharge_id.require' => '参数缺失recharge_id', + 'record_id.require' => '参数缺失record_id', ]; diff --git a/app/middleapi/controller/RechargeController.php b/app/middleapi/controller/RechargeController.php new file mode 100644 index 000000000..e50e28bf7 --- /dev/null +++ b/app/middleapi/controller/RechargeController.php @@ -0,0 +1,100 @@ +request->isPost()){ + return $this->fail('请求方式错误'); + } + $params = $this->request->post(['page_no','page_size', 'user_info', 'start_time', 'end_time', 'sn', 'pay_way', 'pay_status' ]); + $where = []; + if (!empty($params['sn'])) { + $where[] = ['ro.sn', '=', $params['sn']]; + } + if (!empty($params['pay_way'])) { + $where[] = ['ro.pay_way', '=', $params['pay_way']]; + } + if (!empty($params['pay_status'])) { + $where[] = ['ro.pay_status', '=', $params['pay_status']]; + } + if (!empty($params['user_info'])) { + $where[] = ['u.sn|u.nickname|u.mobile', 'like', '%' . $params['user_info'] . '%']; + } + if (!empty($params['start_time']) && !empty($params['end_time'])) { + $where[] = ['ro.create_time', 'between', [strtotime($params['start_time']), strtotime($params['end_time'])]]; + } + $pageNo = !empty($params['page_no']) ? $params['page_no'] : 1; + $pageSize = !empty($params['page_size']) ? $params['page_size'] : 20; + $field = 'ro.id,ro.sn,ro.order_amount,ro.pay_way,ro.pay_time,ro.pay_status,ro.create_time,ro.refund_status'; + $field .= ',u.avatar,u.nickname,u.company_id'; + $data = RechargeOrder::alias('ro') + ->join('user u', 'u.id = ro.user_id') + ->join('admin a', 'u.admin_id = a.id') + ->join('company c', 'u.company_id = c.id') + ->field($field) + ->where($where) + ->order('ro.id', 'desc') + ->page($pageNo, $pageSize) + ->append(['pay_status_text', 'pay_way_text']) + ->select() + ->toArray(); + foreach ($data as &$item) { + $item['avatar'] = FileService::getFileUrl($item['avatar']); + $item['pay_time'] = empty($item['pay_time']) ? '' : date('Y-m-d H:i:s', $item['pay_time']); + } + $count = RechargeOrder::alias('ro') + ->join('user u', 'u.id = ro.user_id') + ->join('admin a', 'u.admin_id = a.id') + ->join('company c', 'u.company_id = c.id') + ->where($where)->count(); + $result = [ + 'lists' => $data, + 'count' => $count, + 'page_no' => $pageNo, + 'page_size' => $pageSize + ]; + return $this->success('请求成功',$result); + } + + + /** + * @notes 退款 + * @return \think\response\Json + * @author 段誉 + * @date 2023/2/28 17:29 + */ + public function refund() + { + $params = (new RechargeRefundValidate())->post()->goCheck('refund'); + $adminId = 1; + $result = RechargeLogic::refund($params, $adminId); + list($flag, $msg) = $result; + if(false === $flag) { + return $this->fail($msg); + } + return $this->success($msg, [], 1, 1); + } + +} \ No newline at end of file