|
@@ -354,24 +354,27 @@ class ROrderController extends AdminController{
|
|
|
// 通知保洁师
|
|
|
if (in_array($status, array(1,2,3,4,5)) && $toTech && $success) {
|
|
|
// if ($toTech) {
|
|
|
- if ($technician_obj && $technician_obj->weixin_userid) {
|
|
|
- $url_prefix = ENVIRONMENT == 'product' ? 'http://api.yiguanjia.me' : 'http://apitest.yiguanjia.me';
|
|
|
- $wechat = O2oApp::getWechatActive();
|
|
|
- $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_id,
|
|
|
+ foreach($technician_ids as $key => $technician_id) {
|
|
|
+ $technician_obj = TechInfo::get($technician_id);
|
|
|
+ if ($technician_obj && $technician_obj->weixin_userid) {
|
|
|
+ $url_prefix = ENVIRONMENT == 'product' ? 'http://api.yiguanjia.me' : 'http://apitest.yiguanjia.me';
|
|
|
+ $wechat = O2oApp::getWechatActive();
|
|
|
+ $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_id,
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
- ),
|
|
|
- );
|
|
|
- $wechat->sendMessage($wechat_data);
|
|
|
+ );
|
|
|
+ $wechat->sendMessage($wechat_data);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -631,82 +634,100 @@ class ROrderController extends AdminController{
|
|
|
*/
|
|
|
public function actionResetTech() {
|
|
|
$id = Yii::app()->request->getParam('id', '');
|
|
|
- $technician_id = intval(Yii::app()->request->getParam('reset_technician', 0));
|
|
|
- $technician_name = Yii::app()->request->getParam('reset_technician_name', '');
|
|
|
+ $technicians = array();
|
|
|
+ $technician_ids = array();
|
|
|
+ $technician_names = array();
|
|
|
+ for($i=0;$i<10;$i++) {
|
|
|
+ if(Yii::app()->request->getParam('reset_extra_add_info_'.$i)) {
|
|
|
+ $technician_ids[] = $i;
|
|
|
+ $technician_names[] = Yii::app()->request->getParam('reset_extra_add_info_'.$i);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// 保洁师信息检查
|
|
|
// 根据ID直接查询保洁师信息(优先使用联想功能)
|
|
|
- if ($technician_id != 0) {
|
|
|
- $technician_obj = TechInfo::get($technician_id);
|
|
|
- if ($technician_obj) {
|
|
|
- $technician_id = $technician_obj->_id;
|
|
|
- $technician_name = $technician_obj->name;
|
|
|
- } else {
|
|
|
- CommonFn::requestAjax(false, '保洁师不存在');
|
|
|
- }
|
|
|
- // ID为0时根据输入框信息查询
|
|
|
- } else if ($technician_name != '') {
|
|
|
- $criteria = new EMongoCriteria();
|
|
|
- $criteria->name = $technician_name;
|
|
|
- $technician_obj = TechInfo::model()->find($criteria);
|
|
|
- if ($technician_obj) {
|
|
|
- $technician_id = $technician_obj->_id;
|
|
|
- $technician_name = $technician_obj->name;
|
|
|
+ $technician_objs = array();
|
|
|
+ foreach($technician_ids as $key => $technician_id) {
|
|
|
+ if ($technician_id != 0) {
|
|
|
+ $technician_obj = TechInfo::get($technician_id);
|
|
|
+ if ($technician_obj) {
|
|
|
+ $technicians[$key]['technician_id'] = $technician_obj->_id;
|
|
|
+ $technicians[$key]['technician_name'] = $technician_obj->name;
|
|
|
+
|
|
|
+ } else {
|
|
|
+ CommonFn::requestAjax(false, '保洁师不存在');
|
|
|
+ }
|
|
|
+ // ID为0时根据输入框信息查询
|
|
|
} else {
|
|
|
- CommonFn::requestAjax(false, '保洁师不存在');
|
|
|
+ foreach ($technician_names as $key => $technician_name)
|
|
|
+ if ($technician_name != '') {
|
|
|
+ $criteria = new EMongoCriteria();
|
|
|
+ $criteria->name = $technician_name;
|
|
|
+ $technician_obj = TechInfo::model()->find($criteria);
|
|
|
+ if ($technician_obj) {
|
|
|
+ $technicians[$key]['technician_id'] = $technician_obj->_id;
|
|
|
+ $technicians[$key]['technician_name'] = $technician_obj->name;
|
|
|
+ } else {
|
|
|
+ CommonFn::requestAjax(false, '保洁师不存在');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CommonFn::requestAjax(false, '保洁师姓名不能为空');
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- } else {
|
|
|
- CommonFn::requestAjax(false, '保洁师姓名不能为空');
|
|
|
+ $technician_objs[] = $technician_obj;
|
|
|
}
|
|
|
|
|
|
$orderid = new MongoId($id);
|
|
|
$order = ROrder::model()->get($orderid);
|
|
|
$toTech = $order->technician != $technician_id ? true : false;
|
|
|
$fromTech = $order->technician;
|
|
|
- $order->technician = $technician_id;
|
|
|
- $order->technician_name = $technician_name;
|
|
|
- $success = $order->save(true, array('technician', 'technician_name'));
|
|
|
-
|
|
|
- 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_id,
|
|
|
+ //$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,
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
- ),
|
|
|
- );
|
|
|
- $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_id,
|
|
|
+ // 发送给原保洁师
|
|
|
+ $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());
|