|
@@ -3,6 +3,7 @@
|
|
|
namespace app\api\controller\water;
|
|
|
|
|
|
use app\admin\model\sms\SmsRecord;
|
|
|
+use app\admin\model\user\UserGroup;
|
|
|
use app\admin\model\water\WaterCate;
|
|
|
use app\admin\model\water\WaterMaterial;
|
|
|
use app\admin\model\water\WaterMaterialScience;
|
|
@@ -49,6 +50,7 @@ class WaterQueryController
|
|
|
// }
|
|
|
// }
|
|
|
//顶板
|
|
|
+ $data['uid'] = $request->uid();
|
|
|
$calculation = $this->calculation($data);
|
|
|
$amount = $this->AmountOfMoney($calculation, $data);// 计算总价,表格
|
|
|
Db::startTrans();
|
|
@@ -115,6 +117,11 @@ class WaterQueryController
|
|
|
|
|
|
public function AmountOfMoney($calculation, $data)
|
|
|
{
|
|
|
+ $user = User::where('uid', $data['uid'])->find();
|
|
|
+ $discount = 0;
|
|
|
+ if ($user['group_id'] > 0){
|
|
|
+ $discount = UserGroup::where('id', $user['group_id'])->value('discount');
|
|
|
+ }
|
|
|
$table = [];
|
|
|
$zj = 0; //总价
|
|
|
$zzl = 0; // 总重量
|
|
@@ -200,7 +207,7 @@ class WaterQueryController
|
|
|
$lac_storey = 0;
|
|
|
foreach ($calculation['lacing_number'] as $v){
|
|
|
$lac_storey ++;
|
|
|
- $details = WaterMaterialScience::where('cate_id', $data['lacing'][$lac_storey-1])->where([['long', '=', 4], ['wide', '=', 4]])->where($where)->find();
|
|
|
+ $details = WaterMaterialScience::where('cate_id', $data['lacing'][$lac_storey-1])->where($where)->find();
|
|
|
$zj += $details['unit_price'] * $v;
|
|
|
$zzl += $details['weight'] * $v;
|
|
|
$table[] = ['title' => '主拉B'.$lac_storey.'层' , 'name' => $details['name'], 'specifications' => '1', 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v , 'type' => 3];
|
|
@@ -210,7 +217,7 @@ class WaterQueryController
|
|
|
$fula_storey = 0;
|
|
|
foreach ($calculation['fula_number'] as $v){
|
|
|
$fula_storey ++;
|
|
|
- $details = WaterMaterialScience::where('cate_id', $data['fula'][$fula_storey-1])->where([['long', '=', 4], ['wide', '=', 4]])->where($where)->find();
|
|
|
+ $details = WaterMaterialScience::where('cate_id', $data['fula'][$fula_storey-1])->where($where)->find();
|
|
|
$zj += $details['unit_price'] * $v;
|
|
|
$zzl += $details['weight'] * $v;
|
|
|
$table[] = ['title' => '辅拉B'.$fula_storey.'层' , 'name' => $details['name'], 'specifications' => '1', 'number' => $v, 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $v, 'weight' => $details['weight'] * $v , 'type' => 6];
|
|
@@ -257,11 +264,24 @@ class WaterQueryController
|
|
|
$zzl += $details['weight'] * $calculation['ladder'];
|
|
|
$table[] = ['title' => '扶梯' , 'name' => $details['name'], 'specifications' => '1', 'number' => $calculation['ladder'], 'unit_price' => $details['unit_price'], 'company' => $details['company'], 'ot_price' => $details['unit_price'] * $calculation['ladder'], 'weight' => $details['weight'] * $calculation['ladder'] , 'type' => 9];
|
|
|
}
|
|
|
+
|
|
|
foreach ($table as &$i){
|
|
|
$i['ot_price'] = round($i['ot_price'], 2);
|
|
|
}
|
|
|
+ if ($discount > 0){
|
|
|
+
|
|
|
+ foreach ($table as &$item)
|
|
|
+ {
|
|
|
+ $item['unit_price'] = $item['unit_price'] * $discount;
|
|
|
+ $item['ot_price'] = $item['ot_price'] * $discount;
|
|
|
+ }
|
|
|
+ return ['table' => $table, 'zj' => $zj * $discount, 'zzl' => $zzl];
|
|
|
+ }else{
|
|
|
+ return ['table' => $table, 'zj' => $zj, 'zzl' => $zzl];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- return ['table' => $table, 'zj' => $zj, 'zzl' => $zzl];
|
|
|
|
|
|
}
|
|
|
|