Browse Source

Merge remote-tracking branch 'origin/develop' into develop

develop
李可松 4 years ago
parent
commit
90c7c5db62
  1. 22
      app/AdminAgent/Controllers/AgentProductController.php
  2. 74
      app/AdminAgent/Controllers/DemandController.php
  3. 61
      app/AdminAgent/Controllers/MyBiddingProductController.php
  4. 1
      app/AdminAgent/Extensions/Grid/ChangeOrderStatus.php
  5. 85
      app/AdminAgent/Extensions/Grid/ChooseDemand.php
  6. 3
      app/AdminAgent/Lazys/DemandBiddingLazys.php
  7. 5
      app/AdminAgent/routes.php
  8. 2
      app/AdminSettled/Controllers/AgentController.php
  9. 2
      app/AdminSettled/Controllers/GuideController.php
  10. 2
      app/AdminSettled/Controllers/SupplierController.php
  11. 102
      app/AdminSupplier/Controllers/DemandController.php
  12. 62
      app/AdminSupplier/Controllers/MyBiddingProductController.php
  13. 2
      app/AdminSupplier/Controllers/MyDemandProductController.php
  14. 4
      app/AdminSupplier/Controllers/ProductController.php
  15. 99
      app/AdminSupplier/Extensions/Grid/ChooseDemand.php
  16. 48
      app/AdminSupplier/Lazys/DemandBiddingLazys.php
  17. 3
      app/AdminSupplier/routes.php
  18. 19
      app/Http/Controllers/Api/OrderController.php
  19. 19
      app/Http/Controllers/Api/UserController.php
  20. 14
      app/Http/Controllers/Api/VerificationController.php
  21. 1
      app/Http/Controllers/Api/WxpayController.php
  22. 5
      app/Models/Demand.php
  23. 10
      app/Models/UserMoneyLog.php
  24. 1
      routes/api.php

22
app/AdminAgent/Controllers/AgentProductController.php

@ -211,13 +211,13 @@ class AgentProductController extends AdminController
])
->required();
$form->switch('is_rec')->help('推荐后将在“我的”页面下方显示');
$form->selectTable('verifier')
->title('选择核销人员')
->dialogWidth('50%;min-width:600px;') //不起作用
->from(SelectUser::make(['is_verify' => 1]))
->model(User::class, 'id', 'nickname')
->customFormat(fn($v) => !$v ? '' : $v)
->required();
//$form->selectTable('verifier')
// ->title('选择核销人员')
// ->dialogWidth('50%;min-width:600px;') //不起作用
// ->from(SelectUser::make(['is_verify' => 1]))
// ->model(User::class, 'id', 'nickname')
// ->customFormat(fn($v) => !$v ? '' : $v)
// ->required();
//组团版旅行社可以选择地接
if (Admin::user()->type == AgentType::CLUSTER) {
@ -321,13 +321,21 @@ class AgentProductController extends AdminController
if (array_key_exists('guide_id', $form->input())) {
$form->guide_id = $form->guide_id ?? 0;
}
//订金
if ($form->earnest <= 0 || $form->earnest_timeout <= 0) {
$form->earnest = 0;
$form->earnest_timeout = 0;
} else if ($form->earnest > $form->price) {
return $form->response()->error('订金不能大于商品价');
}
//定金
if ($form->deposit <= 0 || $form->deposit_timeout <= 0) {
$form->deposit = 0;
$form->deposit_timeout = 0;
} else if ($form->earnest > $form->price) {
return $form->response()->error('定金不能大于商品价');
}
//不允许编辑的字段

74
app/AdminAgent/Controllers/DemandController.php

@ -179,41 +179,41 @@ class DemandController extends AdminController
});
}
public function binding()
{
$demandBiddingId = request('demand_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();
//如果是地接类型 绑定地接到订单
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();
} catch (\Exception $e) {
Log::error('选中竞标失败::'.$e->getTraceAsString());
DB::rollBack();
return $this->jsonFail(1001,'选中竞标失败,稍后重试或联系管理员!'.$e->getMessage());
}
return back();
}
//public function binding()
//{
// $demandBiddingId = request('demand_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();
// //如果是地接类型 绑定地接到订单
// 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();
// } catch (\Exception $e) {
// Log::error('选中竞标失败::'.$e->getTraceAsString());
// DB::rollBack();
// return $this->jsonFail(1001,'选中竞标失败,稍后重试或联系管理员!'.$e->getMessage());
// }
// return back();
//}
}

61
app/AdminAgent/Controllers/MyBiddingProductController.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);
});
});
}
}

1
app/AdminAgent/Extensions/Grid/ChangeOrderStatus.php

@ -31,6 +31,7 @@ class ChangeOrderStatus extends RowAction
return $this->response()->error("订单不存在或已处理过了")->refresh();
}
$order->status = OrderStatus::OFFLINE_PAID;
$order->verify_code = uniqid(); //生成核销码
$order->save();
return $this->response()->success("操作成功,已设置为“线下已付款”")->refresh();

85
app/AdminAgent/Extensions/Grid/ChooseDemand.php

@ -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];
}
}

3
app/AdminAgent/Lazys/DemandBiddingLazys.php

@ -3,6 +3,7 @@
namespace App\AdminAgent\Lazys;
use App\AdminAgent\Extensions\Grid\ChooseDemand;
use App\AdminAgent\Repositories\DemandBidding;
use App\Models\Demand;
use App\Traits\DemandTraits;
@ -27,7 +28,7 @@ class DemandBiddingLazys extends LazyRenderable
return $demand->state == 1;
})
->then(function (Grid\Column $column) {
$column->append('<a class="btn btn-sm btn-primary" href="'.admin_url('/api/demand/binding?demand_bidding_id='.$this->id).'" style="color: white">选中竞标</a>');
$column->append(new ChooseDemand($this->id));
})
->if(function () use ($demand){
return $demand->state == 2;

5
app/AdminAgent/routes.php

@ -27,6 +27,7 @@ Route::group([
$router->resource('demand', 'DemandController');
$router->resource('demand_bidding', 'DemandBiddingController');
$router->resource('my_demand_product', 'MyDemandProductController');
$router->resource('my_bidding_product', 'MyBiddingProductController');
$router->resource('message/list', 'MessageController');
$router->resource('notice/list', 'NoticeController');
@ -35,7 +36,5 @@ Route::group([
$router->resource('article/list', 'ArticleController');
$router->resource('setting', 'SettingController');
$router->resource('channel/list', 'ChannelController');
//api
$router->any('/api/demand/binding', 'DemandController@binding');
});

2
app/AdminSettled/Controllers/AgentController.php

@ -73,7 +73,7 @@ class AgentController extends AdminController
$form->text('address')->required();
$form->image('license_pic')->required()->removable(false)->uniqueName();
$form->text('director')->required();
$form->text('contact_phone')->required();
$form->text('contact_phone')->required()->maxLength(13);
})->saving(function (Form $form) {
if ($form->isEditing()) {
return $form->response()->error('服务器出错了~~');

2
app/AdminSettled/Controllers/GuideController.php

@ -61,7 +61,7 @@ class GuideController extends AdminController
$form->text('name')->required();
$form->image('photo')->required()->removable(false)->uniqueName();
$form->image('license_pic')->required()->removable(false)->uniqueName();
$form->text('contact_phone')->required();
$form->text('contact_phone')->required()->maxLength(13);
})->saving(function (Form $form) {
//判断账号是否唯一
if ($form->isEditing()) {

2
app/AdminSettled/Controllers/SupplierController.php

@ -64,7 +64,7 @@ class SupplierController extends AdminController
$form->text('address')->required();
$form->image('license_pic')->required()->removable(false)->uniqueName();
$form->text('director')->required();
$form->text('contact_phone')->required();
$form->text('contact_phone')->required()->maxLength(13);
})->saving(function (Form $form) {
if ($form->isEditing()) {
return $form->response()->error('服务器出错了~~');

102
app/AdminSupplier/Controllers/DemandController.php

@ -2,7 +2,7 @@
namespace App\AdminSupplier\Controllers;
use App\AdminAgent\Lazys\DemandBiddingLazys;
use App\AdminSupplier\Lazys\DemandBiddingLazys;
use App\Models\AgentProduct;
use App\Models\DemandProduct;
use App\Models\Product;
@ -172,54 +172,54 @@ class DemandController extends AdminController
});
}
public function binding()
{
$demandBiddingId = request('demand_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();
} catch (\Exception $e) {
Log::error('选中竞标失败::'.$e->getTraceAsString());
DB::rollBack();
return $this->jsonFail(1001,'选中竞标失败,稍后重试或联系管理员!'.$e->getMessage());
}
return back();
}
//public function binding()
//{
// $demandBiddingId = request('demand_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();
// } catch (\Exception $e) {
// Log::error('选中竞标失败::'.$e->getTraceAsString());
// DB::rollBack();
// return $this->jsonFail(1001,'选中竞标失败,稍后重试或联系管理员!'.$e->getMessage());
// }
// return back();
//}
}

62
app/AdminSupplier/Controllers/MyBiddingProductController.php

@ -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);
});
});
}
}

2
app/AdminSupplier/Controllers/MyDemandProductController.php

@ -37,7 +37,7 @@ class MyDemandProductController extends AdminController
return Grid::make(new Demand(['publisher','biddingUser','product.category']), function (Grid $grid) {
$grid->model()
->where(['bidding_user_id' => Admin::user()->id,'bidding_user_type' => DemandTraits::$col[1]])
->where(['publisher_id' => Admin::user()->id,'publisher_type' => DemandTraits::$col[1]])
->where('product_id','>',0);
$grid->column('id')->sortable();

4
app/AdminSupplier/Controllers/ProductController.php

@ -35,6 +35,7 @@ class ProductController extends AdminController
$grid->column('stock');
$grid->column('sale');
$grid->column('status')->using(ProductStatus::array());
$grid->column('verify_mobile','核销号码');
$grid->column('created_at');
$grid->column('updated_at');
@ -67,6 +68,7 @@ class ProductController extends AdminController
$show->field('status');
$show->field('know')->unescape()->as(fn($v) => preg_replace('/<script.*?>.*?<\/script>/is', '', $v));
$show->field('content')->unescape()->as(fn($v) => preg_replace('/<script.*?>.*?<\/script>/is', '', $v));
$show->field('verify_mobile','核销号码');
$show->field('created_at');
$show->field('updated_at');
});
@ -96,7 +98,7 @@ class ProductController extends AdminController
$form->text('stock')->default(9999)->required();
$form->editor('know');
$form->editor('content')->required();
$form->text('verify_mobile','核销号码');
if ($form->isEditing()) {
$form->confirm('提示', '编辑产品需要重新审核,同时<span class="btn-danger">下架所有</span>关联的代理商产品,是否继续?');
}

99
app/AdminSupplier/Extensions/Grid/ChooseDemand.php

@ -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];
}
}

48
app/AdminSupplier/Lazys/DemandBiddingLazys.php

@ -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();
});
}
}

3
app/AdminSupplier/routes.php

@ -24,6 +24,5 @@ Route::group([
$router->resource('demand_bidding', 'DemandBiddingController');
$router->resource('demand_product', 'DemandProductController');
$router->resource('my_demand_product', 'MyDemandProductController');
//api
$router->any('/api/demand/binding', 'DemandController@binding');
$router->resource('my_bidding_product', 'MyBiddingProductController');
});

19
app/Http/Controllers/Api/OrderController.php

@ -74,20 +74,20 @@ class OrderController extends Controller
}, $v['pictures']);
}
//10分钟内未付款订单提示付款 TODO 此部分由定
/*if ($v['status'] == Status::UNPAID) {
$minute = $time - strtotime($v['created_at']);
//订单创建后10分钟内未付款则提示,否则取消订单
if ($minute < 600) {
$v['status_text'] = '请在' . ceil($minute / 60) . '分钟内付款';
} else {
//未付款订单提示剩余付款时
if ($v['status'] == Status::UNPAID) {
$second = strtotime($v['timeout']) - $time;
if ($second > 0) {
$v['status_text'] = '请在' . ceil($second / 60) . '分钟内付款';
} /*else { //TODO 此部分由定时
$timeout_ids[] = $v['id'];
$v['status'] = Status::CANCEL;
$v['status_text'] = '已取消';
//TODO 加回库存,未考虑到几天/几个月后再打开订单列表页的情况,需要定时任务处理
Product::query()->find($v['product_id'])->increment('stock', $v['num']);
}
}*/
}*/
}
}
//超时订单设置为已取消 TODO 测试阶段暂时注释
@ -339,6 +339,7 @@ class OrderController extends Controller
'notify_url' => route('wxpay_notify', ['agent_id' => $this->agent_id]), // 支付结果通知网址,如果不设置则会使用配置里的默认地址
'trade_type' => 'JSAPI',
'openid' => $openid,
'profit_sharing' => 'Y', //Y分账,N不分账,默认不分账,Y大写
]);
} catch (InvalidArgumentException | InvalidConfigException | GuzzleException $e) {
return ['error' => $e->getMessage(), 'line' => $e->getLine()];

19
app/Http/Controllers/Api/UserController.php

@ -7,6 +7,7 @@ use App\Models\User;
use EasyWeChat\Factory;
use EasyWeChat\Kernel\Exceptions\DecryptException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache;
/**
@ -67,4 +68,22 @@ class UserController extends Controller
$user->token = request()->header('Authentication');
return $this->success($user);
}
public function bindingMobile(Request $request)
{
$request->validate([
'mobile' => 'required|int|between:10000000000,19999999999',
], [
'*.required' => '参数异常'
]);
$userId = $this->user_id;
$user = User::find($userId);
$user->mobile = Request('mobile',0);
if ($user->save()) {
return $this->success($user);
} else {
return $this->error('绑定失败',407);
}
}
}

14
app/Http/Controllers/Api/VerificationController.php

@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\Agent;
use App\Models\Order;
use App\Models\Product;
use App\Models\User;
use App\Common\OrderStatus;
use EasyWeChat\Factory;
@ -31,7 +32,13 @@ class VerificationController extends Controller
}
$user = User::firstWhere(['id' => $this->user_id, 'status' => 1]);
if (!$user || $user->is_verify !=1 || $user->id != $order->agentProduct->verifier) {
if (!$user || $user->is_verify !=1) {
return $this->error('对不起,你没有核销权限,请联系管理员');
}
$checkMobile = Product::query()->whereIn('id',explode(',',$order->product_ids))->where('verify_mobile',$user->mobile)->doesntExist();
if ($checkMobile) {
return $this->error('对不起,你没有核销权限,请联系管理员');
}
@ -41,6 +48,7 @@ class VerificationController extends Controller
return $this->success();
}
//生成核销二维码
public function qrcode()
{
$id = request()->input('id'); //订单ID
@ -48,7 +56,7 @@ class VerificationController extends Controller
$order = Order::where(['agent_id' => $this->agent_id, 'user_id' => $this->user_id])->find($id);
if (!$order) {
return $this->error('订单不存在!');
} else if (!in_array($order->status, [OrderStatus::PAID, OrderStatus::PAID_RETAINAGE, OrderStatus::REFUSED_REFUND])) {
} else if (!in_array($order->status, [OrderStatus::PAID, OrderStatus::PAID_RETAINAGE, OrderStatus::OFFLINE_PAID, OrderStatus::REFUSED_REFUND])) {
return $this->error('当前订单状态不允许核销!');
} else if (!$order->verify_code) {
$order->verify_code = uniqid();
@ -64,7 +72,7 @@ class VerificationController extends Controller
];
$app = Factory::miniProgram($config);
$response = $app->app_code->getUnlimit($verify_code, ['path' => 'pages/index/index']);
$response = $app->app_code->getUnlimit($verify_code, ['path' => 'pages/verification/index']);
if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
$filename = $response->saveAs(storage_path('app/public/verify_code'), $verify_code);

1
app/Http/Controllers/Api/WxpayController.php

@ -80,6 +80,7 @@ class WxpayController
$order->paid_at = now();
$order->paid_money = DB::raw('`paid_money` + ' . $money);
$order->timeout = null; //清除超时时间
$order->save();
//增加销量,库存在拍下时已经减了

5
app/Models/Demand.php

@ -32,4 +32,9 @@ class Demand extends BaseModel
{
return $this->hasOne(AgentProduct::class, 'id', 'agent_product_id');
}
public function bidding()
{
return $this->hasOne(DemandBidding::class,'id','bidding_id');
}
}

10
app/Models/UserMoneyLog.php

@ -14,4 +14,14 @@ class UserMoneyLog extends BaseModel
parent::__construct($attributes);
$this->timestamps = false;
}
public function agent()
{
return $this->belongsTo(Agent::class);
}
public function order()
{
return $this->belongsTo(Order::class);
}
}

1
routes/api.php

@ -124,6 +124,7 @@ Route::namespace('App\Http\Controllers\Api')
Route::prefix('user')->group(function () {
Route::post('info', 'UserController@info'); //解密用户信息
Route::post('profile', 'UserController@profile'); //解密用户信息
//Route::post('bindingMobile', 'UserController@bindingMobile'); //解密用户信息
});
# 文件上传

Loading…
Cancel
Save