Compare commits

...

1 Commits
main ... batch

Author SHA1 Message Date
fcbdf65ba8 添加商品批次 2024-12-27 11:04:51 +08:00
3 changed files with 9 additions and 2 deletions

View File

@ -42,6 +42,8 @@ class PurchaseProductOfferController extends BaseApiController
return $this->fail('请选择供应商');
}
$params['admin_id']=0;
$params['manufacture'] = !empty($params['manufacture']) ? date('Y-m-d H:i:s', $params['manufacture']) : '';
$params['expiration_date'] = !empty($params['expiration_date']) ? date('Y-m-d H:i:s', $params['expiration_date']) : '';
PurchaseProductOfferLogic::setProcureInfo($params);
return $this->success('设置成功', [], 1, 1);
}

View File

@ -53,10 +53,14 @@ class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchI
$cateIds = [];
$list = PurchaseProductOffer::where($this->searchWhere)
->with('product')
->field(['id', 'order_id', 'product_id', 'price', 'total_price', 'buyer_nums', 'unit', 'is_buyer', 'buyer_confirm','need_num', 'buyer_id', 'status', 'mark','update_time', 'supplier_id', 'package', 'store_info', 'marques', 'after_sales', 'pay_type'])
->field(['id', 'order_id', 'product_id', 'price', 'total_price', 'buyer_nums', 'unit', 'is_buyer', 'buyer_confirm','need_num', 'buyer_id', 'status', 'mark','update_time', 'supplier_id', 'package', 'store_info', 'marques', 'after_sales', 'pay_type', 'expiration_date', 'manufacture'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($item) use(&$cateIds, &$supplierIds, &$unitIds) {
$item->store_info = empty($item['store_info']) ? ($item['product']['store_info'] ?? '') : $item['store_info'];
$item->after_sales = empty($item['after_sales']) ? ($item['product']['after_sales'] ?? '') : $item['after_sales'];
$item->marques = empty($item['marques']) ? ($item['product']['marques'] ?? '') : $item['marques'];
$item->package = empty($item['package']) ? ($item['product']['package'] ?? '') : $item['package'];
$item->store_name=$item->product->store_name ?? '';
$item->image=$item->product->image ?? '';
$cateIds[] = $item->product->top_cate_id ?? 0;
@ -82,6 +86,7 @@ class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchI
$categories = StoreCategory::field('id,name')->whereIn('id', array_unique($cateIds))->select()->toArray();
$categories = reset_index($categories, 'id');
foreach ($list as &$item) {
$item['made_place'] = $item['product']['made_place'] ?? '';
$item['supplier_name'] = $suppliers[$item['supplier_id']]['mer_name'] ?? '';
$item['unit_name'] = $units[$item['unit']]['name'] ?? '';
$item['category_name'] = !empty($item['product']['top_cate_id']) && !empty($categories[$item['product']['top_cate_id']]) ? $categories[$item['product']['top_cate_id']]['name'] : '';

View File

@ -24,7 +24,7 @@ class PurchaseProductOffer extends BaseModel
public function product()
{
return $this->hasOne(StoreProduct::class, 'id', 'product_id')->field('id,store_name,top_cate_id,image');
return $this->hasOne(StoreProduct::class, 'id', 'product_id')->field('id,store_name,top_cate_id,image,store_info,package,marques,after_sales,made_place');
}
}