예제 #1
0
 /**
  * 服务器插入下载快券
  * @param unknown_type $uid
  * @param unknown_type $couponId
  * @param unknown_type $transSeq
  * @return 如果成功返回新插入的id, 失败返回false
  */
 public function download_coupon($uid, $couponId, $transSeq)
 {
     $CI =& get_instance();
     // 如果用户可以继续下载
     $query = $CI->db->query("insert into downloadedcoupon (uid,couponId,transSeq,createdAt) values ({$uid},{$couponId},'{$transSeq}',null)");
     if ($CI->db->affected_rows() == 0) {
         /// 如果下载失败
         log_message('error', 'Insert DownloadedCoupon: uid# ' . $uid . ', couponId #' . $couponId);
         return false;
     } else {
         //
         //调用内部服务器的数据库更新
         $id = $CI->db->insert_id();
         if ($this->coupon->dcount_increment($couponId) != true) {
             //如果自增没有完成,log
             log_message('error', 'DCount Increment: uid # ' . $uid, ', couponId #', $couponId, ',downloadedCouponId #' . $id);
         }
         return $id;
     }
 }
예제 #2
0
 public function sleep_dcoupon_get()
 {
     sleep(5);
     $this->coupon->dcount_increment(36);
     return $this->output_results('10s后的返回');
 }
예제 #3
0
 function test_coupon()
 {
     $this->coupon->dcount_increment(38);
 }