24 changed files with 528 additions and 118 deletions
-
22app/AdminAgent/Controllers/AgentProductController.php
-
74app/AdminAgent/Controllers/DemandController.php
-
61app/AdminAgent/Controllers/MyBiddingProductController.php
-
1app/AdminAgent/Extensions/Grid/ChangeOrderStatus.php
-
85app/AdminAgent/Extensions/Grid/ChooseDemand.php
-
3app/AdminAgent/Lazys/DemandBiddingLazys.php
-
5app/AdminAgent/routes.php
-
2app/AdminSettled/Controllers/AgentController.php
-
2app/AdminSettled/Controllers/GuideController.php
-
2app/AdminSettled/Controllers/SupplierController.php
-
102app/AdminSupplier/Controllers/DemandController.php
-
62app/AdminSupplier/Controllers/MyBiddingProductController.php
-
2app/AdminSupplier/Controllers/MyDemandProductController.php
-
4app/AdminSupplier/Controllers/ProductController.php
-
99app/AdminSupplier/Extensions/Grid/ChooseDemand.php
-
48app/AdminSupplier/Lazys/DemandBiddingLazys.php
-
3app/AdminSupplier/routes.php
-
19app/Http/Controllers/Api/OrderController.php
-
19app/Http/Controllers/Api/UserController.php
-
14app/Http/Controllers/Api/VerificationController.php
-
1app/Http/Controllers/Api/WxpayController.php
-
5app/Models/Demand.php
-
10app/Models/UserMoneyLog.php
-
1routes/api.php
@ -0,0 +1,61 @@ |
|||
<?php |
|||
|
|||
namespace App\AdminAgent\Controllers; |
|||
|
|||
|
|||
use App\Common\ProductStatus; |
|||
use App\Traits\ResponseHelper; |
|||
use App\AdminAgent\Repositories\Demand; |
|||
use Dcat\Admin\Admin; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Http\Controllers\AdminController; |
|||
use App\Traits\DemandTraits; |
|||
|
|||
class MyBiddingProductController extends AdminController |
|||
{ |
|||
|
|||
use ResponseHelper; |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new Demand(['publisher','biddingUser','product.category']), function (Grid $grid) { |
|||
|
|||
$grid->model() |
|||
//->where(['publisher_id' => Admin::user()->id,'publisher_type' => DemandTraits::$col[0]])
|
|||
->where('product_id','>',0) |
|||
->whereHas('bidding',function ($query) { |
|||
$query->where(['state' => 1,'bidding_user_id' => Admin::user()->id,'bidding_user_type' => DemandTraits::$col[0]]); |
|||
}); |
|||
$grid->column('id')->sortable(); |
|||
//$grid->column('title');
|
|||
//$grid->column('detail','内容')->display('查看')->modal('详情',function ($modal) {
|
|||
// $modal->xl();
|
|||
// return $this->comment;
|
|||
//});
|
|||
$grid->column('biddingUser.name','中标人'); |
|||
$grid->column('price','发标价格'); |
|||
$grid->column('product.category.name', '产品分类'); |
|||
$grid->column('product.title','产品标题'); |
|||
$grid->column('product.picture','产品图片')->image('', 60, 60); |
|||
$grid->column('product.price','产品售价'); |
|||
$grid->column('product.original_price','产品原价'); |
|||
$grid->column('product.stock','产品库存'); |
|||
$grid->column('product.sale','产品销量'); |
|||
$grid->column('product.status','产品状态')->using(ProductStatus::array()); |
|||
$grid->disableDeleteButton(); |
|||
$grid->disableEditButton(); |
|||
$grid->disableQuickEditButton(); |
|||
$grid->disableViewButton(); |
|||
$grid->disableActions(); |
|||
$grid->filter(function (Grid\Filter $filter) { |
|||
$filter->equal('id'); |
|||
$filter->equal('bidding_user_type','竞标用户类型')->select(DemandTraits::$polymorphic); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,85 @@ |
|||
<?php |
|||
|
|||
namespace App\AdminAgent\Extensions\Grid; |
|||
|
|||
use App\Models\AgentProduct; |
|||
use App\Models\DemandBidding; |
|||
use App\Traits\DemandTraits; |
|||
use Dcat\Admin\Grid\RowAction; |
|||
use Illuminate\Http\Request; |
|||
use Illuminate\Support\Facades\DB; |
|||
use Illuminate\Support\Facades\Log; |
|||
|
|||
/** |
|||
* 供应商审核 |
|||
* Class AuditSupplier |
|||
* @package App\Admin\Extensions\Grid |
|||
*/ |
|||
class ChooseDemand extends RowAction |
|||
{ |
|||
private $id; |
|||
|
|||
public function __construct($biddingId = '') |
|||
{ |
|||
parent::__construct('选中竞标'); |
|||
$this->id = $biddingId; |
|||
$this->title = '选中竞标'; |
|||
} |
|||
|
|||
protected function html() |
|||
{ |
|||
$class = 'btn btn-sm btn-success'; |
|||
$this->appendHtmlAttribute('class', $class); |
|||
$this->defaultHtmlAttribute('href', 'javascript:;'); |
|||
|
|||
return "<a {$this->formatHtmlAttributes()}>{$this->title}</a>"; |
|||
} |
|||
|
|||
public function handle(Request $request) |
|||
{ |
|||
$demandBiddingId = request('bidding_id',0); |
|||
$demandBidding = DemandBidding::find($demandBiddingId); |
|||
if (empty($demandBidding)) { |
|||
return $this->response()->error('订单异常'); |
|||
} |
|||
|
|||
$demand = \App\Models\Demand::find($demandBidding->demand_id); |
|||
|
|||
if (empty($demand)) { |
|||
return $this->response()->error('订单异常'); |
|||
} |
|||
|
|||
DB::beginTransaction(); |
|||
try { |
|||
$demandBidding->state = 1; |
|||
$demandBidding->save(); |
|||
//改变订单状态
|
|||
$demand->bidding_id = $demandBidding->id; |
|||
$demand->bidding_user_id = $demandBidding->bidding_user_id; |
|||
$demand->state = DemandTraits::$stateKey[1]; |
|||
$demand->save(); |
|||
//如果是地接类型 绑定地接到订单
|
|||
if ($demand->bidding_user_type == DemandTraits::$col[2]){ |
|||
$agentProduct = AgentProduct::find($demand->agent_product_id); |
|||
$agentProduct->guide_id = $demandBidding->bidding_user_id; |
|||
$agentProduct->save(); |
|||
} |
|||
DB::commit(); |
|||
return $this->response()->success("选中竞标成功")->refresh(); |
|||
} catch (\Exception $e) { |
|||
Log::error('选中竞标失败::'.$e->getTraceAsString()); |
|||
DB::rollBack(); |
|||
return $this->response()->error($e->getMessage()); |
|||
} |
|||
} |
|||
|
|||
public function confirm() |
|||
{ |
|||
return ['确定要选中该竞标吗?', '']; |
|||
} |
|||
|
|||
public function parameters() |
|||
{ |
|||
return ['bidding_id' => $this->id]; |
|||
} |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
<?php |
|||
|
|||
namespace App\AdminSupplier\Controllers; |
|||
|
|||
|
|||
use App\Common\ProductStatus; |
|||
use App\Traits\ResponseHelper; |
|||
use App\AdminAgent\Repositories\Demand; |
|||
use Dcat\Admin\Admin; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Http\Controllers\AdminController; |
|||
use App\Traits\DemandTraits; |
|||
use Dcat\Admin\Repositories\EloquentRepository; |
|||
|
|||
class MyBiddingProductController extends AdminController |
|||
{ |
|||
|
|||
use ResponseHelper; |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new Demand(['publisher','biddingUser','product.category']), function (Grid $grid) { |
|||
|
|||
$grid->model() |
|||
//->where(['publisher_id' => Admin::user()->id,'publisher_type' => DemandTraits::$col[0]])
|
|||
->where('product_id','>',0) |
|||
->whereHas('bidding',function ($query) { |
|||
$query->where(['state' => 1,'bidding_user_id' => Admin::user()->id,'bidding_user_type' => DemandTraits::$col[1]]); |
|||
}); |
|||
$grid->column('id')->sortable(); |
|||
//$grid->column('title');
|
|||
//$grid->column('detail','内容')->display('查看')->modal('详情',function ($modal) {
|
|||
// $modal->xl();
|
|||
// return $this->comment;
|
|||
//});
|
|||
$grid->column('publisher.name','发标人'); |
|||
$grid->column('price','发标价格'); |
|||
$grid->column('product.category.name', '产品分类'); |
|||
$grid->column('product.title','产品标题'); |
|||
$grid->column('product.picture','产品图片')->image('', 60, 60); |
|||
$grid->column('product.price','产品售价'); |
|||
$grid->column('product.original_price','产品原价'); |
|||
$grid->column('product.stock','产品库存'); |
|||
$grid->column('product.sale','产品销量'); |
|||
$grid->column('product.status','产品状态')->using(ProductStatus::array()); |
|||
$grid->disableDeleteButton(); |
|||
$grid->disableEditButton(); |
|||
$grid->disableQuickEditButton(); |
|||
$grid->disableViewButton(); |
|||
$grid->disableActions(); |
|||
$grid->filter(function (Grid\Filter $filter) { |
|||
$filter->equal('id'); |
|||
$filter->equal('bidding_user_type','竞标用户类型')->select(DemandTraits::$polymorphic); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,99 @@ |
|||
<?php |
|||
|
|||
namespace App\AdminAgent\Extensions\Grid; |
|||
|
|||
use App\Models\AgentProduct; |
|||
use App\Models\DemandBidding; |
|||
use App\Models\DemandProduct; |
|||
use App\Traits\DemandTraits; |
|||
use Dcat\Admin\Grid\RowAction; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
use Illuminate\Http\Request; |
|||
use Illuminate\Support\Facades\DB; |
|||
use Illuminate\Support\Facades\Log; |
|||
|
|||
/** |
|||
* 供应商审核 |
|||
* Class AuditSupplier |
|||
* @package App\Admin\Extensions\Grid |
|||
*/ |
|||
class ChooseDemand extends RowAction |
|||
{ |
|||
private $id; |
|||
|
|||
public function __construct($biddingId = '') |
|||
{ |
|||
parent::__construct('选中竞标'); |
|||
$this->id = $biddingId; |
|||
$this->title = '选中竞标'; |
|||
} |
|||
|
|||
protected function html() |
|||
{ |
|||
$class = 'btn btn-sm btn-success'; |
|||
$this->appendHtmlAttribute('class', $class); |
|||
$this->defaultHtmlAttribute('href', 'javascript:;'); |
|||
|
|||
return "<a {$this->formatHtmlAttributes()}>{$this->title}</a>"; |
|||
} |
|||
|
|||
public function handle(Request $request) |
|||
{ |
|||
$demandBiddingId = request('bidding_id',0); |
|||
$demandBidding = DemandBidding::find($demandBiddingId); |
|||
if (empty($demandBidding)) { |
|||
return false; |
|||
} |
|||
|
|||
$demand = \App\Models\Demand::find($demandBidding->demand_id); |
|||
|
|||
if (empty($demand)) { |
|||
return false; |
|||
} |
|||
|
|||
DB::beginTransaction(); |
|||
try { |
|||
$demandBidding->state = 1; |
|||
$demandBidding->save(); |
|||
//改变订单状态
|
|||
$demand->bidding_id = $demandBidding->id; |
|||
$demand->bidding_user_id = $demandBidding->bidding_user_id; |
|||
$demand->state = DemandTraits::$stateKey[1]; |
|||
$demand->save(); |
|||
//将产品绑给代理商
|
|||
$demandProduct = DemandProduct::find($demand->demand_product_id); |
|||
$product = new Product(); |
|||
|
|||
$product->supplier_id = $demandProduct->supplier_id; |
|||
$product->category_id = $demandProduct->category_id; |
|||
$product->title = $demandProduct->title; |
|||
$product->price = $demandBidding->price; |
|||
$product->original_price = $demandBidding->price; |
|||
$product->pictures = $demandProduct->pictures; |
|||
$product->stock = $demand->stock; |
|||
$product->know = $demandProduct->know; |
|||
$product->content = $demandProduct->content; |
|||
$product->agent_id = $demandBidding->bidding_user_id; |
|||
$product->save(); |
|||
|
|||
$demand->product_id = $product->id; |
|||
$demand->save(); |
|||
DB::commit(); |
|||
return $this->response()->success("选中竞标成功")->refresh(); |
|||
} catch (\Exception $e) { |
|||
Log::error('选中竞标失败::'.$e->getTraceAsString()); |
|||
DB::rollBack(); |
|||
return $this->response()->error($e->getMessage()); |
|||
} |
|||
} |
|||
|
|||
public function confirm() |
|||
{ |
|||
return ['确定要选中该竞标吗?', '']; |
|||
} |
|||
|
|||
public function parameters() |
|||
{ |
|||
return ['bidding_id' => $this->id]; |
|||
} |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\AdminSupplier\Lazys; |
|||
|
|||
use App\AdminAgent\Extensions\Grid\ChooseDemand; |
|||
use App\AdminAgent\Repositories\DemandBidding; |
|||
use App\Models\Demand; |
|||
use App\Traits\DemandTraits; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Grid\LazyRenderable; |
|||
use Illuminate\Support\Arr; |
|||
|
|||
class DemandBiddingLazys extends LazyRenderable |
|||
{ |
|||
public function grid(): Grid |
|||
{ |
|||
return Grid::make(new DemandBidding(['biddingUser']), function (Grid $grid) { |
|||
$demandId = request('demand_id',''); |
|||
$demand = Demand::find($demandId); |
|||
$grid->model()->where('demand_id',$demandId); |
|||
$grid->column('id'); |
|||
$grid->column('price','出价'); |
|||
$grid->column('comment','内容'); |
|||
$grid->column('biddingUser.name','竞拍人'); |
|||
$grid->column('bidding','竞标') |
|||
->if(function () use ($demand){ |
|||
return $demand->state == 1; |
|||
}) |
|||
->then(function (Grid\Column $column) { |
|||
$column->append(new ChooseDemand($this->id)); |
|||
}) |
|||
->if(function () use ($demand){ |
|||
return $demand->state == 2; |
|||
}) |
|||
->then(function (Grid\Column $column) use ($demand){ |
|||
if ($demand->bidding_id == $this->id) { |
|||
$column->append('<span class="text-success">已中标</span>'); |
|||
} else { |
|||
$column->append('<span class="text-danger">未中标</span>'); |
|||
} |
|||
}); |
|||
$grid->column('created_at'); |
|||
$grid->disableActions(); |
|||
$grid->disableRowSelector(); |
|||
}); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue