setPage($input['page'] ?? 1); $model->setPageSize($input['pageSize'] ?? 10); if ($this->isAdmin()) { $where = []; } else { $where[] = ['status', '=', $model::NORMAL]; } if (!empty($input['code'])) { $where[] = ['pay_code', 'like', "%{$input['code']}%"]; } if (!empty($input['groupId'])) { $where[] = ['group_id', '=', "{$input['groupId']}"]; } // $where[] = ['gr.admin_id','=',$this->adminId]; $model->setWhere($where); $data = $model->getPageList($model); Until::output($data); } /** * @OA\Post(path="/api/Pay/save", * tags={"支付管理"}, * summary="保存支付配置信息", * @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")), * @OA\RequestBody( * @OA\MediaType( * mediaType="multipart/form-data", * @OA\Schema( * @OA\Property(description="支付code", property="code", type="string", default="jj公司"), * @OA\Property(description="状态 1正常 2删除", property="status", type="integer", default="1"), * @OA\Property(description="备注", property="remark", type="string", default="xx支付"), * @OA\Property(description="集团id", property="groupId", type="string", default="xx支付"), * required={"code"}) * ) * ), * @OA\Response(response="200", description="请求成功") * ) */ public function save() { $input = Until::getInput(); $rule = [ 'code|支付code' => 'require', // 'masterPayId|主商户号' => 'require', //'subPayId|子商户号' => 'require', // 'masterAppId|主appId' => 'require', //'subAppId|子appId' => 'require', 'groupId|集团id' => 'require', // 'xcxSecret|秘钥' => 'require', ]; Until::check($rule, $input); $model = new PayModel(); if (!empty($input['id'])) { $id = (int)$input['id']; $model::where(['id' => $id])->update([ 'pay_code' => $input['code'], // 'master_pay_id' => $input['masterPayId'], // 'sub_pay_id' => $input['subPayId'], // 'master_app_id' => $input['masterAppId'], // 'sub_app_id' => $input['subAppId'], // 'xcx_secret' => $input['xcxSecret'], 'group_id' => $input['groupId'], 'status' => $input['status'] ?? 1, 'remark' => $input['remark'] ]); } else { $rs = $model::where(['pay_code' => $input['code']])->find(); if (!empty($rs)) { throw new ApiException('存在相同payCode'); } $id = $model->insertGetId([ 'pay_code' => $input['code'], // 'master_pay_id' => $input['masterPayId'], // 'sub_pay_id' => $input['subPayId'] ?? "", // 'master_app_id' => $input['masterAppId'], // 'sub_app_id' => $input['subAppId'] ?? "", // 'xcx_secret' => $input['xcxSecret'], 'group_id' => $input['groupId'], 'status' => $input['status'] ?? 1, 'remark' => $input['remark'] ?? '' ]); } $model->setWhere([['p.id' ,'=', (int)$id]]); $info = $model->getPayInfo(); Until::output(['info' => $info]); } /** * @OA\GET(path="/api/Pay/read", * tags={"支付管理"}, * summary="查看支付信息", * @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")), * @OA\Parameter(name="id", in="query", description="支付id", @OA\Schema(type="ineger",default="1")), * @OA\RequestBody( * ), * @OA\Response(response="200", description="请求成功") * ) */ public function read($id) { $model = new PayModel(); $where[] = ['p.id', '=', (int)$id]; $model->setWhere($where); $info = $model->getPayInfo(); Until::output(['info' => $info]); } /** * @OA\GET(path="/api/Pay/delete", * tags={"支付管理"}, * summary="删除支付配置信息", * @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")), * @OA\Parameter(name="id", in="query", description="支付id", @OA\Schema(type="ineger",default="1")), * @OA\Parameter(name="status", in="query", description="1正常 2删除", @OA\Schema(type="ineger",default="1")), * @OA\RequestBody( * ), * @OA\Response(response="200", description="请求成功") * ) */ public function delete($id, $status) { $model = new PayModel(); $where[] = ['id', '=', (int)$id]; $data = ['status' => (int)$status]; $isSuccess = $model::where($where)->update($data); Until::output(['isSuccess' => $isSuccess]); } }