Exemple #1
0
 public static function newOne($phone, $passwd, $nickname, $sex, $headimgurl)
 {
     if (DB::getDB('w')->beginTransaction() === false) {
         return false;
     }
     if (!empty($phone)) {
         $ret = self::findUserByPhone($phone, 'w');
         if (!empty($ret)) {
             DB::getDB('w')->rollBack();
             return false;
         }
     }
     $data = array('phone' => $phone, 'passwd' => $passwd, 'nickname' => Util::emojiEncode($nickname), 'sex' => $sex, 'headimgurl' => $headimgurl, 'state' => self::USER_ST_DEFAULT, 'ctime' => CURRENT_TIME, 'mtime' => CURRENT_TIME);
     $ret = DB::getDB('w')->insertOne('u_user', $data);
     if ($ret === false || (int) $ret <= 0) {
         DB::getDB('w')->rollBack();
         return false;
     }
     $ret = UserDetailModel::newOne($ret);
     if ($ret === false) {
         DB::getDB('w')->rollBack();
         return false;
     }
     if (DB::getDB('w')->commit() === false) {
         return false;
     }
     self::onUpdateData($ret);
     return true;
 }
Exemple #2
0
 public static function newOne($userId, $goodsId, $orderId, $nickname, $score, $content, $imageUrls)
 {
     if (empty($goodsId) || empty($userId) || empty($orderId) || empty($content)) {
         return false;
     }
     $data = array('user_id' => $userId, 'goods_id' => $goodsId, 'order_id' => $orderId, 'nickname' => Util::emojiEncode($nickname), 'score' => $score, 'content' => Util::emojiEncode($content), 'image_urls' => $imageUrls, 'state' => self::COMMENT_ST_VALID, 'ctime' => CURRENT_TIME);
     $ret = DB::getDB('w')->insertOne('g_goods_comment', $data);
     if ($ret === false) {
         return false;
     }
     $ck = Cache::CK_GOODS_HAD_COMMENT . $userId . ':' . $orderId . ':' . $goodsId;
     Cache::setEx($ck, Cache::CK_GOODS_HAD_COMMENT_EXPIRE, '1');
     return true;
 }
Exemple #3
0
 public static function updateWxUserInfo($userInfo, $wxUserInfo, $from)
 {
     $openid = $wxUserInfo['openid'];
     if (empty($openid) || empty($wxUserInfo) || empty($userInfo)) {
         return false;
     }
     $data = array();
     if (isset($wxUserInfo['nickname']) && $userInfo['nickname'] != $wxUserInfo['nickname']) {
         $data['nickname'] = Util::emojiEncode($wxUserInfo['nickname']);
     }
     if (isset($wxUserInfo['sex']) && $userInfo['sex'] != $wxUserInfo['sex']) {
         $data['sex'] = $wxUserInfo['sex'];
     }
     if (isset($wxUserInfo['headimgurl']) && $userInfo['headimgurl'] != $wxUserInfo['headimgurl']) {
         $data['headimgurl'] = $wxUserInfo['headimgurl'];
     }
     if (isset($wxUserInfo['province']) && $userInfo['province'] != $wxUserInfo['province']) {
         $data['province'] = $wxUserInfo['province'];
     }
     if (isset($wxUserInfo['city']) && $userInfo['city'] != $wxUserInfo['city']) {
         $data['city'] = $wxUserInfo['city'];
     }
     if (isset($wxUserInfo['subscribe']) && $userInfo['subscribe'] != $wxUserInfo['subscribe']) {
         $data['subscribe'] = $wxUserInfo['subscribe'];
     }
     if (isset($wxUserInfo['subscribe_time']) && $userInfo['subscribe_time'] != $wxUserInfo['subscribe_time']) {
         $data['subscribe_time'] = $wxUserInfo['subscribe_time'];
     }
     if ($userInfo['subscribe_from'] == 0) {
         // 仅记首次
         $data['subscribe_from'] = $from;
     }
     if (isset($wxUserInfo['unionid']) && $userInfo['unionid'] != $wxUserInfo['unionid']) {
         $data['unionid'] = $wxUserInfo['unionid'];
     }
     if (empty($data)) {
         return true;
     }
     $ret = DB::getDB('w')->update('u_wx_user', $data, array('openid'), array($openid), false, 1);
     self::onUpdateData($openid);
     return $ret !== false;
 }