购物车

parent 9ffe949b
...@@ -44,6 +44,7 @@ class CartApiController extends Controller ...@@ -44,6 +44,7 @@ class CartApiController extends Controller
//购物车列表 //购物车列表
public function cartLists(Request $request){ public function cartLists(Request $request){
$result = CartService::cartLists($request->user->id); $result = CartService::cartLists($request->user->id);
return $this->setSuccessData($result);
} }
......
...@@ -61,3 +61,40 @@ function numberToHtml($number){ ...@@ -61,3 +61,40 @@ function numberToHtml($number){
return $number; return $number;
} }
} }
/**
* 生成纯小写字母的字符串
*
*/
function strRandom($class='',$len_num=3){
$randstr = 'asdwpkxmiqplmzacbmeruwulurjlauejrifkfghjklzxcvbnmqwwertyuiopkdsieurnvewjeilweiskvnx';
$len = strlen($randstr)-9;
$res = '';
for($i=0;$i<$len_num;$i++){
$start = rand(0,$len);
$str = substr($randstr, $start,9);
$res .= ' '.$str;
}
return $res;
}
/*
* 计算最大购买数量
*/
function getMaxBuyStock($stock,$multiple,$ladder_price){
//todo 2022.9.27 计算最大购买数量
$max_buy_stock = 0;
if ($stock > 0 && $multiple >0){
$max_buy_stock1 = intval($stock/$multiple)*$multiple; //库存最大购买数量
if ($ladder_price){ //梯度价库存最大购买数量
$max_pur_num = @$ladder_price[count($ladder_price)-1]["purchases"];
$max_buy_stock2 = intval($max_pur_num/$multiple)*$multiple; //库存最大购买数量
$max_buy_stock = $max_buy_stock1 > $max_buy_stock2 ? $max_buy_stock2:$max_buy_stock1;
}else{
$max_buy_stock = $max_buy_stock1;
}
}
return $max_buy_stock;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment