Browse Source

Merge branch 'develop' of ssh://8.134.10.79:222/Leadfyy.co/hainan into develop

master
shuixiang 4 years ago
parent
commit
2689d40a25
  1. 3
      app/Admin/Controllers/DemandProductController.php
  2. 12
      app/Admin/Extensions/Grid/MiniProgramUpload.php
  3. 16
      app/Admin/Repositories/DemandProduct.php
  4. 27
      app/AdminSupplier/Controllers/DemandBiddingController.php
  5. 5
      app/AdminSupplier/Renderable/SelectProduct.php
  6. 8
      app/Http/Controllers/Api/LoginController.php
  7. 32
      app/Http/Controllers/Api/TestController.php
  8. 3
      ready.md

3
app/Admin/Controllers/DemandProductController.php

@ -3,11 +3,10 @@
namespace App\Admin\Controllers;
use App\Admin\Extensions\Grid\AuditDemandProduct;
use App\Admin\Repositories\Product;
use App\Admin\Repositories\DemandProduct;
use App\Common\ProductStatus;
use App\Common\UserStatus;
use App\Models\Category;
use App\Models\DemandProduct;
use App\Models\Supplier;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;

12
app/Admin/Extensions/Grid/MiniProgramUpload.php

@ -68,8 +68,18 @@ class MiniProgramUpload extends RowAction
if (!$refreshToken) {
return $this->response()->error('获取refresh_token失败');
}
$miniProgram = $openPlatform->miniProgram($agent->appid, $refreshToken);
//设置业务域名
/** @var \EasyWeChat\OpenPlatform\Authorizer\MiniProgram\Domain\Client $domain */
$domain = $miniProgram['domain'];
$res = $domain->setWebviewDomain([env('APP_URL')]);
if (!isset($res['errcode'], $res['errmsg']) || $res['errcode'] != 0 || $res['errmsg'] != 'ok') {
throw new \Exception('设置业务域名失败!');
}
/** @var Client $code */
$code = $openPlatform->miniProgram($agent->appid, $refreshToken)['code'] ?? null;
$code = $miniProgram['code'] ?? null;
if (!$code) {
return $this->response()->error('获取code失败');
}

16
app/Admin/Repositories/DemandProduct.php

@ -0,0 +1,16 @@
<?php
namespace App\Admin\Repositories;
use App\Models\DemandProduct as Model;
use Dcat\Admin\Repositories\EloquentRepository;
class DemandProduct extends EloquentRepository
{
/**
* Model.
*
* @var string
*/
protected $eloquentClass = Model::class;
}

27
app/AdminSupplier/Controllers/DemandBiddingController.php

@ -109,18 +109,6 @@ class DemandBiddingController extends AdminController
$form->disableViewButton();
$form->disableViewCheck();
$demand_id = request('demand_id');
$isBidding = \App\Models\DemandBidding::query()
->where('demand_id',$demand_id)
->where([
'bidding_user_type' => DemandTraits::$col[1],
'bidding_user_id' => Admin::user()->id
])
->exists();
if ($demand_id && $isBidding) {
Admin::exit('你已经竞标过了,无需重复参加');
}
$form->display('id')->disable();
if(request('is_bidding',0)) {
@ -145,6 +133,21 @@ class DemandBiddingController extends AdminController
$form->bidding_user_id = Admin::user()->id;
});
$form->saving(function (Form $form) {
if ($form->isCreating()) {
$isBidding = \App\Models\DemandBidding::query()
->where('demand_id',$form->demand_id)
->where([
'bidding_user_type' => DemandTraits::$col[1],
'bidding_user_id' => Admin::user()->id
])
->exists();
if ($isBidding) {
Admin::exit('你已经竞标过了,无需重复参加');
}
}
});
$form->saved(function (Form $form) {
$provinceId = Demand::query()->where('id',$this->demand_id)->value('province_id');

5
app/AdminSupplier/Renderable/SelectProduct.php

@ -26,7 +26,10 @@ class SelectProduct extends LazyRenderable
$grid->disableBatchActions();
//$grid->model()->where('status', ProductStatus::ON_SALE);
$grid->model()->where('supplier_id', Admin::user()->id);
$grid->model()->where([
'supplier_id' => Admin::user()->id,
'status' => ProductStatus::ON_SALE
]);
$grid->quickSearch(['title', 'supplier.name'])->placeholder('搜索产品名称、供应商');
$grid->column('id');

8
app/Http/Controllers/Api/LoginController.php

@ -53,9 +53,13 @@ class LoginController extends Controller
];
$app = Factory::openPlatform($config);
dd($app);
$refreshToken = $app->getAuthorizer($appid)['authorization_info']['authorizer_refresh_token'] ?? null;
if (!$refreshToken) {
return $this->error('获取refresh_token失败');
}
$app = $app->miniProgram($appid, $refreshToken);
}
dd($agent->toArray());
try {
$res = $app->auth->session($code);
if (!empty($res['errcode']) || empty($res['openid']) && empty($res['unionid'])) {

32
app/Http/Controllers/Api/TestController.php

@ -2,10 +2,8 @@
namespace App\Http\Controllers\Api;
use App\Models\Agent;
use App\Models\Order;
use App\Models\OrderProductItem;
use App\Models\Product;
use App\Models\AdminSetting;
use EasyWeChat\Factory;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
@ -18,7 +16,31 @@ class TestController
{
public function index()
{
return $this->login(2);
$appid = 'wx5bd5789ad8f89524';
$setting = AdminSetting::val(['service_appid', 'service_appsecret', 'service_token', 'service_aeskey']);
$config = [
'app_id' => $setting['service_appid'],
'secret' => $setting['service_appsecret'],
'token' => $setting['service_token'],
'aes_key' => $setting['service_aeskey'],
];
$app = Factory::openPlatform($config);
$refreshToken = $app->getAuthorizer($appid)['authorization_info']['authorizer_refresh_token'] ?? null;
if (!$refreshToken) {
return $this->error('获取refresh_token失败');
}
$miniProgram = $app->miniProgram($appid, $refreshToken);
$domain = $miniProgram['domain'];
$host = env('APP_URL');
$param = [
"action" => "add",
"requestdomain" => [$host],
"uploaddomain" => [$host],
"downloaddomain" => [$host],
];
return [$domain->modify($param), $domain->setWebviewDomain([env('APP_URL')])];
}
/**

3
ready.md

@ -42,6 +42,9 @@ TRUNCATE `users`;
TRUNCATE `user_channels`;
TRUNCATE `user_favs`;
TRUNCATE `user_money_logs`;
TRUNCATE `withdrawal`;
TRUNCATE `withdrawal_alipay`;
TRUNCATE `withdrawal_bank`;
TRUNCATE `workorder`;
TRUNCATE `workorder_item`;

Loading…
Cancel
Save