You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.9 KiB

<?php
namespace app\adminapi\controller\v1;
use app\adminapi\ApiController;
use think\facade\Db;
class Payment extends ApiController{
//取得支付列表
public function list(){
$do=Db::name('payment')
->order('pay_order','asc');
$payment=$do->select();
$result = [
'page' => 1,
'total' => $do->count(),
'data' => $payment
];
return $this->Success($result);
}
//取得支付資料
public function getPayment(){
$id=input('id');
$result=Db::name('payment')
->where('pay_id',$id)
->find();
return $this->Success($result);
}
//更新支付資料
public function update(){
$data=input('post.');
try{
Db::name('payment')
->where('pay_id',$data['pay_id'])
->update($data);
}catch(\Exception $e){
return $this->Error($e->getMessage());
}
return $this->Success('更新成功');
}
public function updateEnabled(){
$data=input('post.');
try{
Db::name('payment')
->where('pay_id',$data['pay_id'])
->update(['enabled'=>$data['enabled']]);
}catch(\Exception $e){
return $this->Error($e->getMessage());
}
return $this->Success('更新成功');
}
public function updateOrder(){
$data=input('post.');
foreach($data as $key=>$value){
try{
Db::name('payment')
->where('pay_id',$value['pay_id'])
->update(['pay_order'=>$value['pay_order']]);
}catch(\Exception $e){
return $this->Error($e->getMessage());
}
}
return $this->Success('更新成功');
}
}