需求按钮状态优化
This commit is contained in:
@@ -120,6 +120,9 @@ class Demand extends Api
|
||||
$button = ['name' => '查看详情', 'theme' => 'light'];
|
||||
// key 为按钮动作标识(复用 DemandService::BUTTON_* 常量),
|
||||
// 前端据此判断按钮类型,避免依赖中文文案;无动作的展示型按钮 key 为空
|
||||
if ((int)$item->status === DemandService::STATUS_FINISHED) {
|
||||
return ['key' => DemandService::BUTTON_FINISHED, 'name' => '交易完成', 'theme' => 'light'];
|
||||
}
|
||||
if ($opType == 'all') {
|
||||
if ($item->status == 1 && $item->isMyWin && $item->winBidding->bidding_status == 2 && $item->winBidding->process_status == 1) {
|
||||
$button = ['key' => DemandService::BUTTON_CONFIRM, 'name' => '确认接单', 'theme' => 'danger'];
|
||||
@@ -196,9 +199,12 @@ class Demand extends Api
|
||||
$bidUserIds = array_column($demand_bidding, 'user_id');
|
||||
$item->demand_biddings_count = count($demand_bidding);
|
||||
$item->is_bid = in_array($user_id, $bidUserIds);
|
||||
$item->isMy = $item->user_id == $user_id;
|
||||
$item->isMyWin = $item->winBidding && $item->winBidding->user_id == $user_id;
|
||||
$item->hasDelivery = in_array($item->id, $deliveredDemandIds);
|
||||
$item->button = $btnNameFun($opType, $item);
|
||||
// 列表不返回报价、合同和中标明细,避免其它开发者看到成交价与交付相关信息
|
||||
$item->hidden(['demandBiddings', 'demandContracts', 'winBidding']);
|
||||
});
|
||||
$this->success('', $list);
|
||||
} catch (\Exception $e) {
|
||||
@@ -222,6 +228,13 @@ class Demand extends Api
|
||||
if (!$info) {
|
||||
throw new \Exception('该需求不存在');
|
||||
}
|
||||
$info->isMy = $user_id == $info->user_id;//我发布
|
||||
$info->isMyWin = $info->winBidding && $info->winBidding->user_id == $user_id;//我中标
|
||||
$canSeeDeal = $info->isMy || $info->isMyWin;
|
||||
// 交易完成的订单,只有发布者和接单开发者可以查看
|
||||
if ((int)$info->status === DemandService::STATUS_FINISHED && !$canSeeDeal) {
|
||||
throw new \Exception('仅发布者和接单开发者可查看');
|
||||
}
|
||||
//更新浏览次数
|
||||
DemandService::where($where)->setInc('views');
|
||||
$steps = [
|
||||
@@ -239,12 +252,10 @@ class Demand extends Api
|
||||
'steps' => $steps,
|
||||
'current' => max($ins - 1, 0)
|
||||
];
|
||||
//我的报价
|
||||
$info->myBidding = DemandBiddingService::getOne(['demand_id' => $id, 'user_id' => $user_id]);
|
||||
//中标报价
|
||||
// $info->winBidding = DemandBiddingService::getOne(['demand_id' => $id, 'bidding_status' => DemandBiddingService::STATUS_BIDDING_WIN]);
|
||||
$info->isMy = $user_id == $info->user_id;//我发布
|
||||
$info->isMyWin = $info->winBidding && $info->winBidding->user_id == $user_id;//我中标
|
||||
// 招标中返回自己的报价,便于继续投标;成交报价只给发布者和接单开发者
|
||||
$info->myBidding = ((int)$info->status === DemandService::STATUS_BIDDING || $canSeeDeal)
|
||||
? DemandBiddingService::getOne(['demand_id' => $id, 'user_id' => $user_id])
|
||||
: null;
|
||||
//小程序内无法直接识别二维码,需先长按保存再用微信扫一扫
|
||||
$qrcodeText = '请使用微信扫码进群沟通';
|
||||
if ($user_id == $info->user_id) {
|
||||
@@ -257,8 +268,13 @@ class Demand extends Api
|
||||
'url' => $fl,
|
||||
'name' => urldecode(basename($fl))
|
||||
], $info->files);
|
||||
//交付内容(订单发货表,开发者发货后展示)
|
||||
$info->delivery = OrderShipService::getDemandDelivery($id);
|
||||
// 成交报价、合同和交付内容仅发布者与接单开发者可见
|
||||
if ($canSeeDeal) {
|
||||
$info->delivery = OrderShipService::getDemandDelivery($id);
|
||||
} else {
|
||||
$info->delivery = null;
|
||||
$info->hidden(['winBidding', 'demandContracts']);
|
||||
}
|
||||
|
||||
$this->success('', $info);
|
||||
} catch (\Exception $e) {
|
||||
@@ -273,8 +289,17 @@ class Demand extends Api
|
||||
{
|
||||
try {
|
||||
$demandId = $this->request->param('demandId', 0);
|
||||
$userId = $this->auth->id ?? 0;
|
||||
$demand = DemandService::getOne(['id' => $demandId], ['winBidding']);
|
||||
if (!$demand) {
|
||||
$this->error('该需求不存在');
|
||||
}
|
||||
$isMy = $demand->user_id == $userId;
|
||||
$isMyWin = $demand->winBidding && $demand->winBidding->user_id == $userId;
|
||||
if (!$isMy && !$isMyWin) {
|
||||
$this->error('仅发布者和接单开发者可查看');
|
||||
}
|
||||
$info = ContractService::getWinBiddingContract($demandId);
|
||||
$demand = DemandService::getOne(['id' => $demandId]);
|
||||
$platform = $demand ? VirtualPayService::normalizePayPlatform($demand->pay_platform) : '';
|
||||
$info->pay_platform = $platform !== '' ? $platform : 'android';
|
||||
if (empty($info->data_json['customData']) && ($firstContract = ContractService::getFirstContract($demandId))) {
|
||||
|
||||
Reference in New Issue
Block a user