feat: 更新了采购产品、用户提现、库存管理等功能的代码,优化了查询逻辑,并改进了异常处理。

This commit is contained in:
mkm 2024-08-14 22:05:33 +08:00
parent 948b3e5794
commit 07bdc6f142
5 changed files with 27 additions and 6 deletions

View File

@ -28,7 +28,7 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc
public function setSearch(): array
{
return [
'=' => ['supplier_id', 'order_id', 'product_id', 'price', 'nums', 'unit', 'is_buyer', 'buyer_confirm', 'is_storage', 'is_stream', 'need_num', 'notes', 'buyer_id', 'status', 'stream_admin_id', 'stream_time', 'storage_admin_id'],
'=' => [],
];
}
@ -45,7 +45,7 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc
public function lists(): array
{
return PurchaseProductOffer::where($this->searchWhere)
->field(['id', 'supplier_id', 'order_id', 'product_id', 'price', 'nums', 'unit', 'is_buyer', 'buyer_confirm', 'is_storage', 'is_stream', 'need_num', 'notes', 'buyer_id', 'status', 'stream_admin_id', 'stream_time', 'storage_admin_id'])
->field(['id', 'supplier_id', 'order_id', 'product_id', 'price', 'buyer_nums', 'unit', 'is_buyer', 'buyer_confirm', 'is_storage', 'is_stream', 'need_num', 'notes', 'buyer_id', 'status', 'stream_admin_id', 'stream_time', 'storage_admin_id'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($item){
@ -59,7 +59,7 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc
$item->is_buyer_name='无须采购';
}
if($item->buyer_id>0){
$item->buyer_name=DeliveryService::where('id',$item->buyer_id)->value('nickname');
$item->buyer_name=DeliveryService::where('uid',$item->buyer_id)->value('nickname');
if($item->buyer_confirm==0){
$item->buyer_confirm_name='采购中';
}else{

View File

@ -5,6 +5,7 @@ namespace app\api\controller\purchase_product_offer;
use app\api\lists\purchase_product_offer\PurchaseProductOfferLists;
use app\api\controller\BaseApiController;
use app\common\model\purchase_product_offer\PurchaseProductOffer;
@ -27,4 +28,21 @@ class PurchaseProductOfferController extends BaseApiController
{
return $this->dataLists(new PurchaseProductOfferLists());
}
public function offer_update(){
$params=$this->request->post();
$data=[
'buyer_nums'=>$params['nums'],
'price'=>$params['price'],
'total_price'=>$params['total_price'],
'buyer_confirm'=>1,
];
$res=PurchaseProductOffer::where('id',$params['id'])->where('buyer_id',$this->userId)->update($data);
if($res){
return $this->success('提交成功');
}else{
return $this->fail('提交失败');
}
}
}

View File

@ -324,8 +324,9 @@ class UserController extends BaseApiController
$capitalFlowDao = new CapitalFlowLogic($find);
$capitalFlowDao->userExpense('user_withdrawal', 'withdrawal', $res['id'], $money);
User::where('id', $this->userId)->dec('now_money', $money)->update();
Db::commit();
return $this->success('申请成功,等待审核');
} catch (\Exception $e) {
} catch (\Throwable $e) {
Db::rollback();
return $this->success('申请失败');
}

View File

@ -28,7 +28,7 @@ class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchI
public function setSearch(): array
{
return [
'=' => ['supplier_id', 'order_id', 'product_id', 'price', 'nums', 'unit', 'is_buyer', 'buyer_confirm', 'is_storage', 'is_stream', 'need_num', 'notes', 'buyer_id', 'status', 'stream_admin_id', 'stream_time', 'storage_admin_id'],
'=' => [],
];
}
@ -45,13 +45,14 @@ class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchI
public function lists(): array
{
return PurchaseProductOffer::where($this->searchWhere)
->field(['id', 'supplier_id', 'order_id', 'product_id', 'price', 'nums', 'unit', 'is_buyer', 'buyer_confirm', 'is_storage', 'is_stream', 'need_num', 'notes', 'buyer_id', 'status', 'stream_admin_id', 'stream_time', 'storage_admin_id'])
->field(['id', 'order_id', 'product_id', 'price', 'buyer_nums', 'unit', 'is_buyer', 'buyer_confirm','need_num', 'buyer_id', 'status', ])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($item){
$find=StoreProduct::where('id',$item->product_id)->find();
$item->store_name=$find->store_name;
$item->image=$find->image;
$item->store_info=$find->store_info;
$item->unit_name=StoreProductUnit::where('id',$item->unit)->value('name');
if($item->is_buyer==1){
$item->is_buyer_name='需要采购';

View File

@ -131,6 +131,7 @@ class UserLogic extends BaseLogic
$data['share_name']= $share_name.'No.'.preg_replace('/4/','*', $data['id']);
$data['system_store_id']=SystemStoreStaff::where('uid',$uid)->value('store_id');
$data['delivery_service_id']=DeliveryService::where('uid',$uid)->value('id');
}else{
$data = [];
}