feat(purchase): 优化采购商品信息展示和存储

- 修改采购商品控制器和逻辑类的注释
- 调整采购商品列表的字段选择
- 增加商品信息更新功能
- 完善采购商品添加和编辑时的商品信息保存
This commit is contained in:
mkm 2024-11-01 21:11:34 +08:00
parent 962a3df197
commit 710c999cef
5 changed files with 37 additions and 19 deletions

View File

@ -10,7 +10,7 @@ use app\admin\validate\purchase_product_offer\PurchaseProductOfferValidate;
/**
* 采购供应链商品控制器
* 采购商品控制器
* Class PurchaseProductOfferController
* @package app\admin\controller\purchase_product_offer
*/
@ -19,7 +19,7 @@ class PurchaseProductOfferController extends BaseAdminController
/**
* @notes 获取采购供应链商品列表
* @notes 获取采购商品列表
* @return \think\response\Json
* @author admin
* @date 2024/08/14 15:06
@ -31,7 +31,7 @@ class PurchaseProductOfferController extends BaseAdminController
/**
* @notes 添加采购供应链商品
* @notes 添加采购商品
* @return \think\response\Json
* @author admin
* @date 2024/08/14 15:06
@ -46,7 +46,7 @@ class PurchaseProductOfferController extends BaseAdminController
/**
* @notes 编辑采购供应链商品
* @notes 编辑采购商品
* @return \think\response\Json
* @author admin
* @date 2024/08/14 15:06
@ -93,7 +93,7 @@ class PurchaseProductOfferController extends BaseAdminController
return $this->success('设置成功', [], 1, 1);
}
/**
* @notes 删除采购供应链商品
* @notes 删除采购商品
* @return \think\response\Json
* @author admin
* @date 2024/08/14 15:06
@ -107,7 +107,7 @@ class PurchaseProductOfferController extends BaseAdminController
/**
* @notes 获取采购供应链商品详情
* @notes 获取采购商品详情
* @return \think\response\Json
* @author admin
* @date 2024/08/14 15:06

View File

@ -59,7 +59,6 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc
}
$job_ids=$this->adminInfo['job_ids']??[];
return PurchaseProductOffer::where($this->searchWhere)
->field(['id', 'supplier_id', 'order_id', 'product_id', 'price','total_price', 'buyer_nums', 'unit', 'is_buyer', 'buyer_confirm', 'is_storage', 'is_stream', 'need_num', 'mark', 'buyer_id', 'status', 'stream_admin_id', 'stream_time', 'storage_admin_id'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($item) use($job_ids){

View File

@ -32,7 +32,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
public function setSearch(): array
{
return [
'=' => ['cate_id', 'is_show', 'bar_code','product_type'],
'=' => ['cate_id', 'is_show', 'bar_code','product_type','id'],
'<=' => ['stock'],
'%like%' => ['store_name'],
];

View File

@ -7,6 +7,7 @@ use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
use app\common\logic\BaseLogic;
use app\common\model\beforehand_order\BeforehandOrder;
use app\common\model\purchase_product_offer\PurchaseProductOffer;
use app\common\model\store_product\StoreProduct;
use app\common\model\warehouse_order\WarehouseOrder;
use app\common\model\warehouse_product\WarehouseProduct;
use support\exception\BusinessException;
@ -186,6 +187,22 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
$data['purchase'] = $v['price'];
$data['total_price'] = $v['total_price'];
$data['financial_pm'] = 1;
$product_arr=[];
if($v['package']!=''){
$product_arr['package']=$v['package'];
}
if($v['store_info']!=''){
$product_arr['store_info']=$v['store_info'];
}
if($v['marques']!=''){
$product_arr['marques']=$v['marques'];
}
if($v['after_sales']!=''){
$product_arr['after_sales']=$v['after_sales'];
}
if($product_arr!=[]){
StoreProduct::where('id',$v['product_id'])->save($product_arr);
}
WarehouseProductLogic::add($data);
PurchaseProductOffer::where('id', $v['id'])->update(['status' => 1, 'is_storage' => 1]);
}

View File

@ -15,7 +15,7 @@ use think\facade\Db;
/**
* 采购供应链商品逻辑
* 采购商品逻辑
* Class PurchaseProductOfferLogic
* @package app\admin\logic\purchase_product_offer
*/
@ -24,7 +24,7 @@ class PurchaseProductOfferLogic extends BaseLogic
/**
* @notes 添加采购供应链商品
* @notes 添加采购商品
* @param array $params
* @return bool
* @author admin
@ -38,6 +38,7 @@ class PurchaseProductOfferLogic extends BaseLogic
if ($mark == '') {
$mark = BeforehandOrderCartInfo::where('bhoid', $params['order_id'])->where('product_id', $params['product_id'])->value('mark');
}
$find=StoreProduct::where('id',$params['product_id'])->find();
PurchaseProductOffer::create([
'order_id' => $params['order_id'],
'product_id' => $params['product_id'],
@ -46,6 +47,10 @@ class PurchaseProductOfferLogic extends BaseLogic
'need_num' => $params['need_num'],
'mark' => $mark,
'buyer_id' => $params['buyer_id'],
'package' => $find['package'],
'store_info' => $find['store_info'],
'marques' => $find['marques'],
'after_sales' => $find['after_sales'],
'status' => 0,
]);
@ -60,7 +65,7 @@ class PurchaseProductOfferLogic extends BaseLogic
/**
* @notes 编辑采购供应链商品
* @notes 编辑采购商品
* @param array $params
* @return bool
* @author admin
@ -117,6 +122,10 @@ class PurchaseProductOfferLogic extends BaseLogic
'total_price' => $params['total_price'],
'pay_type' => $params['pay_type'] ?? 0,
'buyer_confirm' => 1,
'package' => $params['package'],
'store_info' => $params['store_info'],
'marques' => $params['marques'],
'after_sales' => $params['after_sales'],
]);
$find = StoreProductPrice::where(['offer_id' => $params['id']])->find();
$top_cate_id = StoreProduct::where('id', $offer['product_id'])->value('top_cate_id');
@ -149,13 +158,6 @@ class PurchaseProductOfferLogic extends BaseLogic
} else {
StoreProductPrice::create($data);
}
// $find=BeforehandOrderCartInfo::where(['bhoid'=>$params['bhoid'],'product_id'=>$offer['product_id']])->find();
// if($find){
// $find->purchase=$params['purchase'];
// $find->total_price=bcmul($find['cart_num'],$params['price'],2);
// $find->price=$params['price'];
// $find->save();
// }
Db::commit();
return true;
} catch (\Throwable $e) {
@ -245,7 +247,7 @@ class PurchaseProductOfferLogic extends BaseLogic
}
}
/**
* @notes 删除采购供应链商品
* @notes 删除采购商品
* @param array $params
* @return bool
* @author admin