'全部', self::Waiting => '待发货', self::Shipped => '已发货', self::Finish => '完成' ]; //出售记录 public static function getCreateUserBuying(int $uid, int $buyingId, int $orderId, int $fromId, float $amount) { $fee = bcmul(config('market_transfer.serve_fee'), $amount, 2); $income = bcsub($amount, $fee, 2); self::create([ 'user_id' => $uid, 'buying_id' => $buyingId, 'order_id' => $orderId, 'from_id' => $fromId, 'amount' => $amount, 'fee' => $fee, 'income' => $income, ]); return [$income,$fee]; } //users //用户 public function users() { return $this->hasOne('UserModel', 'id', 'user_id', [], 'LEFT')->setEagerlyType(0); } public function fromuser() { return $this->hasOne('UserModel', 'id', 'from_id', [], 'LEFT')->setEagerlyType(0); } //产品 public function productlists() { return $this->hasOne('ProductLists', 'id', 'product_id', [], 'LEFT')->setEagerlyType(0); } //订单 public function orders() { return $this->hasOne('ProductOrder', 'id', 'order_id', [], 'LEFT')->setEagerlyType(0); } public function getCreateTimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } public function getUpdateTimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } protected function setCreateTimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } protected function setUpdateTimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } }