Charlie 9 jaren geleden
bovenliggende
commit
7d2d4aaf9a

+ 1 - 1
webshell/SyncCode.sh

@@ -1,5 +1,5 @@
 #!/bin/sh
-DEPLOY_DIR=/data/wozhua
+DEPLOY_DIR=/data/php
 if [ ! -d $DEPLOY_DIR ] ; then
 echo >&2 "fatal: post-receive: DEPLOY_DIR_NOT_EXIST: \"$DEPLOY_DIR\""
 exit 1

+ 1 - 1
webshell/SyncCodeOnline.sh

@@ -1,5 +1,5 @@
 #!/bin/sh
-DEPLOY_DIR=/data/yiguanjia-php
+DEPLOY_DIR=/data/php
 if [ ! -d $DEPLOY_DIR ] ; then
 echo >&2 "fatal: post-receive: DEPLOY_DIR_NOT_EXIST: \"$DEPLOY_DIR\""
 exit 1

+ 1 - 0
www/protected/config/main.php

@@ -35,6 +35,7 @@ return array(
         //               'ipFilters'=>array('127.0.0.1','::1'),
         //            ),
         'dataview',
+        'common',
         'o2o',
     ),
 

+ 13 - 0
www/protected/modules/common/CommonModule.php

@@ -0,0 +1,13 @@
+<?php
+
+class CommonModule extends CWebModule
+{
+    public function init()
+    {
+
+        $this->setImport(array(
+            'common.controllers.*',
+            'common.components.*',
+        ));
+    }
+}

+ 248 - 0
www/protected/modules/common/controllers/ConfirmController.php

@@ -0,0 +1,248 @@
+<?php
+class ConfirmController extends CController{
+    public  $layout="none";
+    public function actionPaySuccess(){
+        $input_data = json_decode(file_get_contents("php://input"), true);
+        $input_data = $input_data['data']['object'];
+        if($input_data['object'] == 'charge'&& $input_data['paid']==true){
+            if($input_data['subject'] == '附加服务'){
+                $a_order = AppendOrder::get(new MongoId($input_data['order_no']));
+                if($a_order && $a_order->status == 0){
+                    $a_order->charge_id = $input_data['id'];
+                    $a_order->pay_channel = $input_data['channel'];
+                    $a_order->status = 1;
+                    if($a_order->update(array('charge_id','pay_channel','status'),true)){
+                        echo 'success';
+                        die();
+                    }
+                }
+                echo 'fail';
+                die();
+            }
+            if ($input_data['subject'] == '带我回家-支付') {
+                $deal_order = DealOrder::get(new MongoId($input_data['order_no']));
+                if ($deal_order && $deal_order->status == 0) {
+                    // 订单修改
+                    $deal_order->chargeid = $input_data['id'];
+                    $deal_order->pay_channel = $input_data['channel'];
+                    $deal_order->pay_time = time();
+                    $deal_order->status = 1;
+
+                    // 宠物修改
+                    $pet = DealPet::get($deal_order->pet);
+                    $pet->status = 3;
+
+                    // 商家订单增加
+                    $kennel = Kennel::get($deal_order->kennel);
+                    $kennel->order_count += 1;
+                    $kennel->save();
+
+                    if ($deal_order->save() && $pet->save()) {
+                        echo 'success';
+                        die;
+                    }
+                }
+                echo 'fail';
+                die;
+            }
+            if ($input_data['subject'] == '带我回家-首款支付') {
+                $deal_earnest_order = DealChildOrder::get(new MongoId($input_data['order_no']));
+                if ($deal_earnest_order && $deal_earnest_order->status == 0) {
+                    $deal_earnest_order->chargeid = $input_data['id'];
+                    $deal_earnest_order->pay_channel = $input_data['channel'];
+                    $deal_earnest_order->pay_time = time();
+                    $deal_earnest_order->status = 1;
+                    // 后续操作在DealChildOrder::afterSave()中
+                    if ($deal_earnest_order->save()) {
+                        echo 'success';
+                        die;
+                    }
+                }
+                echo 'fail';
+                die;
+            }
+            if ($input_data['subject'] == '带我回家-尾款支付') {
+                $deal_final_order = DealChildOrder::get(new MongoId($input_data['order_no']));
+                if ($deal_final_order && $deal_final_order->status == 0) {
+                    $deal_final_order->chargeid = $input_data['id'];
+                    $deal_final_order->pay_channel = $input_data['channel'];
+                    $deal_final_order->pay_time = time();
+                    $deal_final_order->status = 1;
+                    // 后续操作在DealChildOrder::afterSave()中
+                    if ($deal_final_order->save()) {
+                        echo 'success';
+                        die;
+                    }
+                }
+                echo 'fail';
+                die;
+            }
+            //TODO update database
+            $order = ROrder::get(new MongoId($input_data['order_no']));
+            if(!$order || $order->status == -1){
+                echo 'fail';
+                die();
+            }
+            $order->charge_id = $input_data['id'];
+            $order->pay_channel = $input_data['channel'];
+            $order->status = 1;
+            if($order->update(array('charge_id','pay_channel','status'),true)){
+                $list = new ARedisList('o2o_after_pay_success');
+                $list->push(json_encode($input_data));
+                echo 'success';
+                die();
+            }else{
+                echo 'fail';
+                die();
+            }
+        }elseif($input_data['object'] == 'refund'&& $input_data['succeed']==true){
+            //TODO update database
+            echo 'success';
+            die();
+        }else{
+            echo 'fail';
+            die();
+        }
+    }
+
+    public function actionCheckMobile(){
+        $mobile = Yii::app()->getRequest()->getParam("mobile",'');
+        if($mobile && preg_match("/\d{11}/",$mobile)){
+            $criteria = new EMongoCriteria();
+            $criteria->mobile('==',$mobile);
+            $user = Mobile::model()->find($criteria);
+            if($user){
+                echo 'fail';
+            }else{
+                $userAr  = new Mobile();
+                $userAr->mobile = $mobile;
+                if($userAr->save()){
+                    echo 'success';
+                }else{
+                    echo 'fail';
+                }
+            }
+        }else{
+            echo 'fail';
+        }
+    }
+
+    public function actionSyncCode(){
+        echo ENVIRONMENT."\n";
+        if(ENVIRONMENT == 'product'){
+            exec("/data/wozhua/webshell/SyncCodeOnline.sh");
+            echo 'success';
+        }elseif(ENVIRONMENT == 'develop'){
+            exec("/data/wozhua/webshell/SyncCodeDev.sh");
+            echo 'success';
+        }else{
+            exec("/data/wozhua/webshell/SyncCode.sh");
+            echo 'success';
+        }
+    }
+
+    public function actionSyncDealCode(){
+        echo ENVIRONMENT."\n";
+        if(ENVIRONMENT == 'product'){
+            exec("/data/wozhua/webshell/SyncDealCodeOnline.sh");
+            echo 'success';
+        }else{
+            exec("/data/wozhua/webshell/SyncDealCode.sh");
+            echo 'success';
+        }
+    }
+
+    public function actionSyncFrontCode(){
+        echo ENVIRONMENT."\n";
+        if(ENVIRONMENT == 'product'){
+            exec("/data/wozhua/webshell/SyncFrontCodeOnline.sh");
+            echo 'success';
+        }else{
+            exec("/data/wozhua/webshell/SyncFrontCode.sh");
+            echo 'success';
+        }
+    }
+
+    public function actionConvVideo(){
+        $input_data = json_decode(file_get_contents("php://input"), true);
+        file_put_contents('/data/qiniulog.json',var_export($input_data,true),FILE_APPEND);
+        $id = $input_data['id'];
+        if($id){
+            $cache = new ARedisCache();
+            $topic_id = $cache->get($id);
+            $topic = Topic::get(new MongoId($topic_id));
+            $qiniu_config = Yii::app()->params['qiniuConfig'];
+            if($topic && isset($topic->video)){
+                $key = str_replace('http://'.$qiniu_config['video'].'.qiniudn.com/','',$topic->video['url']);
+                $new_key = 'af'.$key;
+                $topic->video['url'] = 'http://'.$qiniu_config['video'].'.qiniudn.com/'.$new_key;
+                $topic->update(array('video'),true);
+            }
+        }
+    }
+
+    public function actionUserFollow(){
+        $path = Yii::getPathOfAlias('application');
+        require_once($path."/vendors/weixin/wechat.class.php");
+        $wxConfig = Yii::app()->params['wxConfig'];
+        $options = array(
+               'token'=>'kkzH33eWEuP383uuKuQ366uKPwwzpE37', //填写你设定的key
+               'encodingaeskey'=>'2MACh0Ww6nDHDtH4pHEwgfRnCnctGVtNA0Bumvw5nkA', //填写加密用的EncodingAESKey
+               'appid'=>$wxConfig['appId'], //填写高级调用功能的app id
+               'appsecret'=>$wxConfig['appSecret'], //填写高级调用功能的密钥
+           );
+        $weObj = new Wechat($options);
+        $weObj->valid();
+        $menu = $weObj->getMenu();
+        $newmenu =  array(
+               "button"=>
+                   array(
+                       array('type'=>'view','name'=>'上门服务','url'=>'http://www.wozhua.mobi/o2o/web/index'),
+                       array('type'=>'view','name'=>'下载APP','url'=>'http://t.cn/R2DKttW'),
+                       array('type'=>'click','name'=>'握爪过年','key'=>'WOZHUA_STAR'),
+                       )
+               );
+        $result = $weObj->createMenu($newmenu);
+        $data = $weObj->getRev()->getRevData();
+        if(isset($data['FromUserName']) && !empty($data['FromUserName'])){
+            if($data['Event'] == 'subscribe'){
+                // @file_put_contents('/data/subscribe.log',$data['FromUserName'].'--'.$data['Event']."\n",FILE_APPEND);
+                $criteria = new EMongoCriteria();
+                $criteria->wx_pub_openid('==',$data['FromUserName']);
+                $user = RUser::model()->find($criteria); 
+                if($user){
+                    $user->wx_have_follow = 1;
+                    $user->update(array('wx_have_follow'),true);
+                }else{
+                    // @file_put_contents('/data/subscribe_error.log',$data['FromUserName'].'--'.$data['Event']."\n",FILE_APPEND);
+                }
+            }elseif($data['Event']=='unsubscribe'){
+                // @file_put_contents('/data/subscribe.log',$data['FromUserName'].'--'.$data['Event']."\n",FILE_APPEND);
+                $criteria = new EMongoCriteria();
+                $criteria->wx_pub_openid('==',$data['FromUserName']);
+                $user = RUser::model()->find($criteria); 
+                if($user){
+                    $user->wx_have_follow = 0;
+                    $user->update(array('wx_have_follow'),true);
+                }else{
+                    // @file_put_contents('/data/subscribe_error.log',$data['FromUserName'].'--'.$data['Event']."\n",FILE_APPEND);
+                }
+            }elseif($data['Event']=='CLICK' && $data['EventKey']=='WOZHUA_STAR'){
+                $criteria = new EMongoCriteria();
+                $criteria->wx_pub_openid('==',$data['FromUserName']);
+                $user = RUser::model()->find($criteria); 
+                if($user && $user->wx_have_follow != 1){
+                    $user->wx_have_follow = 1;
+                    $user->update(array('wx_have_follow'),true);
+                }
+                $weObj->text("晒萌宠照,赢Apple watch,参与活动请点击:http://t.cn/RbgjgPK")->reply(); 
+            }
+            if(time() - $data['CreateTime'] < 2 && $data['Event'] == 'subscribe'){
+                $weObj->text("晒萌宠照,赢Apple watch,参与活动请点击:http://t.cn/RbgjgPK")->reply(); 
+            }
+        }
+    }
+
+
+}
+