本文整理匯總了PHP中UserModule::sub_score方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserModule::sub_score方法的具體用法?PHP UserModule::sub_score怎麽用?PHP UserModule::sub_score使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserModule
的用法示例。
在下文中一共展示了UserModule::sub_score方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: exchange_commodity
public function exchange_commodity($com_id, $mobile, $address, $name)
{
$comsrv = new CommodityService();
$com = $comsrv->get_by_id($com_id);
if ($com->count <= 0) {
return GOOD_IS_ZERO;
}
$user_info = $this->get_by_uuid($this->user->uuid);
if ($com->price > $user_info->scores) {
return USER_ERR_SCORE_NOT_ENOUGH;
}
// 插入兌換記錄
$result = $comsrv->add_exch_record($com_id, $this->user->uuid, $mobile, $address, $name);
if ($result) {
$umod = new UserModule($this->user->uuid);
$score = 0 - $com->price;
$rs = $umod->sub_score($this->user->uuid, $score);
$comsrv->dec_com($com_id);
}
return $result;
}
示例2: add_score
public function add_score($user, $record)
{
$userMod = new UserModule($user->uuid);
$score_record = $this->scoremod->add_record($record);
// 添加積分記錄
if ($score_record) {
if ($record->type == 1) {
$amount = -$record->amount;
} else {
$amount = $record->amount;
}
$userMod->sub_score($user->uuid, $amount);
// 添加積分
}
}