|
@@ -3,17 +3,12 @@
|
|
|
namespace App\Service;
|
|
|
|
|
|
use App\Model\BasicType;
|
|
|
-use App\Model\Depart;
|
|
|
use App\Model\Employee;
|
|
|
use App\Model\Product;
|
|
|
-use App\Model\ProductCategory;
|
|
|
-use App\Model\ProductInfo;
|
|
|
-use App\Model\ProductIntroduction;
|
|
|
-use App\Model\ProductPriceDetail;
|
|
|
-use App\Model\ProductRange;
|
|
|
+use App\Model\ProductActivity;
|
|
|
+use App\Model\ProductActivityPrice;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
-
|
|
|
class ProductActivityService extends Service
|
|
|
{
|
|
|
public function productEdit($data,$user){
|
|
@@ -23,108 +18,33 @@ class ProductActivityService extends Service
|
|
|
try {
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
- $model = Product::where('id',$data['id'])->first();
|
|
|
- $model->product_category_id = $data['product_category_id'] ?? 0;
|
|
|
+ $model = ProductActivity::where('id',$data['id'])->first();
|
|
|
$model->title = $data['title'];
|
|
|
- $model->code = $data['code'] ?? '';
|
|
|
- $model->size = $data['size'] ?? '';
|
|
|
- $model->unit = $data['unit'] ?? 0;
|
|
|
- $model->bar_code = $data['bar_code'] ?? '';
|
|
|
- $model->cost = $data['cost'] ?? 0;
|
|
|
- $model->retail_price = $data['retail_price'] ?? 0;
|
|
|
+ $model->start_time = $data['start_time'] ?? 0;
|
|
|
+ $model->end_time = $data['end_time'] ?? 0;
|
|
|
$model->mark = $data['mark'] ?? '';
|
|
|
- $model->state = $data['state'] ?? 0;
|
|
|
$model->save();
|
|
|
|
|
|
$time = time();
|
|
|
|
|
|
- ProductIntroduction::where('product_id',$data['id'])
|
|
|
+ ProductActivityPrice::where('product_activity_id',$data['id'])
|
|
|
->where('del_time',0)
|
|
|
->update(['del_time' => $time]);
|
|
|
- if(! empty($data['introduction'])){
|
|
|
- $models = new ProductIntroduction();
|
|
|
- $models->product_id = $model->id;
|
|
|
- $models->introduction = $data['introduction'];
|
|
|
- $models->save();
|
|
|
- }
|
|
|
-
|
|
|
- ProductInfo::where('del_time',0)
|
|
|
- ->where('product_id',$data['id'])
|
|
|
- ->update(['del_time' => $time]);
|
|
|
-
|
|
|
- if(! empty($data['img'])){
|
|
|
- $insert = [];
|
|
|
- foreach ($data['img'] as $value){
|
|
|
- $insert[] = [
|
|
|
- 'product_id' => $model->id,
|
|
|
- 'file' => $value['url'],
|
|
|
- 'type' => ProductInfo::type_one,
|
|
|
- 'name' => $value['name'],
|
|
|
- 'crt_time' => $time,
|
|
|
- ];
|
|
|
- }
|
|
|
- ProductInfo::insert($insert);
|
|
|
- }
|
|
|
-
|
|
|
- if(! empty($data['file'])){
|
|
|
- $insert = [];
|
|
|
- foreach ($data['file'] as $value){
|
|
|
- $insert[] = [
|
|
|
- 'product_id' => $model->id,
|
|
|
- 'file' => $value['url'],
|
|
|
- 'type' => ProductInfo::type_two,
|
|
|
- 'name' => $value['name'],
|
|
|
- 'crt_time' => $time,
|
|
|
- ];
|
|
|
- }
|
|
|
- ProductInfo::insert($insert);
|
|
|
- }
|
|
|
-
|
|
|
- ProductRange::where('del_time',0)
|
|
|
- ->where('product_id',$data['id'])
|
|
|
- ->update(['del_time' => $time]);
|
|
|
-
|
|
|
- if(! empty($data['depart'])){
|
|
|
- $insert = [];
|
|
|
- foreach ($data['depart'] as $value){
|
|
|
- $insert[] = [
|
|
|
- 'product_id' => $model->id,
|
|
|
- 'depart_id' => $value,
|
|
|
- 'type' => ProductRange::type_one,
|
|
|
- 'crt_time' => $time,
|
|
|
- ];
|
|
|
- }
|
|
|
- ProductRange::insert($insert);
|
|
|
- }
|
|
|
|
|
|
- if(! empty($data['employee'])){
|
|
|
+ if(! empty($data['product'])){
|
|
|
$insert = [];
|
|
|
- foreach ($data['employee'] as $value){
|
|
|
- $insert[] = [
|
|
|
- 'product_id' => $model->id,
|
|
|
- 'employee_id' => $value,
|
|
|
- 'type' => ProductRange::type_two,
|
|
|
- 'crt_time' => $time,
|
|
|
- ];
|
|
|
- }
|
|
|
- ProductRange::insert($insert);
|
|
|
- }
|
|
|
-
|
|
|
- ProductPriceDetail::where('del_time',0)
|
|
|
- ->where('product_id',$data['id'])
|
|
|
- ->update(['del_time' => $time]);
|
|
|
-
|
|
|
- if(! empty($data['product_price'])){
|
|
|
- $insert = [];
|
|
|
- foreach ($data['product_price'] as $value){
|
|
|
+ foreach ($data['product'] as $value){
|
|
|
$insert[] = [
|
|
|
+ 'product_activity_id' => $model->id,
|
|
|
'product_id' => $model->id,
|
|
|
'basic_type_id' => $value['basic_type_id'],
|
|
|
'price' => $value['price'],
|
|
|
'crt_time' => $time,
|
|
|
+ 'start_time' => $data['start_time'] ?? 0,
|
|
|
+ 'end_time' => $data['end_time'] ?? 0,
|
|
|
];
|
|
|
}
|
|
|
- ProductPriceDetail::insert($insert);
|
|
|
+ ProductActivityPrice::insert($insert);
|
|
|
}
|
|
|
|
|
|
DB::commit();
|
|
@@ -143,17 +63,12 @@ class ProductActivityService extends Service
|
|
|
try {
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
- $model = new Product();
|
|
|
+ $model = new ProductActivity();
|
|
|
$model->product_category_id = $data['product_category_id'] ?? 0;
|
|
|
$model->title = $data['title'];
|
|
|
- $model->code = $data['code'] ?? '';
|
|
|
- $model->size = $data['size'] ?? '';
|
|
|
- $model->unit = $data['unit'] ?? 0;
|
|
|
- $model->bar_code = $data['bar_code'] ?? '';
|
|
|
- $model->cost = $data['cost'] ?? 0;
|
|
|
- $model->retail_price = $data['retail_price'] ?? 0;
|
|
|
+ $model->start_time = $data['start_time'] ?? 0;
|
|
|
+ $model->end_time = $data['end_time'] ?? 0;
|
|
|
$model->mark = $data['mark'] ?? '';
|
|
|
- $model->state = $data['state'] ?? 0;
|
|
|
$model->crt_id = $user['id'];
|
|
|
$model->depart_id = $data['depart_id'] ?? 0;
|
|
|
$model->top_depart_id = $data['top_depart_id'] ?? 0;
|
|
@@ -161,78 +76,20 @@ class ProductActivityService extends Service
|
|
|
|
|
|
$time = time();
|
|
|
|
|
|
- if(! empty($data['introduction'])){
|
|
|
- $models = new ProductIntroduction();
|
|
|
- $models->product_id = $model->id;
|
|
|
- $models->introduction = $data['introduction'];
|
|
|
- $models->save();
|
|
|
- }
|
|
|
-
|
|
|
- if(! empty($data['img'])){
|
|
|
- $insert = [];
|
|
|
- foreach ($data['img'] as $value){
|
|
|
- $insert[] = [
|
|
|
- 'product_id' => $model->id,
|
|
|
- 'file' => $value['url'],
|
|
|
- 'type' => ProductInfo::type_one,
|
|
|
- 'name' => $value['name'],
|
|
|
- 'crt_time' => $time,
|
|
|
- ];
|
|
|
- }
|
|
|
- ProductInfo::insert($insert);
|
|
|
- }
|
|
|
-
|
|
|
- if(! empty($data['file'])){
|
|
|
+ if(! empty($data['product'])){
|
|
|
$insert = [];
|
|
|
- foreach ($data['file'] as $value){
|
|
|
- $insert[] = [
|
|
|
- 'product_id' => $model->id,
|
|
|
- 'file' => $value['url'],
|
|
|
- 'type' => ProductInfo::type_two,
|
|
|
- 'name' => $value['name'],
|
|
|
- 'crt_time' => $time,
|
|
|
- ];
|
|
|
- }
|
|
|
- ProductInfo::insert($insert);
|
|
|
- }
|
|
|
-
|
|
|
- if(! empty($data['depart'])){
|
|
|
- $insert = [];
|
|
|
- foreach ($data['depart'] as $value){
|
|
|
- $insert[] = [
|
|
|
- 'product_id' => $model->id,
|
|
|
- 'depart_id' => $value,
|
|
|
- 'type' => ProductRange::type_one,
|
|
|
- 'crt_time' => $time,
|
|
|
- ];
|
|
|
- }
|
|
|
- ProductRange::insert($insert);
|
|
|
- }
|
|
|
-
|
|
|
- if(! empty($data['employee'])){
|
|
|
- $insert = [];
|
|
|
- foreach ($data['employee'] as $value){
|
|
|
- $insert[] = [
|
|
|
- 'product_id' => $model->id,
|
|
|
- 'employee_id' => $value,
|
|
|
- 'type' => ProductRange::type_two,
|
|
|
- 'crt_time' => $time,
|
|
|
- ];
|
|
|
- }
|
|
|
- ProductRange::insert($insert);
|
|
|
- }
|
|
|
-
|
|
|
- if(! empty($data['product_price'])){
|
|
|
- $insert = [];
|
|
|
- foreach ($data['product_price'] as $value){
|
|
|
+ foreach ($data['product'] as $value){
|
|
|
$insert[] = [
|
|
|
+ 'product_activity_id' => $model->id,
|
|
|
'product_id' => $model->id,
|
|
|
'basic_type_id' => $value['basic_type_id'],
|
|
|
'price' => $value['price'],
|
|
|
'crt_time' => $time,
|
|
|
+ 'start_time' => $data['start_time'] ?? 0,
|
|
|
+ 'end_time' => $data['end_time'] ?? 0,
|
|
|
];
|
|
|
}
|
|
|
- ProductPriceDetail::insert($insert);
|
|
|
+ ProductActivityPrice::insert($insert);
|
|
|
}
|
|
|
|
|
|
DB::commit();
|
|
@@ -251,24 +108,12 @@ class ProductActivityService extends Service
|
|
|
DB::beginTransaction();
|
|
|
$time = time();
|
|
|
|
|
|
- Product::where('del_time',0)->where('id',$data['id'])->update(['del_time' => $time]);
|
|
|
+ ProductActivity::where('del_time',0)->where('id',$data['id'])->update(['del_time' => $time]);
|
|
|
|
|
|
- ProductIntroduction::where('product_id',$data['id'])
|
|
|
+ ProductActivityPrice::where('product_activity_id',$data['id'])
|
|
|
->where('del_time',0)
|
|
|
->update(['del_time' => $time]);
|
|
|
|
|
|
- ProductInfo::where('del_time',0)
|
|
|
- ->where('product_id',$data['id'])
|
|
|
- ->update(['del_time' => $time]);
|
|
|
-
|
|
|
- ProductRange::where('del_time',0)
|
|
|
- ->where('product_id',$data['id'])
|
|
|
- ->update(['del_time' => $time]);
|
|
|
-
|
|
|
- ProductPriceDetail::where('del_time',0)
|
|
|
- ->where('product_id',$data['id'])
|
|
|
- ->update(['del_time' => $time]);
|
|
|
-
|
|
|
DB::commit();
|
|
|
}catch (\Exception $exception){
|
|
|
DB::rollBack();
|
|
@@ -280,107 +125,39 @@ class ProductActivityService extends Service
|
|
|
|
|
|
public function productDetail($data,$user){
|
|
|
if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
|
|
|
- $customer = Product::where('del_time',0)
|
|
|
+ $customer = ProductActivity::where('del_time',0)
|
|
|
->where('id',$data['id'])
|
|
|
->first();
|
|
|
- if(empty($customer)) return [false,'产品不存在或已被删除'];
|
|
|
+ if(empty($customer)) return [false,'活动不存在或已被删除'];
|
|
|
$customer = $customer->toArray();
|
|
|
- $category = ProductCategory::where('id',$customer['product_category_id'])
|
|
|
- ->value('title');
|
|
|
- $customer['product_category_title'] = $category;
|
|
|
- $customer['introduction'] = "";
|
|
|
- $in = ProductIntroduction::where('del_time',0)
|
|
|
- ->where('product_id',$data['id'])
|
|
|
- ->first();
|
|
|
- if(! empty($in)) $customer['introduction'] = $in->introduction;
|
|
|
|
|
|
- $detail = ProductPriceDetail::where('del_time',0)
|
|
|
- ->where('product_id',$data['id'])
|
|
|
- ->select('product_id','basic_type_id','price')
|
|
|
+ $detail = ProductActivityPrice::where('del_time',0)
|
|
|
+ ->where('product_activity_id',$data['id'])
|
|
|
->get()->toArray();
|
|
|
$title_map = BasicType::whereIn('id',array_column($detail,'basic_type_id'))
|
|
|
->pluck('title','id')
|
|
|
->toArray();
|
|
|
- //是否总公司
|
|
|
- $is_main = $user['is_all_depart'];
|
|
|
- $top_depart = $user['depart_top'][0] ?? [];
|
|
|
- $customer['is_edit'] = $customer['top_depart_id'] == $top_depart['depart_id'] ? 1 : 0;
|
|
|
- $customer['product_price'] = [];
|
|
|
- //展示金额
|
|
|
+ $customer['product'] = [];
|
|
|
foreach ($detail as $value){
|
|
|
- if(! $is_main && ($top_depart['basic_type_id'] != $value['basic_type_id'])) {
|
|
|
- $is_show = 0;
|
|
|
- }else{
|
|
|
- $is_show = 1;
|
|
|
- }
|
|
|
- $customer['product_price'][] = [
|
|
|
+ $customer['product'][] = [
|
|
|
'basic_type_id' => $value['basic_type_id'],
|
|
|
'basic_type_title' => $title_map[$value['basic_type_id']] ?? '',
|
|
|
'price' => $value['price'],
|
|
|
- 'is_show' => $is_show,
|
|
|
];
|
|
|
}
|
|
|
|
|
|
- //单位
|
|
|
- $title = BasicType::where('id',$customer['unit'])->value('title');
|
|
|
- $customer['unit_name'] = $title;
|
|
|
-
|
|
|
- $customer['img'] = $customer['file'] = $customer['depart'] = $customer['employee'] = [];
|
|
|
- $customer_info = ProductInfo::where('del_time',0)
|
|
|
- ->where('product_id',$customer['id'])
|
|
|
- ->select('id','product_id','file','type','name')
|
|
|
- ->get()->toArray();
|
|
|
- foreach ($customer_info as $value){
|
|
|
- $tmp = [
|
|
|
- 'url' => $value['file'],
|
|
|
- 'name' => $value['name'],
|
|
|
- ];
|
|
|
- if($value['type'] == ProductInfo::type_one){
|
|
|
- $customer['img'][] = $tmp;
|
|
|
- }elseif ($value['type'] == ProductInfo::type_two){
|
|
|
- $customer['file'][] = $tmp;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $customer_range = ProductRange::where('del_time',0)
|
|
|
- ->where('product_id',$customer['id'])
|
|
|
- ->select('id','product_id','depart_id','type','employee_id')
|
|
|
- ->get()->toArray();
|
|
|
- $emp_map = Employee::whereIn('id',array_unique(array_merge_recursive([$customer['crt_id']],array_column($customer_range,'employee_id'))))
|
|
|
- ->pluck('emp_name','id')
|
|
|
- ->toArray();
|
|
|
- $depart_map = Depart::whereIn('id',array_unique(array_column($customer_range,'depart_id')))
|
|
|
- ->pluck('title','id')
|
|
|
- ->toArray();
|
|
|
- foreach ($customer_range as $value){
|
|
|
- if($value['type'] == ProductRange::type_one){
|
|
|
- $tmp = [
|
|
|
- 'id' => $value['depart_id'],
|
|
|
- 'name' => $depart_map[$value['depart_id']],
|
|
|
- ];
|
|
|
- $customer['depart'][] = $tmp;
|
|
|
- }elseif ($value['type'] == ProductRange::type_two){
|
|
|
- $tmp = [
|
|
|
- 'id' => $value['employee_id'],
|
|
|
- 'name' => $emp_map[$value['employee_id']] ?? '',
|
|
|
- ];
|
|
|
- $customer['employee'][] = $tmp;
|
|
|
- }
|
|
|
- }
|
|
|
- $customer['crt_name'] = $emp_map[$customer['crt_id']] ?? '';
|
|
|
+ $customer['crt_name'] = Employee::where('id',$customer['crt_id'])->value('emp_name');
|
|
|
$customer['crt_time'] = $customer['crt_time'] ? date("Y-m-d H:i:s",$customer['crt_time']): '';
|
|
|
|
|
|
return [true, $customer];
|
|
|
}
|
|
|
|
|
|
public function productList($data,$user){
|
|
|
- $model = new Product(['userData' => $user, 'search' => $data]);
|
|
|
+ $model = new ProductActivity(['userData' => $user, 'search' => $data]);
|
|
|
$model = $model->where('del_time',0)
|
|
|
- ->select('title','id','product_category_id','code','size','unit','bar_code','retail_price','cost','state','crt_id','crt_time','mark','depart_id','top_depart_id')
|
|
|
->orderby('id', 'desc');
|
|
|
|
|
|
if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
|
|
|
- if(isset($data['state'])) $model->where('state', $data['state']);
|
|
|
|
|
|
$list = $this->limit($model,'',$data);
|
|
|
$list = $this->fillData($list,$user);
|
|
@@ -389,20 +166,39 @@ class ProductActivityService extends Service
|
|
|
}
|
|
|
|
|
|
public function productRule(&$data, $user, $is_add = true){
|
|
|
- if(empty($data['title'])) return [false,'产品名称不能为空'];
|
|
|
- if(empty($data['product_category_id'])) return [false,'产品分类不能为空'];
|
|
|
- if(empty($data['code'])) return [false,'产品编码不能为空'];
|
|
|
- if(empty($data['cost'])) return [false,'成本不能为空'];
|
|
|
- $res = $this->checkNumber($data['cost']);
|
|
|
- if(! $res) return [false,'成本请输入不超过两位小数并且大于0的数值'];
|
|
|
- if(empty($data['retail_price'])) return [false,'零售价不能为空'];
|
|
|
- $res = $this->checkNumber($data['retail_price']);
|
|
|
- if(! $res) return [false,'零售价格请输入不超过两位小数并且大于0的数值'];
|
|
|
- if(! empty($data['product_price'])){
|
|
|
- $map = BasicType::whereIn('id',array_column($data['product_price'],'basic_type_id'))
|
|
|
+ if(empty($data['title'])) return [false,'活动名称名称不能为空'];
|
|
|
+ if(empty($data['activity_time'][0]) || empty($data['activity_time'][1])) return [false,'请填写活动时间范围'];
|
|
|
+ $data['start_time'] = $this->changeDateToDateMin($data['activity_time'][0]);
|
|
|
+ $data['end_time'] = $this->changeDateToDateMin($data['activity_time'][1]);
|
|
|
+ if($is_add){
|
|
|
+ $product = ProductActivityPrice::where('del_time',0)
|
|
|
+ ->where('start', '<=', $data['end_time'])
|
|
|
+ ->where('end', '>=', $data['start_time'])
|
|
|
+ ->select('product_id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $product = array_column($product,'product_id');
|
|
|
+ }else{
|
|
|
+ if(empty($data['id'])) return [false,'ID不能为空'];
|
|
|
+ $product = ProductActivityPrice::where('del_time',0)
|
|
|
+ ->where('id','<>',$data['id'])
|
|
|
+ ->where('start', '<=', $data['end_time'])
|
|
|
+ ->where('end', '>=', $data['start_time'])
|
|
|
+ ->select('product_id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $product = array_column($product,'product_id');
|
|
|
+ }
|
|
|
+ if(! empty($data['product'])){
|
|
|
+ $start_time = date("Y-m-d H:i",$data['start_time']);
|
|
|
+ $end_time = date("Y-m-d H:i",$data['end_time']);
|
|
|
+ $map = BasicType::whereIn('id',array_column($data['product'],'basic_type_id'))
|
|
|
+ ->pluck('title','id')
|
|
|
+ ->toArray();
|
|
|
+ $map2 = Product::whereIn('id',array_column($data['product'],'product_id'))
|
|
|
->pluck('title','id')
|
|
|
->toArray();
|
|
|
- foreach ($data['product_price'] as $value){
|
|
|
+ foreach ($data['product'] as $value){
|
|
|
+ $pro = $map2[$value['product_id']] ?? "";
|
|
|
+ if(in_array($value['product_id'], $product)) return [false,'产品:' . $pro . '在' . $start_time . '——' . $end_time . '已设置活动价格'];
|
|
|
if(! empty($value['price'])) {
|
|
|
$tmp = $map[$value['basic_type_id']] ?? '';
|
|
|
$res = $this->checkNumber($value['price']);
|
|
@@ -415,21 +211,6 @@ class ProductActivityService extends Service
|
|
|
if(empty($data['depart_id'])) $data['depart_id'] = $this->getDepart($user);
|
|
|
$data['top_depart_id'] = $user['depart_map'][$data['depart_id']] ?? 0;
|
|
|
|
|
|
- $top_depart = Depart::where('del_time',0)->where('parent_id',0)->where('is_main',1)->value('id');
|
|
|
- if($is_add){
|
|
|
- $bool = Product::whereRaw("(binary code = '{$data['code']}' OR title = '{$data['title']}') AND top_depart_id = {$data['top_depart_id']}")
|
|
|
- ->where('del_time',0)
|
|
|
- ->exists();
|
|
|
- }else{
|
|
|
- if(empty($data['id'])) return [false,'ID不能为空'];
|
|
|
- $top_depart_id = Product::where('id',$data['id'])->value('top_depart_id');
|
|
|
- $bool = Product::whereRaw("(binary code = '{$data['code']}' OR title = '{$data['title']}') AND top_depart_id = {$top_depart_id}")
|
|
|
- ->where('id','<>',$data['id'])
|
|
|
- ->where('del_time',0)
|
|
|
- ->exists();
|
|
|
- }
|
|
|
- if($bool) return [false,'产品名称或编码不能重复'];
|
|
|
-
|
|
|
return [true, $data];
|
|
|
}
|
|
|
|
|
@@ -439,54 +220,10 @@ class ProductActivityService extends Service
|
|
|
$emp = Employee::whereIn('id',array_unique(array_column($data['data'],'crt_id')))
|
|
|
->pluck('emp_name','id')
|
|
|
->toArray();
|
|
|
- $category = ProductCategory::whereIn('id',array_unique(array_column($data['data'],'product_category_id')))
|
|
|
- ->pluck('title','id')
|
|
|
- ->toArray();
|
|
|
- $detail = ProductPriceDetail::where('del_time',0)
|
|
|
- ->whereIn('product_id',array_unique(array_column($data['data'],'id')))
|
|
|
- ->select('product_id','basic_type_id','price')
|
|
|
- ->get()->toArray();
|
|
|
- $basic_map = BasicType::whereIn('id',array_unique(array_merge_recursive(array_column($data['data'],'unit'),array_column($detail,'basic_type_id'))))
|
|
|
- ->pluck('title','id')
|
|
|
- ->toArray();
|
|
|
- $detail_map = [];
|
|
|
- foreach ($detail as $value){
|
|
|
- $detail_map[$value['product_id']][] = $value;
|
|
|
- }
|
|
|
|
|
|
- //是否总公司
|
|
|
- $is_main = $user['is_all_depart'];
|
|
|
- $top_depart = $user['depart_top'][0] ?? [];
|
|
|
foreach ($data['data'] as $key => $value){
|
|
|
- $tmp = [];
|
|
|
- if(isset($detail_map[$value['id']])){
|
|
|
- $d = $detail_map[$value['id']];
|
|
|
- foreach ($d as $v){
|
|
|
- if(! $is_main && ($top_depart['basic_type_id'] != $v['basic_type_id'])) {
|
|
|
- $is_show = 0;
|
|
|
- }else{
|
|
|
- $is_show = 1;
|
|
|
- }
|
|
|
- if($top_depart['basic_type_id'] != $v['basic_type_id']) {
|
|
|
- $is_use = 0;
|
|
|
- }else{
|
|
|
- $is_use = 1;
|
|
|
- }
|
|
|
- $tmp[] = [
|
|
|
- 'basic_type_id' => $v['basic_type_id'],
|
|
|
- 'basic_type_title' => $basic_map[$v['basic_type_id']] ?? '',
|
|
|
- 'price' => $v['price'],
|
|
|
- 'is_show' => $is_show,
|
|
|
- 'is_use' => $is_use
|
|
|
- ];
|
|
|
- }
|
|
|
- }
|
|
|
- $data['data'][$key]['product_price'] = $tmp;
|
|
|
$data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
|
|
|
$data['data'][$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
|
|
|
- $data['data'][$key]['product_category_name'] = $category[$value['product_category_id']] ?? '';
|
|
|
- $data['data'][$key]['state_name'] = Product::$state[$value['state']] ?? '';
|
|
|
- $data['data'][$key]['unit_name'] = $basic_map[$value['unit']] ?? '';
|
|
|
}
|
|
|
|
|
|
return $data;
|