fix(admin): 优化预订单购物车详情状态更新逻辑

- 在更改预订单购物车详情状态时,增加采购状态检查
- 如果商品已采购完成,禁止更改状态并返回提示信息
- 在列表中添加顶级分类名称显示
This commit is contained in:
mkm 2024-10-18 15:06:49 +08:00
parent 2506a02601
commit 25eaaab509
2 changed files with 14 additions and 1 deletions

View File

@ -7,6 +7,7 @@ use app\admin\controller\BaseAdminController;
use app\admin\lists\beforehand_order_cart_info\BeforehandOrderCartInfoLists;
use app\admin\logic\beforehand_order_cart_info\BeforehandOrderCartInfoLogic;
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
use app\common\model\purchase_product_offer\PurchaseProductOffer;
/**
* 预订单购物详情表控制器
@ -61,7 +62,17 @@ class BeforehandOrderCartInfoController extends BaseAdminController
*/
public function procurement_status(){
$id=$this->request->post('id');
$res=BeforehandOrderCartInfo::where('id',$id)->update(['is_buyer'=>-1]);
$res=BeforehandOrderCartInfo::where('id',$id)->find();
$find=PurchaseProductOffer::where(['product_id'=>$res['product_id'],'order_id'=>$res['bhoid']])->find();
if($find){
if($find['buyer_confirm']==1){
return $this->fail('该商品已采购完成,无法更改状态');
}else{
PurchaseProductOffer::where('id',$find['id'])->update(['delete_time'=>time()]);
}
}
$res->save(['is_buyer'=>-1]);
if($res){
return $this->success('操作成功',[],1,1);
}else{

View File

@ -11,6 +11,7 @@ use app\common\model\store_product\StoreProduct;
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
use app\common\lists\ListsExcelInterface;
use app\common\model\beforehand_order\BeforehandOrder;
use app\common\model\store_category\StoreCategory;
use app\common\model\store_product_unit\StoreProductUnit;
use app\common\model\system_store\SystemStore;
@ -68,6 +69,7 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe
$item['image'] = $find['image'];
$item['unit'] = $find['unit'];
$item['top_cate_id'] = $find['top_cate_id'];
$item['top_cate_name']=StoreCategory::where('id',$item['top_cate_id'])->value('name');
if ($item->bhoid) {
$status = PurchaseProductOffer::where('order_id', $item->bhoid)->where('product_id', $item->product_id)->value('status');
if ($status == 1) {