public function handle_request()
 {
     $queueList = $this->getRequestData();
     if (!empty($queueList)) {
         foreach ($queueList as $v) {
             $this->createTime = time();
             $id = $v['id'];
             $startTime = date('Y-m-d', $v['createTime']);
             $couponInfo = Model_Mobile_CustomerCoupon::getInstance()->getCouponInfoById($v['couponId']);
             $effectiveTime = $couponInfo['effectiveTime'];
             $endTime = strtotime($startTime) + $effectiveTime * 24 * 3600 - 1;
             //echo "id: ".$id."; startTime:".date('Y-m-d H:i:s',$v['createTime'])." endTime: ".date('Y-m-d H:i:s',$endTime)." now: ".date('Y-m-d H:i:s',$this->createTime)."\n";
             //设置游标
             $this->setMyFlag($v['id']);
             if ($this->createTime > $endTime) {
                 $keyData = array('id' => $id);
                 $data = array('status' => self::STATUS_OVER, 'updateTime' => date('Y-m-d H:i:s', $this->createTime));
                 Bll_CustomerRush_Coupon::getInstance()->updateBrokerCoupon($keyData, $data);
                 $num = $v['totalNum'] - $v['usedNum'];
                 $this->_consumeCouponLog($v['brokerId'], $v['id'], $num);
             }
         }
     }
 }
Exemple #2
0
 public function getBrokerOldestCouponEx($brokerId)
 {
     $couponIds = array();
     $couponInfo = array();
     $couponList = Model_Mobile_CustomerBrokerCoupon::getInstance()->getDataByBrokerIdIfMaster($brokerId, Model_Mobile_CustomerBrokerCoupon::STATUS_OK_USE, '', '', true);
     //$couponList = Model_Mobile_CustomerBrokerCoupon::getInstance()->getBrokerOldestCoupon($brokerId,Model_Mobile_CustomerBrokerCoupon::STATUS_OK_USE);
     foreach ($couponList as $k => $v) {
         $couponIds[] = $v['couponId'];
     }
     $couponIds = array_unique($couponIds);
     $couponInfoTmp = Model_Mobile_CustomerCoupon::getInstance()->getDataByIds($couponIds);
     foreach ($couponInfoTmp as $v) {
         $couponInfo[$v['id']] = $v;
     }
     $expiredCoupon = $couponList[0];
     foreach ($couponList as $k => $v) {
         $couponTime = $v['createTime'] + $couponInfo[$v['couponId']]['effectiveTime'] * 86400 - time();
         $currentCouponTime = $expiredCoupon['createTime'] + $couponInfo[$expiredCoupon['couponId']]['effectiveTime'] * 86400 - time();
         if ($couponTime < $currentCouponTime) {
             $expiredCoupon = $v;
         }
     }
     return $expiredCoupon;
 }