|
@@ -13,7 +13,7 @@ class ROrder extends MongoAr
|
|
|
public $charge_id;//ping++的chargeId,charge_id即为支付单号
|
|
|
public $pay_channel;//支付渠道
|
|
|
public $channel;//订单来源渠道
|
|
|
-
|
|
|
+ public $precedence = 0;//加急 默认0
|
|
|
public $booking_time; //用户预约的时间
|
|
|
public $order_time; //订单生成时间
|
|
|
public $deal_time; //订单处理时间
|
|
@@ -24,7 +24,7 @@ class ROrder extends MongoAr
|
|
|
public $cancel_time; //订单取消时间
|
|
|
public $apply_refund_time; //订单申请退款时间
|
|
|
public $refund_time; //订单退款时间
|
|
|
-
|
|
|
+ public $append_orders = array();
|
|
|
public $products=array(); //订单包含的商品数组 数据库设计 支持多个产品在一个订单
|
|
|
|
|
|
public $price; //订单金额
|
|
@@ -334,7 +334,7 @@ class ROrder extends MongoAr
|
|
|
protected function afterSave() {
|
|
|
parent::afterSave();
|
|
|
|
|
|
- $tech = TechInfo::get($this->technicians);
|
|
|
+
|
|
|
// 生成保洁师提成并保存
|
|
|
if ($this->status == 6 && !empty($this->technicians)) {
|
|
|
// 订单时间检查
|
|
@@ -351,70 +351,73 @@ class ROrder extends MongoAr
|
|
|
|
|
|
$order = $this->_id;
|
|
|
$commisionObj = Commision::getByOrder($order);
|
|
|
-
|
|
|
- // 检查Cmmmision信息是否已录入
|
|
|
- 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();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
+ // 检查Cmmmision信息是否已录入
|
|
|
+ foreach ($this->technicians as $key => $value) {
|
|
|
+ $technician_id = $value['technician_id'];
|
|
|
+ $technician = $value['technician_name'];
|
|
|
+ $tech = TechInfo::get($technician_id);
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 提示保洁师订单已完成
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // 提示保洁师订单已完成
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
}
|