Jelajahi Sumber

修改所有的technician和

DengTao 8 tahun lalu
induk
melakukan
371cde4338

+ 41 - 42
www/protected/controllers/ROrderController.php

@@ -165,11 +165,7 @@ class ROrderController extends AdminController{
                 $technician_names[] = Yii::app()->request->getParam('extra_add_info_'.$i);
             }
         }
-       // var_dump($technician_names);
-        //var_dump($technician_names);
-       // exit();
-        //$technician_id = intval(Yii::app()->request->getParam('technician', 0));
-        //$technician_name = Yii::app()->request->getParam('technician_name', '');
+
 
         if(!$counts){
             CommonFn::requestAjax(false, '购买数量错误');
@@ -345,6 +341,7 @@ class ROrderController extends AdminController{
         //$order->technician = $technician_id;
         //$order->technician_name = $technician_name;
         $order->technicians = $technicians;
+
        // var_dump($order->technicians);exit;
         $arr_order = array('cancel_time','refund_time','finish_time','status','booking_time','deal_time','remark', 'station', 'technicians');
 
@@ -353,7 +350,6 @@ class ROrderController extends AdminController{
 
         // 通知保洁师
         if (in_array($status, array(1,2,3,4,5)) && $toTech && $success) {
-        // if ($toTech) {
             foreach($technician_ids as $key => $technician_id) {
                 $technician_obj = TechInfo::get($technician_id);
                 if ($technician_obj && $technician_obj->weixin_userid) {
@@ -680,55 +676,58 @@ class ROrderController extends AdminController{
 
         $orderid = new MongoId($id);
         $order = ROrder::model()->get($orderid);
-        $toTech = $order->technician != $technician_id ? true : false;
-        $fromTech = $order->technician;
+        $toTech = isset($order->technicians)  ? true : false;
+        $fromTechs[] = technician_names;
         //$order->technician = $technician_id;
         //$order->technician_name = $technician_name;
         $order->technicians = $technicians;
         $success = $order->save(true, array('technicians'));
-        foreach ($technician_objs as $technician_obj) {
+
             if ($toTech && $success) {
-                // 发送给被分配保洁师
-                $wechat = O2oApp::getWechatActive();
-                $url_prefix = ENVIRONMENT == 'product' ? 'http://api.yiguanjia.me' : 'http://apitest.yiguanjia.me';
-                if (!empty($technician_obj->weixin_userid)) {
-                    $wechat_data = array(
-                        'touser' => $technician_obj->weixin_userid,
-                        'msgtype' => 'news',
-                        'agentid' => '24',
-                        'news' => array(
-                            'articles' => array(
-                                array(
-                                    'title' => '壹管家提示-新订单',
-                                    'description' => $technician_obj->name . '你好!刚刚有一个新的订单被分配给你,请点击查看。',
-                                    'url' => $url_prefix . '/index.php?r=o2o/myOrder/info&order=' . $id . '&user=' . $technician_obj->_id,
+                foreach ($technician_objs as $technician_obj) {
+                    // 发送给被分配保洁师
+                    $wechat = O2oApp::getWechatActive();
+                    $url_prefix = ENVIRONMENT == 'product' ? 'http://api.yiguanjia.me' : 'http://apitest.yiguanjia.me';
+                    if (!empty($technician_obj->weixin_userid)) {
+                        $wechat_data = array(
+                            'touser' => $technician_obj->weixin_userid,
+                            'msgtype' => 'news',
+                            'agentid' => '24',
+                            'news' => array(
+                                'articles' => array(
+                                    array(
+                                        'title' => '壹管家提示-新订单',
+                                        'description' => $technician_obj->name . '你好!刚刚有一个新的订单被分配给你,请点击查看。',
+                                        'url' => $url_prefix . '/index.php?r=o2o/myOrder/info&order=' . $id . '&user=' . $technician_obj->_id,
+                                    ),
                                 ),
                             ),
-                        ),
-                    );
-                    $wechat->sendMessage($wechat_data);
+                        );
+                        $wechat->sendMessage($wechat_data);
+                    }
                 }
 
                 // 发送给原保洁师
-                $fromTechObj = TechInfo::get($fromTech);
-                if (!empty($fromTechObj) && !empty($fromTechObj->weixin_userid)) {
-                    $wechat_data = array(
-                        'touser' => $fromTechObj->weixin_userid,
-                        'msgtype' => 'news',
-                        'agentid' => '24',
-                        'news' => array(
-                            'articles' => array(
-                                array(
-                                    'title' => '壹管家提示-订单已被重新分配',
-                                    'description' => $fromTechObj->name . '你好!预定时间在' . date('m月d日H:i', $order->booking_time) . '的订单已被分配给其他保洁师。',
-                                    'url' => $url_prefix . '/index.php?r=o2o/myOrder/info&order=' . $id . '&user=' . $technician_obj->_id,
+                foreach ($fromTechs as $fromTech) {
+                    $fromTechObj = TechInfo::get($fromTech);
+                    if (!empty($fromTechObj) && !empty($fromTechObj->weixin_userid)) {
+                        $wechat_data = array(
+                            'touser' => $fromTechObj->weixin_userid,
+                            'msgtype' => 'news',
+                            'agentid' => '24',
+                            'news' => array(
+                                'articles' => array(
+                                    array(
+                                        'title' => '壹管家提示-订单已被重新分配',
+                                        'description' => $fromTechObj->name . '你好!预定时间在' . date('m月d日H:i', $order->booking_time) . '的订单已被分配给其他保洁师。',
+                                        'url' => $url_prefix . '/index.php?r=o2o/myOrder/info&order=' . $id . '&user=' . $technician_obj->_id,
+                                    ),
                                 ),
                             ),
-                        ),
-                    );
-                    $wechat->sendMessage($wechat_data);
+                        );
+                        $wechat->sendMessage($wechat_data);
+                    }
                 }
-            }
         }
         CommonFn::requestAjax($success, '', array());
     }

+ 58 - 53
www/protected/modules/o2o/models/ROrder.php

@@ -51,8 +51,8 @@ class ROrder extends MongoAr
     public $station = '';//服务网点,station的mongoid
 
     public $technicians = array(); // 接单保洁师
-    public $technician = ''; // 接单保洁师,user的id
-    public $technician_name = ''; // 接单保洁师姓名
+    //public $technician = ''; // 接单保洁师,user的id
+    //public $technician_name = ''; // 接单保洁师姓名
 
     public $address = array(); //地址信息   包含   province  city  area position detail   name  mobile position
 
@@ -334,9 +334,9 @@ class ROrder extends MongoAr
     protected function afterSave() {
         parent::afterSave();
 
-        $tech = TechInfo::get($this->technician);
+        $tech = TechInfo::get($this->technicians);
         // 生成保洁师提成并保存
-        if ($this->status == 6 && !empty($this->technician)) {
+        if ($this->status == 6 && !empty($this->technicians)) {
             // 订单时间检查
             // 预定时间是否在12月之后
             $time = time();
@@ -352,60 +352,65 @@ class ROrder extends MongoAr
             $order = $this->_id;
             $commisionObj = Commision::getByOrder($order);
             // 检查Cmmmision信息是否已录入
-            if ($commisionObj == false) {
-                // 普通订单生成提成并保存
-                $commisionObj = new Commision();
-                $commisionObj->time = empty($this->finish_time) ? $time : $this->finish_time;
-                $commisionObj->booking_time = $this->booking_time;
-                $commisionObj->user = $this->technician;
-                $commisionObj->order = $this->_id;
-                $commisionObj->commision = Commision::getCommision($this, Commision::MAIN, $tech->scheme);
-                $commisionObj->type = Commision::MAIN;
-                $commisionObj->insert();
-
-                // 订单内附加订单生成提成并保存
-                $appends = $this->append_orders;
-                if (!empty($appends)) {
-                    $criteria = new EMongoCriteria();
-                    $criteria->_id('in', $appends);
-                    $appendOrders = AppendOrder::model()->findAll($criteria);
-                    foreach ($appendOrders as $key => $row) {
-                        if ($row->status != 1) {
-                            continue;
+            foreach ($this->technicians as $technician_id => $technician) {
+
+                if ($commisionObj == false) {
+                    // 普通订单生成提成并保存
+                    $commisionObj = new Commision();
+                    $commisionObj->time = empty($this->finish_time) ? $time : $this->finish_time;
+                    $commisionObj->booking_time = $this->booking_time;
+                    $commisionObj->user = $technician;
+                    $commisionObj->order = $this->_id;
+                    $commisionObj->commision = Commision::getCommision($this, Commision::MAIN, $tech->scheme);
+                    $commisionObj->type = Commision::MAIN;
+                    $commisionObj->insert();
+
+                    // 订单内附加订单生成提成并保存
+                    $appends = $this->append_orders;
+                    if (!empty($appends)) {
+                        $criteria = new EMongoCriteria();
+                        $criteria->_id('in', $appends);
+                        $appendOrders = AppendOrder::model()->findAll($criteria);
+                        foreach ($appendOrders as $key => $row) {
+                            if ($row->status != 1) {
+                                continue;
+                            }
+                            $commisionObj = new Commision();
+                            $commisionObj->time = empty($this->finish_time) ? $time : $this->finish_time;
+                            $commisionObj->booking_time = $this->booking_time;
+                            $commisionObj->user = $technician;
+                            $commisionObj->order = $row->_id;
+                            $commisionObj->commision = Commision::getCommision($row, Commision::APPEND, $tech->scheme);
+                            $commisionObj->type = Commision::APPEND;
+                            $commisionObj->insert();
                         }
-                        $commisionObj = new Commision();
-                        $commisionObj->time = empty($this->finish_time) ? $time : $this->finish_time;
-                        $commisionObj->booking_time = $this->booking_time;
-                        $commisionObj->user = $this->technician;
-                        $commisionObj->order = $row->_id;
-                        $commisionObj->commision = Commision::getCommision($row, Commision::APPEND, $tech->scheme);
-                        $commisionObj->type = Commision::APPEND;
-                        $commisionObj->insert();
                     }
                 }
-            }
-            // 提示保洁师订单已完成
-            if ($tech && $tech->weixin_userid) {
-                // 检查订单评价是否存在,若存在则不发送
-                $comment = Comment::getByOrder($this->_id);
-                if (!$comment) {
-                    $wechat = O2oApp::getWechatActive();
-                    $url_prefix = ENVIRONMENT == 'product' ? 'http:// api.yiguanjia.me' : 'http:// apitest.yiguanjia.me';
-                    $wechat_data = [
-                        'touser'  => $tech->weixin_userid,
-                        'msgtype' => 'news',
-                        'agentid' => '24',
-                        'news'    => [
-                            'articles' => [
-                                [
-                                    'title' => '壹管家提示-订单已完成',
-                                    'description' => $tech->name.'你好!预定时间在'.date('m月d日H:i', $this->booking_time).'的订单已完成,请点击查看订单情况。',
-                                    'url' => $url_prefix.'/index.php?r=o2o/myCommision/info&order='.(string)$order.'&user='.$this->technician.'&type=0',
+
+
+                // 提示保洁师订单已完成
+                if ($tech && $tech->weixin_userid) {
+                    // 检查订单评价是否存在,若存在则不发送
+                    $comment = Comment::getByOrder($this->_id);
+                    if (!$comment) {
+                        $wechat = O2oApp::getWechatActive();
+                        $url_prefix = ENVIRONMENT == 'product' ? 'http:// api.yiguanjia.me' : 'http:// apitest.yiguanjia.me';
+                        $wechat_data = [
+                            'touser'  => $tech->weixin_userid,
+                            'msgtype' => 'news',
+                            'agentid' => '24',
+                            'news'    => [
+                                'articles' => [
+                                    [
+                                        'title' => '壹管家提示-订单已完成',
+                                        'description' => $tech->name.'你好!预定时间在'.date('m月d日H:i', $this->booking_time).'的订单已完成,请点击查看订单情况。',
+                                        'url' => $url_prefix.'/index.php?r=o2o/myCommision/info&order='.(string)$order.'&user='.$technician.'&type=0',
+                                    ],
                                 ],
                             ],
-                        ],
-                    ];
-                    $wechat->sendMessage($wechat_data);
+                        ];
+                        $wechat->sendMessage($wechat_data);
+                    }
                 }
             }
         }

+ 0 - 6
www/protected/runtime/gii-1.1.13/ControllerCode.php

@@ -1,6 +0,0 @@
-<?php
-return array (
-  'template' => 'default',
-  'baseClass' => 'Controller',
-  'actions' => 'index',
-);

+ 0 - 4
www/protected/runtime/gii-1.1.13/ModuleCode.php

@@ -1,4 +0,0 @@
-<?php
-return array (
-  'template' => 'default',
-);

TEMPAT SAMPAH
www/protected/runtime/state.bin.cpgz