Merge pull request 'dev' (#266) from dev into main

Reviewed-on: #266
This commit is contained in:
mkm 2024-10-14 20:35:45 +08:00
commit 7212969d3a
4 changed files with 55 additions and 6 deletions

View File

@ -75,10 +75,14 @@ class PurchaseProductOfferController extends BaseAdminController
{
$params = $this->request->post();
PurchaseProductOfferLogic::setProcureInfo($params);
return $this->success('设置成功', [], 1, 1);
}
public function setBatchProcureInfo()
{
$params = $this->request->post();
PurchaseProductOfferLogic::setBatchProcureInfo($params);
return $this->success('设置成功', [], 1, 1);
}
/**
* @notes 删除采购供应链商品

View File

@ -27,7 +27,7 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte
public function setSearch(): array
{
return [
'=' => ['store_id', 'order_id', 'uid','paid','status',],
'=' => ['store_id', 'order_id', 'uid','paid','status','order_type'],
];
}

View File

@ -21,6 +21,7 @@ use app\common\model\supplier\Supplier;
class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
{
public $is_ids;
/**
* @notes 设置搜索条件
@ -31,7 +32,7 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc
public function setSearch(): array
{
return [
'=' => ['order_id'],
'=' => ['order_id','buyer_confirm'],
];
}
@ -47,6 +48,15 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc
*/
public function lists(): array
{
$store_name=$this->request->get('store_name');
if($store_name){
$ids=StoreProduct::where('store_name','like','%'.$store_name.'%')->column('id');
if($ids){
$this->searchWhere[]=['product_id','in',$ids];
}else{
$this->is_ids=1;
}
}
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)
@ -84,6 +94,7 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc
}else{
$item->is_storage_name='未入库';
}
$item->pay_type_name=$item->pay_type==1?'赊账':'现金';
})
->toArray();
@ -98,6 +109,9 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc
*/
public function count(): int
{
if($this->is_ids==1){
return 0;
}
return PurchaseProductOffer::where($this->searchWhere)->count();
}

View File

@ -105,7 +105,7 @@ class PurchaseProductOfferLogic extends BaseLogic
'buyer_nums' => $params['buyer_nums'],
'supplier_id' => $params['supplier_id'],
'price' => $params['purchase'],
'outbound_price' => $params['outbound_price'],
'outbound_price' => $params['outbound_price']??0,
'total_price' => $params['total_price'],
'pay_type' => $params['pay_type']??0,
'buyer_confirm' => 1,
@ -124,7 +124,38 @@ class PurchaseProductOfferLogic extends BaseLogic
throw new BusinessException($e->getMessage());
}
}
/**
* @notes 设置批量采购信息
* @param array $params
* @return bool
* @author admin
* @date 2024/08/14 15:06
*/
public static function setBatchProcureInfo(array $params): bool
{
Db::startTrans();
try {
$data=[];
foreach($params['product_arr'] as $k=>$v){
$data[]=[
'id'=>$v['id'],
'total_price'=>$v['total_price'],
'price'=>$v['purchase'],
'buyer_nums'=>$v['buyer_nums'],
'supplier_id'=>$params['supplier_id'],
'outbound_price'=>0,
'pay_type'=>$v['pay_type']??0,
'buyer_confirm'=>1,
];
}
(new PurchaseProductOffer())->saveAll($data);
Db::commit();
return true;
} catch (\Throwable $e) {
Db::rollback();
throw new BusinessException($e->getMessage());
}
}
/**
* 是否需采购
*/