Browse Source

添加独立站的extra_price

lvhao 6 tháng trước cách đây
mục cha
commit
aefbf63352
1 tập tin đã thay đổi với 27 bổ sung0 xóa
  1. 27 0
      core/CoreApp/models/Model_api.php

+ 27 - 0
core/CoreApp/models/Model_api.php

@@ -792,6 +792,8 @@ function __construct(){
 		$post['authorid'] = isset($v['authorid'])?$v['authorid']:'';
 		$post['wjauthorid'] = isset($v['wjauthorid'])?$v['wjauthorid']:'';
 		$post['sourcecontentid'] = isset($v['sourcecontentid'])?$v['sourcecontentid']:'';
+		
+
 		$yga = $post['shouldmoney'];//金额
 		$post['budget'] = 0;
 		if(isset($v['pay']) && isset($pay[$v['pay']]) && $yga > 0)
@@ -866,6 +868,9 @@ function __construct(){
 			'row_total'=>isset($v['row_total'])?$v['row_total']:"0",
 			'price'=>isset($v['price'])?$v['price']:"0",
 		]);
+		$price_tmp = isset($v['price'])?$v['price']:"0";
+		$row_total_tmp = isset($v['row_total'])?$v['row_total']:"0";
+		$post['extra_price'] = $this->tranExtraPrice($post['issku'],$post['quantity'],$price_tmp,$row_total_tmp);
 		$post['shipremarks'] = $matching['title'];
 		$post['cost'] = $matching['cost'];
 		$post['purchase'] = $matching['purchase'];
@@ -874,6 +879,28 @@ function __construct(){
 		$post['slpx'] = $matching['wcslpx'];
 		return $post;
 	}
+
+	public function tranExtraPrice($issku,$org_qty,$org_price,$org_row_total){
+		$sku = explode(',',$issku);
+		$tmp_qty = explode(';',$org_qty);
+		$tmp_price = explode(",",$org_price);
+		$tmp_row_total = explode(",",$org_row_total);
+	
+		$extra_price = [];
+		foreach ($sku as $k=>$value) 
+		{
+			$qty = isset($tmp_qty[$k])?$tmp_qty[$k]:0;
+			$price = isset($tmp_price[$k])?$tmp_price[$k]:0;
+			$row_total = isset($tmp_row_total[$k])?$tmp_row_total[$k]:0;
+			$extra_price[$k] = [
+				'qty'=>$qty,
+				'price'=>$price,
+				'row_total'=>$row_total,
+				'sub_total'=>$price*$qty
+			];
+		}
+		return $extra_price;
+	}
     /** 
 	*
 	*