本文整理匯總了PHP中Point::update方法的典型用法代碼示例。如果您正苦於以下問題:PHP Point::update方法的具體用法?PHP Point::update怎麽用?PHP Point::update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Point
的用法示例。
在下文中一共展示了Point::update方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: implode
/**
* @brief 移動會員,修改會員等級
*/
function member_remove()
{
$user_ids = IFilter::act(IReq::get('check', 'post'), 'int');
$group_id = IFilter::act(IReq::get('move_group', 'post'), 'int');
$point = IFilter::act(IReq::get('move_point', 'post'), 'int');
if ($user_ids && is_array($user_ids)) {
$ids = implode(',', $user_ids);
if ($ids) {
$tb_member = new IModel('member');
$updatearray = array();
//積分改動
if ($point) {
$pointObj = new Point();
$userList = $tb_member->query('user_id in(' . $ids . ')', 'user_id,point');
foreach ($userList as $val) {
$c_point = intval($point - $val['point']);
if ($c_point != 0) {
$tip = $c_point > 0 ? '獎勵' : '扣除';
$pointConfig = array('user_id' => $val['user_id'], 'point' => $c_point, 'log' => '管理員' . $this->admin['admin_name'] . '修改了積分,' . $tip . $c_point . '積分');
$pointObj->update($pointConfig);
}
}
}
$updatearray['group_id'] = $group_id;
$tb_member->setData($updatearray);
$where = "user_id in (" . $ids . ")";
$tb_member->update($where);
}
}
$this->member_list();
}
示例2: array
function member_save()
{
$user_id = IFilter::act(IReq::get('user_id'), 'int');
$user_name = IFilter::act(IReq::get('username'));
$email = IFilter::act(IReq::get('email'));
$password = IFilter::act(IReq::get('password'));
$repassword = IFilter::act(IReq::get('repassword'));
$group_id = IFilter::act(IReq::get('group_id'), 'int');
$truename = IFilter::act(IReq::get('true_name'));
$sex = IFilter::act(IReq::get('sex'), 'int');
$telephone = IFilter::act(IReq::get('telephone'));
$mobile = IFilter::act(IReq::get('mobile'));
$province = IFilter::act(IReq::get('province'), 'int');
$city = IFilter::act(IReq::get('city'), 'int');
$area = IFilter::act(IReq::get('area'), 'int');
$contact_addr = IFilter::act(IReq::get('contact_addr'));
$zip = IFilter::act(IReq::get('zip'));
$qq = IFilter::act(IReq::get('qq'));
$msn = IFilter::act(IReq::get('msn'));
$exp = IFilter::act(IReq::get('exp'), 'int');
$point = IFilter::act(IReq::get('point'), 'int');
$_POST['area'] = ',' . $province . ',' . $city . ',' . $area . ',';
if (!$user_id && $password == '') {
$errorMsg = '請輸入密碼!';
}
if ($password != $repassword) {
$errorMsg = '兩次輸入的密碼不一致!';
}
//操作失敗表單回填
if (isset($errorMsg)) {
$this->userInfo = $_POST;
$this->redirect('member_edit', false);
Util::showMessage($errorMsg);
}
$member = array('true_name' => $truename, 'telephone' => $telephone, 'mobile' => $mobile, 'area' => $_POST['area'], 'contact_addr' => $contact_addr, 'qq' => $qq, 'msn' => $msn, 'sex' => $sex, 'zip' => $zip, 'exp' => $exp, 'point' => $point, 'group_id' => $group_id);
//創建會員操作類
$userDB = new IModel("user");
$memberDB = new IModel("member");
//添加新會員
if (empty($user_id)) {
$user = array('username' => $user_name, 'password' => md5($password), 'email' => $email);
$userDB->setData($user);
$user_id = $userDB->add();
$member['user_id'] = $user_id;
$member['time'] = date('Y-m-d H:i:s');
$memberDB->setData($member);
$memberDB->add();
} else {
//修改密碼
if ($password) {
$userDB->setData(array('password' => md5($password)));
$userDB->update('id = ' . $user_id);
}
$member_info = $memberDB->getObj('user_id=' . $user_id);
//修改積分記錄日誌
if ($point != $member_info['point']) {
$ctrlType = $point > $member_info['point'] ? '增加' : '減少';
$diffPoint = $point - $member_info['point'];
$pointObj = new Point();
$pointConfig = array('user_id' => $user_id, 'point' => $diffPoint, 'log' => '管理員' . $this->admin['admin_name'] . '將積分' . $ctrlType . $diffPoint . '積分');
$pointObj->update($pointConfig);
}
$memberDB->setData($member);
$memberDB->update("user_id = " . $user_id);
}
$this->redirect('member_list');
}
示例3: updateOrderStatus
/**
* 支付成功後修改訂單狀態
* @param $orderNo string 訂單編號
* @param $admin_id int 管理員ID
* @param $note string 收款的備注
* @return false or int order_id
*/
public static function updateOrderStatus($orderNo, $admin_id = '', $note = '')
{
//獲取訂單信息
$orderObj = new IModel('order');
$orderRow = $orderObj->getObj('order_no = "' . $orderNo . '"');
if (empty($orderRow)) {
return false;
}
if ($orderRow['pay_status'] == 1) {
return $orderRow['id'];
} else {
if ($orderRow['pay_status'] == 0) {
$dataArray = array('status' => 2, 'pay_time' => ITime::getDateTime(), 'pay_status' => 1);
$orderObj->setData($dataArray);
$is_success = $orderObj->update('order_no = "' . $orderNo . '"');
if ($is_success == '') {
return false;
}
//刪除訂單中使用的道具
$ticket_id = trim($orderRow['prop']);
if ($ticket_id != '') {
$propObj = new IModel('prop');
$propData = array('is_userd' => 1);
$propObj->setData($propData);
$propObj->update('id = ' . $ticket_id);
}
if (intval($orderRow['user_id']) != 0) {
$user_id = $orderRow['user_id'];
//獲取用戶信息
$memberObj = new IModel('member');
$memberRow = $memberObj->getObj('user_id = ' . $user_id, 'prop,group_id');
//(1)刪除訂單中使用的道具
if ($ticket_id != '') {
$finnalTicket = str_replace(',' . $ticket_id . ',', ',', ',' . trim($memberRow['prop'], ',') . ',');
$memberData = array('prop' => $finnalTicket);
$memberObj->setData($memberData);
$memberObj->update('user_id = ' . $user_id);
}
if ($memberRow) {
//(2)進行促銷活動獎勵
$proObj = new ProRule($orderRow['real_amount']);
$proObj->setUserGroup($memberRow['group_id']);
$proObj->setAward($user_id);
//(3)增加經驗值
$memberData = array('exp' => 'exp + ' . $orderRow['exp']);
$memberObj->setData($memberData);
$memberObj->update('user_id = ' . $user_id, 'exp');
//(4)增加積分
$pointConfig = array('user_id' => $user_id, 'point' => $orderRow['point'], 'log' => '成功購買了訂單號:' . $orderRow['order_no'] . '中的商品,獎勵積分' . $orderRow['point']);
$pointObj = new Point();
$pointObj->update($pointConfig);
}
}
//插入收款單
$collectionDocObj = new IModel('collection_doc');
$collectionData = array('order_id' => $orderRow['id'], 'user_id' => $orderRow['user_id'], 'amount' => $orderRow['order_amount'], 'time' => ITime::getDateTime(), 'payment_id' => $orderRow['pay_type'], 'pay_status' => 1, 'if_del' => 0, 'note' => $note, 'admin_id' => $admin_id ? $admin_id : 0);
$collectionDocObj->setData($collectionData);
$collectionDocObj->add();
/*同步數據*/
//同步團購的數據
if ($orderRow['type'] == 1) {
$regimentUserObj = new IModel('regiment_user_relation');
$regimentUserObj->setData(array('is_over' => 1));
$regimentUserObj->update("order_no = '" . $orderRow['order_no'] . "'");
}
//更改購買商品的庫存數量
self::updateStore($orderRow['id'], 'reduce');
return $orderRow['id'];
} else {
return false;
}
}
}
示例4: IModel
function trade_ticket()
{
$ticketId = IFilter::act(IReq::get('ticket_id', 'post'), 'int');
$message = '';
if (intval($ticketId) == 0) {
$message = '請選擇要兌換的代金券';
} else {
$nowTime = ITime::getDateTime();
$ticketObj = new IModel('ticket');
$ticketRow = $ticketObj->getObj('id = ' . $ticketId . ' and point > 0 and start_time <= "' . $nowTime . '" and end_time > "' . $nowTime . '"');
if (empty($ticketRow)) {
$message = '對不起,此代金券不能兌換';
} else {
$memberObj = new IModel('member');
$where = 'user_id = ' . $this->user['user_id'];
$memberRow = $memberObj->getObj($where, 'point');
if ($ticketRow['point'] > $memberRow['point']) {
$message = '對不起,您的積分不足,不能兌換此類代金券';
} else {
//生成紅包
$dataArray = array('condition' => $ticketRow['id'], 'name' => $ticketRow['name'], 'card_name' => 'T' . IHash::random(8), 'card_pwd' => IHash::random(8), 'value' => $ticketRow['value'], 'start_time' => $ticketRow['start_time'], 'end_time' => $ticketRow['end_time'], 'is_send' => 1);
$propObj = new IModel('prop');
$propObj->setData($dataArray);
$insert_id = $propObj->add();
//用戶prop字段值null時
$memberArray = array('prop' => ',' . $insert_id . ',');
$memberObj->setData($memberArray);
$result = $memberObj->update('user_id = ' . $this->user["user_id"] . ' and ( prop is NULL or prop = "" )');
//用戶prop字段值非null時
if (!$result) {
$memberArray = array('prop' => 'concat(prop,"' . $insert_id . ',")');
$memberObj->setData($memberArray);
$result = $memberObj->update('user_id = ' . $this->user["user_id"], 'prop');
}
//代金券成功
if ($result) {
$pointConfig = array('user_id' => $this->user['user_id'], 'point' => '-' . $ticketRow['point'], 'log' => '積分兌換代金券,扣除了 -' . $ticketRow['point'] . '積分');
$pointObj = new Point();
$pointObj->update($pointConfig);
}
}
}
}
//展示
if ($message != '') {
$this->integral();
Util::showMessage($message);
} else {
$this->redirect('redpacket');
}
}
示例5: refund
/**
* @brief 訂單退款操作
* @param int $refundId 退款單ID
* @param int $authorId 操作人ID
* @param string $type admin:管理員;seller:商家
* @param int $isNotBalance 是否充值到餘額, 0:退款餘額; 1:不退款到餘額
* @return
*/
public static function refund($refundId, $authorId, $type = 'admin', $isNotBalance = 0)
{
$orderGoodsDB = new IModel('order_goods');
$refundDB = new IModel('refundment_doc');
//獲取goods_id和product_id用於給用戶減積分,經驗
$refundsRow = $refundDB->getObj('id = ' . $refundId);
$order_id = $refundsRow['order_id'];
$order_no = $refundsRow['order_no'];
$user_id = $refundsRow['user_id'];
$orderGoodsRow = $orderGoodsDB->getObj('order_id = ' . $order_id . ' and goods_id = ' . $refundsRow['goods_id'] . ' and product_id = ' . $refundsRow['product_id'] . ' and is_send != 2');
if (!$orderGoodsRow) {
return false;
}
$order_goods_id = $orderGoodsRow['id'];
//如果管理員(商家)自定義了退款金額。否則就使用默認的付款商品金額
$amount = $refundsRow['amount'] > 0 ? $refundsRow['amount'] : $orderGoodsRow['goods_nums'] * $orderGoodsRow['real_price'];
//庫存增加
self::updateStore($order_goods_id, 'add');
//更新退款狀態
$orderGoodsDB->setData(array('is_send' => 2));
$orderGoodsDB->update('id = ' . $order_goods_id);
//更新order表狀態
$isSendData = $orderGoodsDB->getObj('order_id = ' . $order_id . ' and is_send != 2');
$orderStatus = 6;
//全部退款
if ($isSendData) {
$orderStatus = 7;
//部分退款
}
$tb_order = new IModel('order');
$tb_order->setData(array('status' => $orderStatus));
$tb_order->update('id=' . $order_id);
/**
* 進行用戶的餘額增加操作,積分,經驗的減少操作,
* 1,當全部退款時候,減少訂單中記錄的積分和經驗;且如果沒有發貨的商品直接退回訂單中的運費,報價,稅金等
* 2,當部分退款時候,查詢商品表中積分和經驗
*/
if ($orderStatus == 6) {
Order_class::resetOrderProp($order_id);
$orderRow = $tb_order->getObj('id = ' . $order_id);
//是否返還運費,報價,稅金
$isDeliveryData = $orderGoodsDB->getObj('order_id = ' . $order_id . ' and delivery_id > 0');
if (!$isDeliveryData) {
$amount += $orderRow['real_freight'] + $orderRow['insured'] + $orderRow['taxes'];
}
}
//退款積分,經驗
$goodsDB = new IModel('goods');
$goodsRow = $goodsDB->getObj('id = ' . $orderGoodsRow['goods_id']);
$orderRow = array('exp' => $goodsRow['exp'] * $orderGoodsRow['goods_nums'], 'point' => $goodsRow['point'] * $orderGoodsRow['goods_nums'], 'order_no' => $order_no);
//更新退款表
$updateData = array('amount' => $amount, 'pay_status' => 2, 'dispose_time' => ITime::getDateTime());
$refundDB->setData($updateData);
$refundDB->update('id = ' . $refundId);
//更新用戶的信息
$obj = new IModel('member');
$memberObj = $obj->getObj('user_id = ' . $user_id, 'exp,point');
$exp = $memberObj['exp'] - $orderRow['exp'];
$obj->setData(array('exp' => $exp <= 0 ? 0 : $exp));
$obj->update('user_id = ' . $user_id);
//積分記錄日誌
$pointConfig = array('user_id' => $user_id, 'point' => '-' . $orderRow['point'], 'log' => '退款訂單號:' . $orderRow['order_no'] . '中的商品,減掉積分 -' . $orderRow['point']);
$pointObj = new Point();
$pointObj->update($pointConfig);
//用戶餘額進行的操作記入account_log表
$log = new AccountLog();
$config = array('user_id' => $user_id, 'event' => 'drawback', 'num' => $amount, 'order_no' => $order_no);
if ($type == 'admin') {
$config['admin_id'] = $authorId;
$adminObj = new IModel('admin');
$adminRow = $adminObj->getObj('id = ' . $authorId);
$authorName = $adminRow['admin_name'];
} else {
if ($type == 'seller') {
$config['seller_id'] = $authorId;
$sellerObj = new IModel('seller');
$sellerRow = $sellerObj->getObj('id = ' . $authorId);
$authorName = $sellerRow['seller_name'];
}
}
//生成訂單日誌
$tb_order_log = new IModel('order_log');
$tb_order_log->setData(array('order_id' => $order_id, 'user' => $authorName, 'action' => '退款', 'result' => '成功', 'note' => '訂單【' . $order_no . '】退款,退款金額:¥' . $amount, 'addtime' => ITime::getDateTime()));
$tb_order_log->add();
return $isNotBalance == 0 ? $log->write($config) : true;
}
示例6: giftAction
/**
* @brief 贈品促銷規則獎勵操作
* @param array 贈品促銷規則獎勵信息
*/
private function giftAction($giftArray, $user_id)
{
foreach ($giftArray as $key => $val) {
$award_type = $val['award_type'];
$award_value = $val['award_value'];
switch ($award_type) {
//積分
case "3":
$pointConfig = array('user_id' => $user_id, 'point' => $award_value, 'log' => '促銷獎勵,消費滿' . $this->sum . '元,獎勵' . $award_value . '積分');
$pointObj = new Point();
$pointObj->update($pointConfig);
break;
//代金券
//代金券
case "4":
/*(1)修改prop表*/
$ticketObj = new IModel('ticket');
$where = 'id = ' . $award_value;
$ticketRow = $ticketObj->getObj($where);
//獎勵的紅包沒有過期
$time = ITime::getDateTime();
if ($time > $ticketRow['start_time'] && $time < $ticketRow['end_time']) {
$dataArray = array('condition' => $award_value, 'name' => $ticketRow['name'], 'card_name' => 'T' . IHash::random(8), 'card_pwd' => IHash::random(8), 'value' => $ticketRow['value'], 'start_time' => $ticketRow['start_time'], 'end_time' => $ticketRow['end_time'], 'is_send' => 1);
$propObj = new IModel('prop');
$propObj->setData($dataArray);
$insert_id = $propObj->add();
/*(2)修改member表*/
$memberObj = new IModel('member');
//用戶prop字段值null時
$memberArray = array('prop' => ',' . $insert_id . ',');
$memberObj->setData($memberArray);
$result = $memberObj->update('user_id = ' . $user_id . ' and ( prop is NULL or prop = "" )');
//用戶prop字段值非null時
if (!$result) {
$memberArray = array('prop' => 'concat(prop,"' . $insert_id . ',")');
$memberObj->setData($memberArray);
$memberObj->update('user_id = ' . $user_id, 'prop');
}
}
break;
//贈送經驗
//贈送經驗
case "5":
$memberObj = new IModel('member');
$memberArray = array('exp' => 'exp' + $award_value);
$memberObj->setData($memberArray);
$memberObj->update('user_id = ' . $user_id, 'exp');
break;
}
}
}
示例7: refund
/**
* @brief 訂單退款操作
* @param int $refundId 退款單ID
* @param int $authorId 操作人ID
* @param string $type admin:管理員;seller:商家
* @return
*/
public static function refund($refundId, $authorId, $type = 'admin')
{
$orderGoodsDB = new IModel('order_goods');
$refundDB = new IModel('refundment_doc');
//更新退款表
$updateData = array('pay_status' => 2, 'dispose_time' => ITime::getDateTime());
$refundDB->setData($updateData);
$refundDB->update('id = ' . $refundId);
//獲取goods_id和product_id用於給用戶減積分,經驗
$refundsRow = $refundDB->getObj('id = ' . $refundId);
$order_id = $refundsRow['order_id'];
$order_no = $refundsRow['order_no'];
$amount = $refundsRow['amount'];
$user_id = $refundsRow['user_id'];
$orderGoodsRow = $orderGoodsDB->getObj('order_id = ' . $order_id . ' and goods_id = ' . $refundsRow['goods_id'] . ' and product_id = ' . $refundsRow['product_id']);
$order_goods_id = $orderGoodsRow['id'];
//更新退款狀態
$orderGoodsDB->setData(array('is_send' => 2));
$orderGoodsDB->update('id = ' . $order_goods_id);
//更新order表狀態
$isSendData = $orderGoodsDB->getObj('order_id = ' . $order_id . ' and is_send != 2');
$orderStatus = 6;
//全部退款
if ($isSendData) {
$orderStatus = 7;
//部分退款
}
$tb_order = new IModel('order');
$tb_order->setData(array('status' => $orderStatus));
$tb_order->update('id=' . $order_id);
if ($orderStatus == 6) {
Order_class::resetOrderProp($order_id);
}
//生成訂單日誌
$authorName = $type == 'admin' ? ISafe::get('admin_name') : ISafe::get('seller_name');
$tb_order_log = new IModel('order_log');
$tb_order_log->setData(array('order_id' => $order_id, 'user' => $authorName, 'action' => '退款', 'result' => '成功', 'note' => '訂單【' . $order_no . '】退款,退款金額:¥' . $amount, 'addtime' => ITime::getDateTime()));
$tb_order_log->add();
/**
* 進行用戶的餘額增加操作,積分,經驗的減少操作,
* 1,當全部退款時候,減少訂單中記錄的積分和經驗;
* 2,當部分退款時候,查詢商品表中積分和經驗
*/
if ($orderStatus == 6) {
$orderRow = $tb_order->getObj('id = ' . $order_id);
} else {
$goodsDB = new IModel('goods');
$goodsRow = $goodsDB->getObj('id = ' . $orderGoodsRow['goods_id']);
$orderRow = array('exp' => $goodsRow['exp'], 'point' => $goodsRow['point'], 'order_no' => $order_no);
}
$obj = new IModel('member');
$memberObj = $obj->getObj('user_id = ' . $user_id, 'balance,exp,point');
$exp = $memberObj['exp'] - $orderRow['exp'];
$balance = $memberObj['balance'] + $amount;
$obj->setData(array('balance' => $balance, 'exp' => $exp <= 0 ? 0 : $exp));
$isSuccess = $obj->update('user_id = ' . $user_id);
//積分記錄日誌
$pointConfig = array('user_id' => $user_id, 'point' => '-' . $orderRow['point'], 'log' => '退款訂單號:' . $orderRow['order_no'] . '中的商品,減掉積分 -' . $orderRow['point']);
$pointObj = new Point();
$pointObj->update($pointConfig);
if ($isSuccess) {
//用戶餘額進行的操作記入account_log表
$log = new AccountLog();
$config = array('user_id' => $user_id, 'event' => 'drawback', 'num' => $amount, 'order_no' => $order_no);
if ($type == 'admin') {
$config['admin_id'] = $authorId;
} else {
if ($type == 'seller') {
$config['seller_id'] = $authorId;
}
}
$re = $log->write($config);
return true;
}
return false;
}