setCoin($this->member->credit2); } public function lockCoin($coin) { if (bccomp($coin, $this->member->credit2) == 1) { $name = (new BalanceCoin())->getName(); throw new AppException("用户(ID:{$this->member->uid})" . $name . "不足"); } $this->member->credit2 -= $coin; } /** * @param VirtualCoin $coin * @param $data * @return bool * @throws \app\common\exceptions\ShopException */ function consume(VirtualCoin $coin, $data) { $data = [ 'member_id' => $this->member->uid, 'remark' => '订单[' . $data['order_sn'] . ']抵扣[' . $coin->getMoney() . ']元', 'relation' => $data['order_sn'], 'operator' => ConstService::OPERATOR_MEMBER, 'operator_id' => $this->member->uid, 'change_value' => $coin->getCoin(), ]; $result = (new BalanceChange())->deduction($data); return $result; } }