コード例 #1
0
ファイル: function.php プロジェクト: riyuexing/huike
/**
 * 创建随机字符串。
 * @return string 随机字符串
 */
function create_rand_str()
{
    if (APP_DEBUG) {
        trace("创建随机字符串...");
    }
    return Org\Util\String::randString();
}
コード例 #2
0
ファイル: function.php プロジェクト: huangxulei/app
/**
 * 对用户的密码进行加密
 * @param string $password
 * @param string $encrypt //传入加密串,在修改密码时做认证
 * @return array/password
 */
function password($password, $encrypt = '')
{
    $pwd = array();
    $pwd['encrypt'] = $encrypt ? $encrypt : Org\Util\String::randString(6);
    $pwd['password'] = md5(md5(trim($password)) . $pwd['encrypt']);
    return $encrypt ? $pwd['password'] : $pwd;
}
コード例 #3
0
 /**
  *代购订单
  */
 public function buyAccept()
 {
     $info = I('post.');
     $phone = $info['phone'];
     $save = $info;
     if ($phone != session('phone')) {
         $return = ['status' => '-10', 'info' => '账户不存在'];
         $this->ajaxReturn($return);
     } else {
         $save['userId'] = session('userId');
     }
     if ($info['sendAddr'] == null || $info['goodsDesc'] == null || $info['priceLimit'] == null || $info['runnerFee'] == null) {
         $return = ['status' => '-100', 'info' => '请完整填写上述内容'];
         $this->ajaxReturn($return);
     }
     $save['recipientTel'] = $phone;
     if (!is_null(session("userName"))) {
         $save['recipientName'] = session("userName");
     } else {
         $save['recipientName'] = session("userNick");
     }
     $save['sendAddr'] = $info['sendAddr'] . $info['sendDet'];
     $location = $this->locationToLal($info['sendAddr']);
     $save['longitude'] = $location['lng'];
     $save['latitude'] = $location['lat'];
     M('purchase')->add($save);
     $sendId = M('purchase')->getLastInsID();
     $string = new \Org\Util\String();
     $randNum = $string->randString(8, 1);
     $orderNo = "B" . time() . $randNum;
     $order = ['orderNo' => $orderNo, 'type' => 1, 'orderTime' => date('Y-m-d H-i-s', time()), 'userId' => session('userId'), 'payStatus' => 0, 'status' => 0, 'binCode' => '111', 'sendId' => $sendId, 'money' => $info['runnerFee'], 'revenue' => $this->revenue($info['runnerFee'])];
     M('orders')->add($order);
     $return = ['status' => '0', 'info' => 'success', 'orderNo' => $orderNo, 'money' => $info['runnerFee']];
     $this->ajaxReturn($return);
 }
コード例 #4
0
 public function submitOrder()
 {
     if (!$this->isLogin()) {
         $this->redirect('Home/register');
     }
     $this->commonProcess();
     $orderLogic = D('Order', 'Logic');
     $userId = $this->getCurrentUserId();
     $backlogOrder = $orderLogic->getOrderByUserId($userId, 'N');
     if (count($backlogOrder) > 0) {
         $order = $backlogOrder[0];
         //如果没有地址,用默认地址
         if ($order['shippingAddress'] == 0) {
             $defaultAddress = D("ShippingAddress", "Logic")->getDefaultAddress($userId);
             $data['shippingAddress'] = $defaultAddress['addressId'];
         }
         //检查库存
         $inadequateInventoryItems = $this->checkOrderItemsInventory($order['orderId']);
         if (count($inadequateInventoryItems) > 0) {
             $this->redirect('Cart/index', array('itemId' => $inadequateInventoryItems['itemId'], 'itemSize' => $inadequateInventoryItems['itemSize']));
         }
         if ($order['orderNumber'] == '') {
             //生成订单号,规则: 数字8(1位) + 年份最后1位,如2016最后一位6(1位) + 月份,如04(2位) + 日期,如12(2位) + 当前秒数,如59(2位) + 用户ID后2位,如87(2位) + 随机数(2位)
             $strUtil = new \Org\Util\String();
             $orderNumber = '8' . substr(date("Ymds"), 3) . substr($userId, -2) . $strUtil->randString(2, 1);
             $data['orderNumber'] = $orderNumber;
         } else {
             $orderNumber = $order['orderNumber'];
         }
         $data['orderDate'] = date("Y-m-d H:i:s", time());
         $orderLogic->updateOrder($data, $order['orderId']);
         $this->redirect('Payment/index', array('orderNumber' => $orderNumber));
     }
 }