setCoin($this->member->credit1); } public function lockCoin($coin) { if (bccomp($coin, $this->member->credit1) == 1) { $pointName = LangService::getLangSet('member_center')['credit1'] ?: '积分'; throw new AppException("用户(ID:{$this->member->uid})" . $pointName . "余额不足"); } $this->member->credit1 -= $coin; } /** * @param VirtualCoin $coin * @param $data * @return bool * @throws \app\common\exceptions\ShopException */ function consume(VirtualCoin $coin, $data){ $params = [ 'point_income_type' => -1, 'point_mode' => PointService::POINT_MODE_BY, 'member_id' => $this->member->uid, 'point' => -$coin->getCoin(), 'remark' => '订单[' . $data['order_sn'] . ']抵扣[' . $coin->getMoney() . ']元' ]; // 判断:是否为积分商品 if($coin->is_point == 1){ $params['remark'] = '订单[' . $data['order_sn'] . ']消费积分'; } $point_service = new PointService($params); $point_service->changePoint(); return true; } }