作者 sgj
1 个管道 的构建 通过 耗费 7 秒

add the user balance

... ... @@ -588,6 +588,33 @@ class OrderController extends HomeBaseController{
}
}
/**
* @title 余额支付
* @description
* @author sgj
* @url /portal/order/chargeOrder
* @method GET
*
* @param name:fee type:String require:1 default:无 other: desc:金额
* @param name:user_id type:String require:1 default:无 other: desc:用户id
*
* @return order:订单号
*/
public function payByBalance(){
$order_no=input('order_no');
$order_map['order_no']=$order_no;
$order=\db('order')->where($order_map)->find();
$user_map['id']=$order['users_id'];
$user=\db('users')->where($user_map)->find();
if ($order['price']>$user['fee']){
$this->apiResponse('400','余额不足!');
}
$result=\db('users')->where($user_map)->setDec('fee',$order['price']);
if ($result==1){
$this->apiResponse('200','支付成功!');
}
}
//支付回调接口
public function notify(){
... ...
... ... @@ -422,4 +422,21 @@ class UsersController extends HomeBaseController{
$return['min']=floor(($time-$return['hour']*3600)/60);
return $return;
}
/**
* @title 获取用户余额
* @description
* @author
* @url /portal/users/getUserBalance
* @method GET
*
* @param name:users_id type:String require:1 default:无 other: desc:用户id
*
*/
public function getUserBalance(){
$user_id=input('user_id');
$return['fee']=\db('users')->where('id',$user_id)->field('fee');
return $return;
}
}
\ No newline at end of file
... ...