添加通过搜索商品名称检索商品
This commit is contained in:
parent
5dd2440209
commit
68d700a449
@ -289,4 +289,15 @@ class Goods extends Api
|
|||||||
return JsonServer::error('请求方式错误');
|
return JsonServer::error('请求方式错误');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function searchByName()
|
||||||
|
{
|
||||||
|
if($this->request->isGet()) {
|
||||||
|
$shop_name = $this->request->get('shop_name');
|
||||||
|
$data = GoodsLogic::searchByName($shop_name);
|
||||||
|
return JsonServer::success('获取成功', $data);
|
||||||
|
}else{
|
||||||
|
return JsonServer::error('请求方式错误');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ class GoodsLogic extends Logic
|
|||||||
$goodsDetail['member_price'] = 0;
|
$goodsDetail['member_price'] = 0;
|
||||||
// 会员价数组
|
// 会员价数组
|
||||||
$member_price = [];
|
$member_price = [];
|
||||||
foreach ($goodsDetail['goods_item'] as &$goods_item) {
|
foreach ($goodsDetail['goods_item'] as &$goods_item) {
|
||||||
$is_member = Goods::where('id',$goods_item['goods_id'])->value('is_member');
|
$is_member = Goods::where('id',$goods_item['goods_id'])->value('is_member');
|
||||||
$goods_item['is_member'] = $is_member;
|
$goods_item['is_member'] = $is_member;
|
||||||
if($is_member == 1 && $discount && $userId){
|
if($is_member == 1 && $discount && $userId){
|
||||||
@ -277,7 +277,7 @@ class GoodsLogic extends Logic
|
|||||||
['del', '=', 0],
|
['del', '=', 0],
|
||||||
['activity_start_time', '<=', time()],
|
['activity_start_time', '<=', time()],
|
||||||
['activity_end_time', '>=', time()]
|
['activity_end_time', '>=', time()]
|
||||||
])->findOrEmpty()->toArray();
|
])->findOrEmpty()->toArray();
|
||||||
|
|
||||||
if ($teamActivity) {
|
if ($teamActivity) {
|
||||||
$teamFound = (new TeamFound())->alias('TF')
|
$teamFound = (new TeamFound())->alias('TF')
|
||||||
@ -290,7 +290,7 @@ class GoodsLogic extends Logic
|
|||||||
['status', '=', 0],
|
['status', '=', 0],
|
||||||
['invalid_time', '>=', time()]
|
['invalid_time', '>=', time()]
|
||||||
])->join('procurement U', 'U.id=TF.user_id')
|
])->join('procurement U', 'U.id=TF.user_id')
|
||||||
->select()->toArray();
|
->select()->toArray();
|
||||||
|
|
||||||
foreach ($teamFound as &$found) {
|
foreach ($teamFound as &$found) {
|
||||||
unset($found['shop_id']);
|
unset($found['shop_id']);
|
||||||
@ -400,7 +400,8 @@ class GoodsLogic extends Logic
|
|||||||
$wh = "find_in_set(".$get['platform_cate_id'].", third_cate_id)";
|
$wh = "find_in_set(".$get['platform_cate_id'].", third_cate_id)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
// 品牌
|
// 品牌
|
||||||
if(isset($get['brand_id']) && !empty($get['brand_id']) && filter_var($get['brand_id'], FILTER_VALIDATE_INT)) {
|
if(isset($get['brand_id']) && !empty($get['brand_id']) && filter_var($get['brand_id'], FILTER_VALIDATE_INT)) {
|
||||||
@ -456,13 +457,17 @@ class GoodsLogic extends Logic
|
|||||||
$settpye = 0;
|
$settpye = 0;
|
||||||
if($p_id != 0&&$set_id!=0){
|
if($p_id != 0&&$set_id!=0){
|
||||||
$set = Procurementset::where("set_id",$set_id)->where("set_state",1)->find();
|
$set = Procurementset::where("set_id",$set_id)->where("set_state",1)->find();
|
||||||
|
// $where[] = ['second_cate_id', 'in', $set['goods_twotype']];
|
||||||
$set_array = json_decode($set['goods_onetype'], true);
|
$set_array = json_decode($set['goods_onetype'], true);
|
||||||
$w = ['second_cate_id', 'in', $set_array[0]['child_id']];
|
$w = ['second_cate_id', 'in', $set_array[0]['child_id']];
|
||||||
foreach($set_array as $key=>$value){
|
if(isset($get['platform_cate_id'])){
|
||||||
if($value['id'] == $get['platform_cate_id']){
|
foreach($set_array as $key=>$value){
|
||||||
$w = ['second_cate_id', 'in', $value['child_id']];
|
if($value['id'] == $get['platform_cate_id']){
|
||||||
|
$w = ['second_cate_id', 'in', $value['child_id']];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$where[] = $w;
|
$where[] = $w;
|
||||||
if($set != null){
|
if($set != null){
|
||||||
if($set['set_pro']!=0){
|
if($set['set_pro']!=0){
|
||||||
@ -507,6 +512,7 @@ class GoodsLogic extends Logic
|
|||||||
$set_price_type = 3;
|
$set_price_type = 3;
|
||||||
}
|
}
|
||||||
if($set['set_pro']!=0){
|
if($set['set_pro']!=0){
|
||||||
|
// $set_price_type = 1;
|
||||||
//min_price
|
//min_price
|
||||||
if($set['set_pro_type'] == 1){
|
if($set['set_pro_type'] == 1){
|
||||||
$item['purchase_price'] = round($item['purchase_price']*(100+$set['set_pro'])/100,2);
|
$item['purchase_price'] = round($item['purchase_price']*(100+$set['set_pro'])/100,2);
|
||||||
@ -517,10 +523,10 @@ class GoodsLogic extends Logic
|
|||||||
}else{
|
}else{
|
||||||
$item['purchase_price'] = "0.00";
|
$item['purchase_price'] = "0.00";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($set['set_issued']!=0){
|
if($set['set_issued']!=0){
|
||||||
|
// $set_price_type = 2;
|
||||||
//market_price
|
//market_price
|
||||||
if($set['set_issued_type'] == 1){
|
if($set['set_issued_type'] == 1){
|
||||||
$item['issuing_price'] = round($item['issuing_price']*(100+$set['set_issued'])/100,2);
|
$item['issuing_price'] = round($item['issuing_price']*(100+$set['set_issued'])/100,2);
|
||||||
@ -534,7 +540,7 @@ class GoodsLogic extends Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($set['set_wholesale']!=0){
|
if($set['set_wholesale']!=0){
|
||||||
|
// $set_price_type = 3;
|
||||||
//market_price
|
//market_price
|
||||||
if($set['set_wholesale_type'] == 1){
|
if($set['set_wholesale_type'] == 1){
|
||||||
$item['wholesale_price'] = round($item['wholesale_price']*(100+$set['set_wholesale'])/100,2);
|
$item['wholesale_price'] = round($item['wholesale_price']*(100+$set['set_wholesale'])/100,2);
|
||||||
@ -632,7 +638,7 @@ class GoodsLogic extends Logic
|
|||||||
$set_price_type = 3;
|
$set_price_type = 3;
|
||||||
}
|
}
|
||||||
if ($set['set_pro'] != 0) {
|
if ($set['set_pro'] != 0) {
|
||||||
|
// $set_price_type = 1;
|
||||||
if ($set['set_pro_type'] == 1) {
|
if ($set['set_pro_type'] == 1) {
|
||||||
$list[$key]['purchase_price'] = round($value['purchase_price'] * (100 + $set['set_pro']) / 100, 2);
|
$list[$key]['purchase_price'] = round($value['purchase_price'] * (100 + $set['set_pro']) / 100, 2);
|
||||||
}
|
}
|
||||||
@ -641,7 +647,7 @@ class GoodsLogic extends Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($set['set_issued'] != 0) {
|
if ($set['set_issued'] != 0) {
|
||||||
|
// $set_price_type = 2;
|
||||||
if ($set['set_issued_type'] == 1) {
|
if ($set['set_issued_type'] == 1) {
|
||||||
$list[$key]['issuing_price'] = round($value['issuing_price'] * (100 + $set['set_issued']) / 100, 2);
|
$list[$key]['issuing_price'] = round($value['issuing_price'] * (100 + $set['set_issued']) / 100, 2);
|
||||||
}
|
}
|
||||||
@ -650,7 +656,7 @@ class GoodsLogic extends Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($set['set_wholesale'] != 0) {
|
if ($set['set_wholesale'] != 0) {
|
||||||
|
// $set_price_type = 3;
|
||||||
if ($set['set_wholesale_type'] == 1) {
|
if ($set['set_wholesale_type'] == 1) {
|
||||||
$list[$key]['wholesale_price'] = round($value['wholesale_price'] * (100 + $set['set_wholesale']) / 100, 2);
|
$list[$key]['wholesale_price'] = round($value['wholesale_price'] * (100 + $set['set_wholesale']) / 100, 2);
|
||||||
}
|
}
|
||||||
@ -841,15 +847,31 @@ class GoodsLogic extends Logic
|
|||||||
} else {
|
} else {
|
||||||
$isShow = 0;
|
$isShow = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'is_show' => $isShow,
|
'is_show' => $isShow,
|
||||||
'earnings' => $earnings
|
'earnings' => $earnings
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
public static function getGoodsTypeList()
|
|
||||||
|
public static function searchByName($shop_name)
|
||||||
{
|
{
|
||||||
$result = GoodsCategory::where('is_show',1)->select();
|
if (!$shop_name) {
|
||||||
return $result;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$onSaleWhere = [
|
||||||
|
'del' => GoodsEnum::DEL_NORMAL, // 未删除
|
||||||
|
'status' => GoodsEnum::STATUS_SHELVES, // 上架中
|
||||||
|
'audit_status' => GoodsEnum::AUDIT_STATUS_OK, // 审核通过
|
||||||
|
];
|
||||||
|
|
||||||
|
$where[] = ['name', 'like', '%' . $shop_name . '%'];
|
||||||
|
$goods = Goods::field('id, name')
|
||||||
|
->where($onSaleWhere)
|
||||||
|
->where($where)
|
||||||
|
->select()->toArray();
|
||||||
|
|
||||||
|
return $goods;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user