|
@@ -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);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|