setCoin($this->member->credit1); } public function lockCoin($coin) { if (bccomp($coin, $this->member->credit1) == 1) { $pointName = \Setting::get('shop.shop.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) { $point_service = new PointService([ 'point_income_type' => -1, 'point_mode' => PointService::POINT_MODE_BY, 'member_id' => $this->member->uid, 'point' => -$coin->getCoin(), 'remark' => '订单[' . $data['order_sn'] . ']抵扣[' . $coin->getMoney() . ']元' ]); $point_service->changePoint(); return true; } }