修改小程序端提交采购信息
This commit is contained in:
parent
e063fcfe7f
commit
e722c1a773
@ -3,6 +3,8 @@
|
|||||||
namespace app\api\controller\purchase_product_offer;
|
namespace app\api\controller\purchase_product_offer;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\supplier\SupplierLists;
|
||||||
|
use app\admin\logic\purchase_product_offer\PurchaseProductOfferLogic;
|
||||||
use app\api\lists\purchase_product_offer\PurchaseProductOfferLists;
|
use app\api\lists\purchase_product_offer\PurchaseProductOfferLists;
|
||||||
use app\api\controller\BaseApiController;
|
use app\api\controller\BaseApiController;
|
||||||
use app\common\model\dict\DictData;
|
use app\common\model\dict\DictData;
|
||||||
@ -34,21 +36,14 @@ class PurchaseProductOfferController extends BaseApiController
|
|||||||
* 提交采购信息
|
* 提交采购信息
|
||||||
*/
|
*/
|
||||||
public function offer_update(){
|
public function offer_update(){
|
||||||
$params=$this->request->post();
|
|
||||||
$data=[
|
$params = $this->request->post();
|
||||||
'buyer_nums'=>$params['nums'],
|
if($params['supplier_id']=='' ||$params['supplier_id']<=0){
|
||||||
'price'=>$params['price'],
|
return $this->fail('请选择供应商');
|
||||||
'outbound_price'=>$params['outbound_price'],
|
|
||||||
'total_price'=>$params['total_price'],
|
|
||||||
'buyer_confirm'=>1,
|
|
||||||
'pay_type'=>$params['pay_type']??0,
|
|
||||||
];
|
|
||||||
$res=PurchaseProductOffer::where('id',$params['id'])->where('buyer_id',$this->userId)->update($data);
|
|
||||||
if($res){
|
|
||||||
return $this->success('提交成功');
|
|
||||||
}else{
|
|
||||||
return $this->fail('提交失败');
|
|
||||||
}
|
}
|
||||||
|
$params['admin_id']=0;
|
||||||
|
PurchaseProductOfferLogic::setProcureInfo($params);
|
||||||
|
return $this->success('设置成功', [], 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,4 +59,9 @@ class PurchaseProductOfferController extends BaseApiController
|
|||||||
return $this->success('ok',$data);
|
return $this->success('ok',$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function supplier()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new SupplierLists());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -10,6 +10,7 @@ use app\common\model\store_product\StoreProduct;
|
|||||||
use app\common\model\store_product_unit\StoreProductUnit;
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
use app\api\lists\BaseApiDataLists;
|
use app\api\lists\BaseApiDataLists;
|
||||||
use app\common\model\store_category\StoreCategory;
|
use app\common\model\store_category\StoreCategory;
|
||||||
|
use app\common\model\supplier\Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 采购供应链商品列表
|
* 采购供应链商品列表
|
||||||
@ -49,17 +50,16 @@ class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchI
|
|||||||
}else{
|
}else{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return PurchaseProductOffer::where($this->searchWhere)
|
$cateIds = [];
|
||||||
->field(['id', 'order_id', 'product_id', 'price', 'buyer_nums', 'unit', 'is_buyer', 'buyer_confirm','need_num', 'buyer_id', 'status', 'mark','update_time'])
|
$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'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['product_id'=>'desc','id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function($item){
|
->select()->each(function($item) use(&$cateIds, &$supplierIds, &$unitIds) {
|
||||||
$find=StoreProduct::where('id',$item->product_id)->find();
|
$item->store_name=$item->product->store_name ?? '';
|
||||||
$item->store_name=$find->store_name;
|
$item->image=$item->product->image ?? '';
|
||||||
$item->image=$find->image;
|
$cateIds[] = $item->product->top_cate_id ?? 0;
|
||||||
$item->store_info=$find->store_info;
|
|
||||||
$item->unit_name=StoreProductUnit::where('id',$item->unit)->value('name');
|
|
||||||
$item->category_name=StoreCategory::where('id',$find->top_cate_id)->value('name');
|
|
||||||
if($item->is_buyer==1){
|
if($item->is_buyer==1){
|
||||||
$item->is_buyer_name='需要采购';
|
$item->is_buyer_name='需要采购';
|
||||||
}elseif($item->is_buyer==-1){
|
}elseif($item->is_buyer==-1){
|
||||||
@ -73,9 +73,20 @@ class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchI
|
|||||||
$item->buyer_confirm_name='采购完成';
|
$item->buyer_confirm_name='采购完成';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
|
$suppliers = Supplier::field('id,mer_name')->whereIn('id', array_unique(array_column($list,'supplier_id')))->select()->toArray();
|
||||||
|
$suppliers = reset_index($suppliers, 'id');
|
||||||
|
$units = StoreProductUnit::field('id,name')->whereIn('id', array_unique(array_column($list,'unit')))->select()->toArray();
|
||||||
|
$units = reset_index($units, 'id');
|
||||||
|
$categories = StoreCategory::field('id,name')->whereIn('id', array_unique($cateIds))->select()->toArray();
|
||||||
|
$categories = reset_index($categories, 'id');
|
||||||
|
foreach ($list as &$item) {
|
||||||
|
$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'] : '';
|
||||||
|
}
|
||||||
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ namespace app\common\model\purchase_product_offer;
|
|||||||
|
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
use think\model\concern\SoftDelete;
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
@ -21,4 +22,9 @@ class PurchaseProductOffer extends BaseModel
|
|||||||
protected $json = ['source_order_info'];
|
protected $json = ['source_order_info'];
|
||||||
protected $jsonAssoc = true;
|
protected $jsonAssoc = true;
|
||||||
|
|
||||||
|
public function product()
|
||||||
|
{
|
||||||
|
return $this->hasOne(StoreProduct::class, 'id', 'product_id')->field('id,store_name,top_cate_id,image');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user