调整采购单生成
This commit is contained in:
parent
c0cdd0974b
commit
65ce4808c9
@ -49,6 +49,14 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$procurementOrderId = PurchaseProductOffer::where('source_order_id', $this->params['order_id'])->value('source_order_id');
|
||||
if ($procurementOrderId) {
|
||||
foreach ($this->searchWhere as $k => &$v) {
|
||||
if ($v[0] == 'order_id') {
|
||||
$v[2] = $procurementOrderId;
|
||||
}
|
||||
}
|
||||
}
|
||||
$store_name=$this->request->get('store_name');
|
||||
if($store_name){
|
||||
$ids=StoreProduct::where('store_name','like','%'.$store_name.'%')->column('id');
|
||||
@ -125,6 +133,14 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc
|
||||
if($this->is_ids==1){
|
||||
return 0;
|
||||
}
|
||||
$procurementOrderId = PurchaseProductOffer::where('source_order_id', $this->params['order_id'])->value('source_order_id');
|
||||
if ($procurementOrderId) {
|
||||
foreach ($this->searchWhere as $k => &$v) {
|
||||
if ($v[0] == 'order_id') {
|
||||
$v[2] = $procurementOrderId;
|
||||
}
|
||||
}
|
||||
}
|
||||
return PurchaseProductOffer::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
|
@ -56,21 +56,44 @@ class PurchaseProductOfferLogic extends BaseLogic
|
||||
$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' => $procurementOrder['id'],
|
||||
'product_id' => $params['product_id'],
|
||||
'unit' => $params['unit'],
|
||||
'is_buyer' => $params['is_buyer'],
|
||||
'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,
|
||||
|
||||
]);
|
||||
$purchaseProductOffer = PurchaseProductOffer::where(['order_id' => $procurementOrder['id'], 'product_id' => $params['product_id']])->find();
|
||||
if ($purchaseProductOffer) {
|
||||
$purchaseProductOffer->need_num = $purchaseProductOffer['need_num'] + $params['need_num'];
|
||||
if (!empty($purchaseProductOffer['source_order_info'])) {
|
||||
$sourceOrderInfo = $purchaseProductOffer['source_order_info'];
|
||||
$sourceOrderInfo[] = [
|
||||
'source_order_id' => $params['order_id'],
|
||||
'product_id' => $params['product_id'],
|
||||
'need_num' => $params['need_num'],
|
||||
'mark' => $mark,
|
||||
];
|
||||
$purchaseProductOffer->source_order_info = $sourceOrderInfo;
|
||||
}
|
||||
$purchaseProductOffer->save();
|
||||
} else {
|
||||
PurchaseProductOffer::create([
|
||||
'order_id' => $procurementOrder['id'],
|
||||
'product_id' => $params['product_id'],
|
||||
'unit' => $params['unit'],
|
||||
'is_buyer' => $params['is_buyer'],
|
||||
'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,
|
||||
'source_order_info' => [
|
||||
[
|
||||
'source_order_id' => $params['order_id'],
|
||||
'product_id' => $params['product_id'],
|
||||
'need_num' => $params['need_num'],
|
||||
'mark' => $mark,
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
BeforehandOrderCartInfo::where(['bhoid' => $params['order_id'], 'product_id' => $params['product_id']])->update(['is_buyer' => 1]);
|
||||
Db::commit();
|
||||
return true;
|
||||
|
@ -18,5 +18,7 @@ class PurchaseProductOffer extends BaseModel
|
||||
protected $name = 'purchase_product_offer';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
protected $json = ['source_order_info'];
|
||||
protected $jsonAssoc = true;
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user