<?php namespace App\Models; use Dcat\Admin\Traits\HasDateTimeFormatter; use Illuminate\Database\Eloquent\Model; class OrderPrice extends Model { use HasDateTimeFormatter; protected $table = 'order_price'; protected $primaryKey = 'price_id'; protected $guarded = ['price_id']; //设置字段黑名单 public $timestamps = false; public static $PRICE_TYPE_LIST=[ "活动优惠"=>-8, "支付优惠"=>-7, "运费优惠"=>-6, "尾款减款"=>-5, "优惠券优惠金额"=>-4, "尾款"=>-3, "预付款"=>-2, "付款"=>-1, "货款"=>1, "附加费"=>2, "运费"=>3, "退款"=>4, "支付手续费"=>5, ]; //新增或者修改订单的 运费 支付手续费 public static function editOrderSettlement($orderId,$orderSn,$freightCharge,$payCommission){ self::updateOrCreate([ "order_id"=>$orderId, "price_type"=>self::$PRICE_TYPE_LIST["运费"], ],[ "order_sn"=>$orderSn, "price"=>decimal_number_format($freightCharge), "currency"=>2, "create_time"=>time(), ]); self::updateOrCreate([ "order_id"=>$orderId, "price_type"=>self::$PRICE_TYPE_LIST["支付手续费"], ],[ "order_sn"=>$orderSn, "price"=>decimal_number_format($payCommission), "currency"=>2, "create_time"=>time(), ]); } // public static function updateOrderAmount($orderId,$orderSn,$orderAmount=0){ self::updateOrCreate([ "order_id"=>$orderId, "price_type"=>self::$PRICE_TYPE_LIST["货款"], ],[ "order_sn"=>$orderSn, "price"=>decimal_number_format($orderAmount), "currency"=>2, "create_time"=>time(), ]); } }