ConfirmController.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. class ConfirmController extends CController{
  3. public $layout="none";
  4. public function actionPaySuccess(){
  5. $input_data = json_decode(file_get_contents("php://input"), true);
  6. $input_data = $input_data['data']['object'];
  7. if($input_data['object'] == 'charge'&& $input_data['paid']==true){
  8. //TODO update database
  9. $order = ROrder::get(new MongoId($input_data['order_no']));
  10. if(!$order || $order->status == -1){
  11. echo 'fail';
  12. die();
  13. }
  14. $order->charge_id = $input_data['id'];
  15. $order->pay_channel = $input_data['channel'];
  16. $order->status = 1;
  17. if($order->update(array('charge_id','pay_channel','status'),true)){
  18. $list = new ARedisList('o2o_after_pay_success');
  19. $list->push(json_encode($input_data));
  20. echo 'success';
  21. die();
  22. }else{
  23. echo 'fail';
  24. die();
  25. }
  26. }elseif($input_data['object'] == 'refund'&& $input_data['succeed']==true){
  27. //TODO update database
  28. echo 'success';
  29. die();
  30. }else{
  31. echo 'fail';
  32. die();
  33. }
  34. }
  35. public function actionCheckMobile(){
  36. $mobile = Yii::app()->getRequest()->getParam("mobile",'');
  37. if($mobile && preg_match("/\d{11}/",$mobile)){
  38. $criteria = new EMongoCriteria();
  39. $criteria->mobile('==',$mobile);
  40. $user = Mobile::model()->find($criteria);
  41. if($user){
  42. echo 'fail';
  43. }else{
  44. $userAr = new Mobile();
  45. $userAr->mobile = $mobile;
  46. if($userAr->save()){
  47. echo 'success';
  48. }else{
  49. echo 'fail';
  50. }
  51. }
  52. }else{
  53. echo 'fail';
  54. }
  55. }
  56. public function actionSyncCode(){
  57. echo ENVIRONMENT."\n";
  58. if(ENVIRONMENT == 'product'){
  59. exec("/data/php/webshell/SyncCodeOnline.sh");
  60. echo 'success';
  61. }elseif(ENVIRONMENT == 'develop'){
  62. exec("/data/php/webshell/SyncCodeDev.sh");
  63. echo 'success';
  64. }else{
  65. exec("/data/php/webshell/SyncCode.sh");
  66. echo 'success';
  67. }
  68. }
  69. }