xieruidong 2 年之前
父节点
当前提交
45fcd5ae5e
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      application/common/model/OrderInfo.php

+ 4 - 0
application/common/model/OrderInfo.php

@@ -57,6 +57,10 @@ class OrderInfo extends Model
         $orderInfo['amount_goods_real']=$goods['amount_goods_real'];
         $orderInfo['category_id']=$goods['goods']['category_id'];
         $orderInfo['category_name']=Category::withTrashed()->where('id',$orderInfo['category_id'])->value('name');
+        #毛利率
+        $orderInfo['amount_profit']=bcsub($orderInfo['amount_pay'],$orderInfo['amount_cost_total']);
+        $orderInfo['amount_profit_per']=bcmul(100,bcdiv($orderInfo['amount_profit'],$orderInfo['amount_pay']));
+
         if(!$orderInfo->save()){
             throw_user('保存失败');
         }