getChangedData(); //拒接回退积分 if (isset($changeData['status']) && $changeData['status'] == 'rejected') { Db::transaction(function () use ($row) { User::score($row['score'], $row['user_id'], '积分兑换已拒绝,积分退还'); //库存,销量回调 Exchange::where('id', $row['exchange_id'])->setInc('stocks', $row['nums']); Exchange::where('id', $row['exchange_id'])->setDec('sales', $row['nums']); }); } }); } public function getTypeList() { return ['virtual' => __('Type virtual'), 'reality' => __('Type reality')]; } public function getStatusList() { return ['created' => __('Created'), 'inprogress' => __('Inprogress'), 'rejected' => __('Rejected'), 'delivered' => __('Delivered'), 'completed' => __('Completed')]; } public function getTypeTextAttr($value, $data) { $value = $value ?: ($data['type'] ?? ''); $list = $this->getTypeList(); return $list[$value] ?? ''; } public function getStatusTextAttr($value, $data) { $value = $value ?: ($data['status'] ?? ''); $list = $this->getStatusList(); return $list[$value] ?? ''; } public function Exchange() { return $this->belongsTo('Exchange', 'exchange_id', 'id', [], 'LIKE'); } public function User() { return $this->belongsTo('\app\common\model\User', 'user_id', 'id', [], 'LEFT'); } }