1 个管道
的构建
通过
耗费
7 秒
add the user balance
正在显示
2 个修改的文件
包含
44 行增加
和
0 行删除
@@ -588,6 +588,33 @@ class OrderController extends HomeBaseController{ | @@ -588,6 +588,33 @@ class OrderController extends HomeBaseController{ | ||
588 | } | 588 | } |
589 | } | 589 | } |
590 | 590 | ||
591 | + /** | ||
592 | + * @title 余额支付 | ||
593 | + * @description | ||
594 | + * @author sgj | ||
595 | + * @url /portal/order/chargeOrder | ||
596 | + * @method GET | ||
597 | + * | ||
598 | + * @param name:fee type:String require:1 default:无 other: desc:金额 | ||
599 | + * @param name:user_id type:String require:1 default:无 other: desc:用户id | ||
600 | + * | ||
601 | + * @return order:订单号 | ||
602 | + */ | ||
603 | + public function payByBalance(){ | ||
604 | + $order_no=input('order_no'); | ||
605 | + $order_map['order_no']=$order_no; | ||
606 | + $order=\db('order')->where($order_map)->find(); | ||
607 | + $user_map['id']=$order['users_id']; | ||
608 | + $user=\db('users')->where($user_map)->find(); | ||
609 | + if ($order['price']>$user['fee']){ | ||
610 | + | ||
611 | + $this->apiResponse('400','余额不足!'); | ||
612 | + } | ||
613 | + $result=\db('users')->where($user_map)->setDec('fee',$order['price']); | ||
614 | + if ($result==1){ | ||
615 | + $this->apiResponse('200','支付成功!'); | ||
616 | + } | ||
617 | + } | ||
591 | 618 | ||
592 | //支付回调接口 | 619 | //支付回调接口 |
593 | public function notify(){ | 620 | public function notify(){ |
@@ -422,4 +422,21 @@ class UsersController extends HomeBaseController{ | @@ -422,4 +422,21 @@ class UsersController extends HomeBaseController{ | ||
422 | $return['min']=floor(($time-$return['hour']*3600)/60); | 422 | $return['min']=floor(($time-$return['hour']*3600)/60); |
423 | return $return; | 423 | return $return; |
424 | } | 424 | } |
425 | + | ||
426 | + | ||
427 | + /** | ||
428 | + * @title 获取用户余额 | ||
429 | + * @description | ||
430 | + * @author | ||
431 | + * @url /portal/users/getUserBalance | ||
432 | + * @method GET | ||
433 | + * | ||
434 | + * @param name:users_id type:String require:1 default:无 other: desc:用户id | ||
435 | + * | ||
436 | + */ | ||
437 | + public function getUserBalance(){ | ||
438 | + $user_id=input('user_id'); | ||
439 | + $return['fee']=\db('users')->where('id',$user_id)->field('fee'); | ||
440 | + return $return; | ||
441 | + } | ||
425 | } | 442 | } |
-
请 注册 或 登录 后发表评论