ソースを参照

TechHomeController

DengTao 8 年 前
コミット
d5dfeeaf99

+ 1 - 0
www/protected/controllers/CommentController.php

@@ -70,6 +70,7 @@ class CommentController extends AdminController{
 //var_dump($total);die();
         $rows = CommonFn::getRowsFromCursor($cursor);
         $parsedRows = Comment::model()->parse($rows);
+        //var_dump($parsedRows);
 //var_dump($parsedRows);die();
 
         echo CommonFn::composeDatagridData($parsedRows, $total);

+ 33 - 31
www/protected/modules/o2o/controllers/ProductController.php

@@ -144,51 +144,53 @@ class  ProductController extends O2oBaseController{
 
         // 保洁师信息处理
         //     2015-12-11
-        $technician = empty($order->technician) ? 0 : $order->technician;
-        $comment->technician = $technician;
+        $technicians = empty($order->technicians) ? null : $order->technicians;
+        $comment->technicians = $technicians;
 
-        if($comment->save()){
+        if($comment->save()) {
             $order->have_comment = 1;
-            $order->update(array('have_comment'),true);
+            $order->update(array('have_comment'), true);
             $data = $comment->parseRow($comment);
             $start_time = time();
-            $end_time = strtotime(date('Y-m-d',$start_time+1209600));
+            $end_time = strtotime(date('Y-m-d', $start_time + 1209600));
             $coupon_ids[] = '56c5914fa84ea0874f8d3820';
             $coupon_ids[] = '56c591b1a84ea0dd4e8d411e';
             $coupon_ids[] = '56c591e5a84ea04d238cc67b';
             $coupon_ids[] = '56c5921ca84ea0b3268bd949';
-            Service::factory('CouponService')->giveCoupon($order->user,new MongoId($coupon_ids[mt_rand(0,3)]),$start_time,$end_time);
+            Service::factory('CouponService')->giveCoupon($order->user, new MongoId($coupon_ids[mt_rand(0, 3)]), $start_time, $end_time);
 
             // 保洁师操作
-            if ($technician) {
-                $technicianObj = TechInfo::get($technician);
-                if ($technicianObj && $technicianObj->weixin_userid) {
-                    $url_prefix = ENVIRONMENT == 'product' ? 'http://api.yiguanjia.me' : 'http://apitest.yiguanjia.me';
-                    $wechat = O2oApp::getWechatObj();
-                    $wechat_data = array(
-                        'touser'  => $technicianObj->weixin_userid,
-                        'msgtype' => 'news',
-                        'agentid' => '24',
-                        'news'    => array(
-                            'articles' => array(
-                                array(
-                                    'title' => '壹管家提示-新评价',
-                                    'description' => $technicianObj->name.'你好!你刚刚在壹管家O2O服务上收到了一条评分为'.$score.'分的订单评价,请点击查看。',
-                                    'url' => $url_prefix.'/index.php?r=o2o/myComment/info&order='.$order_id.'&user='.$technician,
+            foreach ($technicians as $technician) {
+                if ($technician) {
+                    $technicianObj = TechInfo::get($technician);
+                    if ($technicianObj && $technicianObj->weixin_userid) {
+                        $url_prefix = ENVIRONMENT == 'product' ? 'http://api.yiguanjia.me' : 'http://apitest.yiguanjia.me';
+                        $wechat = O2oApp::getWechatObj();
+                        $wechat_data = array(
+                            'touser' => $technicianObj->weixin_userid,
+                            'msgtype' => 'news',
+                            'agentid' => '24',
+                            'news' => array(
+                                'articles' => array(
+                                    array(
+                                        'title' => '壹管家提示-新评价',
+                                        'description' => $technicianObj->name . '你好!你刚刚在壹管家O2O服务上收到了一条评分为' . $score . '分的订单评价,请点击查看。',
+                                        'url' => $url_prefix . '/index.php?r=o2o/myComment/info&order=' . $order_id . '&user=' . $technician,
+                                    ),
                                 ),
                             ),
-                        ),
-                    );
-                    $wechat->sendMessage($wechat_data);
-                }
-                // 好评数统计
-                if ($score == 5) {
-                    $favourable_count = $technicianObj->favourable_count + 1;
-                    $technicianObj->favourable_count = $favourable_count;
-                    $technicianObj->save();
+                        );
+                        $wechat->sendMessage($wechat_data);
+                    }
+                    // 好评数统计
+                    if ($score == 5) {
+                        $favourable_count = $technicianObj->favourable_count + 1;
+                        $technicianObj->favourable_count = $favourable_count;
+                        $technicianObj->save();
+                    }
                 }
+                CommonFn::requestAjax(true, CommonFn::getMessage('o2o', 'comment_success'), $data);
             }
-            CommonFn::requestAjax(true,CommonFn::getMessage('o2o','comment_success'),$data);
         }else{
             CommonFn::requestAjax(false,CommonFn::getMessage('o2o','comment_failt'));
         }

+ 10 - 8
www/protected/modules/o2o/models/Comment.php

@@ -22,7 +22,7 @@ class Comment extends MongoAr
     public $weight = 0;//评价权重
 
     public $technician = 0;
-
+    public $technicians = array();//多个保洁师
     public $technician_name = '';
 
     public $reply = ''; // 客服回复
@@ -104,14 +104,16 @@ class Comment extends MongoAr
         }
         $newRow['user'] = $user;
 
-        $newRow['technician'] = intval(CommonFn::get_val_if_isset($row, 'technician', 0));
-        $newRow['technician_name'] = '';
+        $newRow['technicians'] = intval(CommonFn::get_val_if_isset($row, 'technicians', 0));
+        //$newRow['technician_name'] = '';
         $newRow['tech_info'] = [];
-        if ($newRow['technician']) {
-            $tech_info = TechInfo::get($newRow['technician']);
-            if ($tech_info) {
-                $newRow['tech_info'] = TechInfo::model()->parseRow($tech_info,array('id','name','mobile','weixin_userid'));
-                $newRow['technician_name'] = $tech_info->name;
+        if ($newRow['technicians']) {
+            foreach($newRow['technicians'] as $technicians) {
+                $tech_info = TechInfo::get($technicians);
+                if ($tech_info) {
+                    $newRow['tech_info'][] = TechInfo::model()->parseRow($tech_info, array('id', 'name', 'mobile', 'weixin_userid'));
+                    $newRow['technician_name'][] = $tech_info->name;
+                }
             }
         }