Пример #1
0
 /**
  * 卖出卡车
  * @param $params
  * require  u         --  user_id
  * require  d         --  car id array
  * @return
  * s   -- OK
  * a   -- user account
  */
 public function sale($params)
 {
     $uid = $params['u'];
     $tu = new TTUser($uid);
     foreach ($params['d'] as $index => $id) {
         $car_obj = $tu->getbyid($id);
         if (!$car_obj) {
             $ret['s'] = 'notexist';
             $ret['index'] = $index;
             return $ret;
         }
         $sale_ret = $tu->saleItem($car_obj);
         if ($sale_ret['s'] != 'OK') {
             $sale_ret['index'] = $index;
             return $sale_ret;
         }
     }
     $tu->remove($params['d']);
     $ret['s'] = 'OK';
     return $ret;
 }
Пример #2
0
 /**
  * 卖出
  * @param $params
  *  require u  -- user id
  *  require d  -- item_id 数组
  *     
  * @return 
  *  s   -- OK ,or other fail
  *                                     notexsit ,不存在配置
  *                                     notsale ,不能购买的物品
  *                                     level,等级未到 
  *                                     achive, 所需成就buy_need_achiveid 未达成 
  *                                     task,所需任务未达成
  *                                     buynumlimit,限量版已经卖完
  *                                     money,
  *				      gem
  */
 public function sale($params)
 {
     $uid = $params['u'];
     $tu = new TTUser($uid);
     if ($tu->check_dup($params['_cid'], $ret)) {
         return $ret;
     }
     foreach ($params['d'] as $index => $id) {
         $item_obj = $tu->getbyid($id);
         if (!$item_obj) {
             $ret['s'] = 'notexsit';
             $ret['index'] = $index;
             return $ret;
         }
         $item = ItemConfig::getItem($item_obj['tag']);
         if (!$item) {
             $ret['s'] = 'notexsit';
             $ret['index'] = $index;
             return $ret;
         }
         $sale_ret = $tu->saleItem($item_obj);
         if ($sale_ret['s'] != 'OK') {
             $sale_ret['index'] = $index;
             return $sale_ret;
         }
         if ($item_obj['pos'] != 's') {
             $pop -= $item['pop'];
         }
     }
     if ($pop) {
         $tu->numch(TT::POPU, $pop);
     }
     $tu->remove($params['d']);
     $ret['s'] = 'OK';
     return $ret;
 }