添加开发者发货功能

This commit is contained in:
Dev
2026-09-30 14:56:56 +08:00
parent f13a5e682a
commit bc17810445
14 changed files with 768 additions and 4 deletions
+27 -1
View File
@@ -7,6 +7,7 @@ use app\common\service\CommonService;
use app\common\service\ContractService;
use app\common\service\DemandBiddingService;
use app\common\service\DemandService;
use app\common\service\OrderShipService;
use think\exception\HttpResponseException;
use think\Lang;
use think\Validate;
@@ -128,6 +129,13 @@ class Demand extends Api
}
} elseif ($item->status == 3 && $item->isMyWin && $item->winBidding->bidding_status == 2 && $item->winBidding->process_status == 2) {
$button = ['name' => '工作完成', 'theme' => 'danger'];
} elseif ($item->status == 5 && $item->isMyWin && $item->winBidding->bidding_status == 2 && $item->winBidding->process_status == 2) {
//客户支付尾款后,开发者发货交付
if ($item->hasDelivery) {
$button = ['name' => '已发货', 'theme' => 'light'];
} else {
$button = ['name' => '去发货', 'theme' => 'danger'];
}
} elseif ($item->is_bid) {
$button = ['name' => '已投标', 'theme' => 'light'];
} elseif ($item->status == 1) {
@@ -147,6 +155,13 @@ class Demand extends Api
$button = ['name' => '工作完成', 'theme' => 'danger'];
} elseif ($item->status == 4 && $item->accept_status == 1) {
$button = ['name' => '待验收', 'theme' => 'light'];
} elseif ($item->status == 5 && $item->isMyWin && $item->winBidding->bidding_status == 2 && $item->winBidding->process_status == 2) {
//客户支付尾款后,开发者发货交付
if ($item->hasDelivery) {
$button = ['name' => '已发货', 'theme' => 'light'];
} else {
$button = ['name' => '去发货', 'theme' => 'danger'];
}
} elseif ($item->status == 5 && $item->accept_status == 2) {
$button = ['name' => '待收货', 'theme' => 'light'];
}
@@ -166,12 +181,15 @@ class Demand extends Api
return $button;
};
$list = DemandService::getList($where, $page_size, 'id desc', '', ['user', 'demandContracts', 'demandBiddings', 'winBidding']);
$list = $list->each(function ($item, $key) use ($user_id, $opType, $btnNameFun) {
//已发货的需求集合(发货表),用于开发者视角的发货按钮展示
$deliveredDemandIds = OrderShipService::where(['demand_id' => ['in', $list->column('id')]])->column('demand_id');
$list = $list->each(function ($item, $key) use ($user_id, $opType, $btnNameFun, $deliveredDemandIds) {
$demand_bidding = $item->demand_biddings;
$bidUserIds = array_column($demand_bidding, 'user_id');
$item->demand_biddings_count = count($demand_bidding);
$item->is_bid = in_array($user_id, $bidUserIds);
$item->isMyWin = $item->winBidding && $item->winBidding->user_id == $user_id;
$item->hasDelivery = in_array($item->id, $deliveredDemandIds);
$item->button = $btnNameFun($opType, $item);
});
$this->success('', $list);
@@ -229,6 +247,14 @@ class Demand extends Api
'url' => $fl,
'name' => urldecode(basename($fl))
], $info->files);
//交付内容(订单发货表,开发者发货后展示)
$ship = OrderShipService::where(['demand_id' => $id])->order('id', 'desc')->find();
$info->delivery = $ship ? [
'images' => json_decode($ship->images, true) ?: [],
'files' => json_decode($ship->files, true) ?: [],
'remark' => $ship->remark,
'delivery_time' => $ship->createtime,
] : null;
$this->success('', $info);
} catch (\Exception $e) {