|
@@ -2692,4 +2692,62 @@ class Sale extends BaseController
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ public function getPrice(){
|
|
|
+ $skuCode=isset($this->post['skuCode'])&&$this->post['skuCode']!=""?trim($this->post['skuCode']):"";
|
|
|
+ if($skuCode===""){
|
|
|
+ return error_show(1003,"参数skuCode不能为空");
|
|
|
+ }
|
|
|
+ $is_activity=isset($this->post['is_activity'])&&$this->post['is_activity']!==""?intval($this->post['is_activity'])
|
|
|
+ :"";
|
|
|
+ if($is_activity===""){
|
|
|
+ return error_show(1003,"参数is_activity不能为空");
|
|
|
+ }
|
|
|
+ $sale_num=isset($this->post['sale_num'])&&$this->post['sale_num']!==""?intval($this->post['sale_num']):"";
|
|
|
+ if($sale_num===""){
|
|
|
+ return error_show(1003,"参数sale_num不能为空");
|
|
|
+ }
|
|
|
+ if($is_activity==1){
|
|
|
+ $act = Db::name("activity_info")->alias("a")->leftJoin("good_activity b","a.activity_code=b.activity_code")
|
|
|
+ ->where(["a.skuCode"=>$skuCode,"a.is_del"=>0,"a.status"=>1,"b.status"=>6,"b.is_del"=>0])->find();
|
|
|
+ if($act==false){
|
|
|
+ return error_show(1003,"未找到相关活动价");
|
|
|
+ }
|
|
|
+ if($act['moq_num']>$sale_num){
|
|
|
+ return error_show(1003,"商品不满足活动价起订量{$act['moq_num']}");
|
|
|
+ }
|
|
|
+ if($act['activity_stock']<$sale_num){
|
|
|
+ return error_show(1003,"商品活动库存剩余{$act['moq_num']}");
|
|
|
+ }
|
|
|
+ return app_show(0,"获取成功",['sale_price'=>$act['activity_price']]);
|
|
|
+ }else{
|
|
|
+ $good = Db::name("good_ladder")->where(["skuCode"=>$skuCode,"is_del"=>0,"status"=>1])->order("min_num desc")
|
|
|
+ ->select()->toArray();
|
|
|
+ if(empty($good)){
|
|
|
+ return error_show(1003,"未找到相关阶梯价格");
|
|
|
+ }
|
|
|
+ $lastnum=0;
|
|
|
+ $lastprice=0;
|
|
|
+ foreach ($good as $value){
|
|
|
+
|
|
|
+ if($value['min_num']>$sale_num){
|
|
|
+ $lastnum=$value['min_num'];
|
|
|
+ $lastprice=0;
|
|
|
+ continue;
|
|
|
+ }else{
|
|
|
+ $lastnum=0;
|
|
|
+ $lastprice=$value['sale_price'];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if($lastnum==0){
|
|
|
+ return app_show(0,"获取成功",['sale_price'=>$lastprice]);
|
|
|
+ }else{
|
|
|
+ return error_show(1003,"商品不满足起订量{$lastnum}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
}
|