123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <?php
- /**
- * Author: luzheng.liu
- * Time: 2020/12/16 23:06
- */
- namespace app\api\controller;
- use app\api\BaseController;
- use app\api\exception\ApiException;
- use app\api\model\AdminModel;
- use app\api\model\BrandModel;
- use app\api\model\CompanyModel;
- use app\api\model\GroupModel;
- use app\api\model\PayModel;
- use app\common\until\Until;
- class Pay extends BaseController {
- /**
- * @OA\Get(path="/api/Pay/index",
- * tags={"支付管理"},
- * summary="支付配置列表",
- * @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
- * @OA\Parameter(name="page", in="query", description="页码", @OA\Schema(type="ineger",default="1")),
- * @OA\Parameter(name="pageSize", in="query", description="页尺寸", @OA\Schema(type="integer",default="10")),
- * @OA\Parameter(name="status", in="query", description="状态 1正常 2删除", @OA\Schema(type="integer",default="1")),
- * @OA\Parameter(name="code", in="query", description="支付code", @OA\Schema(type="string")),
- * @OA\Parameter(name="groupId", in="query", description="公司id", @OA\Schema(type="integer")),
- * @OA\RequestBody(
- * ),
- * @OA\Response(response="200", description="请求成功")
- * )
- */
- public function index() {
- $input = Until::getInput();
- $model = new PayModel();
- $model->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]);
- }
- }
|