71 changed files with 673 additions and 231 deletions
-
4MySQL_change.sql
-
80app/Admin/Actions/Grid/BatchAuditProduct.php
-
37app/Admin/Controllers/AgentController.php
-
1app/Admin/Controllers/AgentStatisticsController.php
-
2app/Admin/Controllers/CategoryController.php
-
4app/Admin/Controllers/DemandProductController.php
-
6app/Admin/Controllers/IndustryOrderController.php
-
12app/Admin/Controllers/IndustryProductController.php
-
82app/Admin/Controllers/MiniProgramController.php
-
18app/Admin/Controllers/OrderController.php
-
1app/Admin/Controllers/OrderStatisticsController.php
-
15app/Admin/Controllers/ProductController.php
-
1app/Admin/Controllers/ProductStatisticsController.php
-
5app/Admin/Controllers/SupplierController.php
-
1app/Admin/Controllers/SupplierStatisticsController.php
-
1app/Admin/Controllers/UserStatisticsController.php
-
133app/Admin/Extensions/Form/Radio2.php
-
4app/Admin/Extensions/Grid/AuditAgent.php
-
1app/Admin/routes.php
-
94app/AdminAgent/Actions/Tree/LoadSystemCategory.php
-
30app/AdminAgent/Controllers/AgentProductController.php
-
8app/AdminAgent/Controllers/CategoryController.php
-
1app/AdminAgent/Controllers/FinanceStatisticsController.php
-
2app/AdminAgent/Controllers/GroupOrderController.php
-
4app/AdminAgent/Controllers/IndustryOrderController.php
-
5app/AdminAgent/Controllers/IndustryProductController.php
-
42app/AdminAgent/Controllers/OrderController.php
-
1app/AdminAgent/Controllers/OrderStatisticsController.php
-
1app/AdminAgent/Controllers/ProductStatisticsController.php
-
1app/AdminAgent/Controllers/SupplierController.php
-
1app/AdminAgent/Controllers/UserStatisticsController.php
-
4app/AdminAgent/Controllers/WithdrawalAlipayController.php
-
3app/AdminAgent/Controllers/WithdrawalBankController.php
-
7app/AdminAgent/Controllers/WorkorderController.php
-
8app/AdminAgent/Renderable/SelectProduct.php
-
4app/AdminAgent/bootstrap.php
-
8app/AdminGuide/Controllers/OrderController.php
-
1app/AdminGuide/Controllers/WalletController.php
-
5app/AdminGuide/Controllers/WithdrawalAlipayController.php
-
5app/AdminGuide/Controllers/WithdrawalBankController.php
-
8app/AdminGuide/Controllers/WorkorderController.php
-
4app/AdminGuide/bootstrap.php
-
2app/AdminSupplier/Controllers/AgentController.php
-
6app/AdminSupplier/Controllers/DepositLogController.php
-
11app/AdminSupplier/Controllers/DiyFormController.php
-
1app/AdminSupplier/Controllers/FinanceStatisticsController.php
-
4app/AdminSupplier/Controllers/IndustryOrderController.php
-
27app/AdminSupplier/Controllers/IndustryProductController.php
-
39app/AdminSupplier/Controllers/OrderController.php
-
1app/AdminSupplier/Controllers/OrderStatisticsController.php
-
59app/AdminSupplier/Controllers/ProductController.php
-
1app/AdminSupplier/Controllers/ProductStatisticsController.php
-
5app/AdminSupplier/Controllers/WithdrawalAlipayController.php
-
5app/AdminSupplier/Controllers/WithdrawalBankController.php
-
7app/AdminSupplier/Controllers/WorkorderController.php
-
4app/AdminSupplier/Extensions/Grid/IndustryOrderStatus.php
-
10app/AdminSupplier/Forms/SupplierInfo.php
-
8app/AdminSupplier/Renderable/SelectProduct.php
-
4app/AdminSupplier/bootstrap.php
-
22app/Http/Controllers/Api/AgentProductController.php
-
2app/Http/Controllers/Api/OrderController.php
-
2app/Http/Controllers/Api/SharePayController.php
-
2app/Jobs/UploadMiniProgramQueue.php
-
1app/Models/Category.php
-
2app/Service/UploadMiniProgram.php
-
2resources/js/agent-spec-edit.js
-
2resources/js/supplier-batch-add-spec.js
-
4resources/lang/zh_CN/agent.php
-
5resources/lang/zh_CN/order.php
-
2resources/lang/zh_CN/supplier.php
-
3routes/api.php
@ -0,0 +1,80 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Actions\Grid; |
||||
|
|
||||
|
use Dcat\Admin\Actions\Response; |
||||
|
use Dcat\Admin\Grid\BatchAction; |
||||
|
use Dcat\Admin\Traits\HasPermissions; |
||||
|
use Illuminate\Contracts\Auth\Authenticatable; |
||||
|
use Illuminate\Database\Eloquent\Model; |
||||
|
use Illuminate\Http\Request; |
||||
|
|
||||
|
/** |
||||
|
* 批量审核产品 |
||||
|
* Class BatchAuditProduct |
||||
|
* @package App\Admin\Actions\Grid |
||||
|
*/ |
||||
|
class BatchAuditProduct extends BatchAction |
||||
|
{ |
||||
|
/** |
||||
|
* @return string |
||||
|
*/ |
||||
|
protected $title = '批量审核'; |
||||
|
|
||||
|
public function __construct($title = null) |
||||
|
{ |
||||
|
parent::__construct($title); |
||||
|
} |
||||
|
|
||||
|
public function render() |
||||
|
{ |
||||
|
$redirect = request()->fullUrl(); |
||||
|
|
||||
|
return <<<HTML |
||||
|
<a data-name="{$this->parent->getName()}" |
||||
|
data-action="batch-delete" |
||||
|
data-redirect="{$redirect}" |
||||
|
data-url="{$this->resource()}"><i class="fa fa-check-square"></i> {$this->title}</a> |
||||
|
HTML;//拒绝图标:fa-times-circle
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Handle the action request. |
||||
|
* |
||||
|
* @param Request $request |
||||
|
* |
||||
|
* @return Response |
||||
|
*/ |
||||
|
public function handle(Request $request) |
||||
|
{ |
||||
|
return $this->response() |
||||
|
->success('Processed successfully: '.json_encode($this->getKey())) |
||||
|
->redirect('/'); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return string|array|void |
||||
|
*/ |
||||
|
public function confirm() |
||||
|
{ |
||||
|
// return ['Confirm?', 'contents'];
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param Model|Authenticatable|HasPermissions|null $user |
||||
|
* |
||||
|
* @return bool |
||||
|
*/ |
||||
|
protected function authorize($user): bool |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return array |
||||
|
*/ |
||||
|
protected function parameters() |
||||
|
{ |
||||
|
return []; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,82 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Controllers; |
||||
|
|
||||
|
use App\Admin\Extensions\Grid\MiniProgramAuditStatus; |
||||
|
use App\Admin\Extensions\Grid\MiniProgramPull; |
||||
|
use App\Admin\Extensions\Grid\MiniProgramReg; |
||||
|
use App\Admin\Extensions\Grid\MiniProgramUpload; |
||||
|
use App\Common\AgentType; |
||||
|
use App\Common\UserStatus; |
||||
|
use App\Models\Agent; |
||||
|
use App\Models\MiniProgramTemplate; |
||||
|
use Dcat\Admin\Grid; |
||||
|
use Dcat\Admin\Http\Controllers\AdminController; |
||||
|
|
||||
|
class MiniProgramController extends AdminController |
||||
|
{ |
||||
|
protected $title = '小程序管理'; |
||||
|
protected $translation = 'agent'; |
||||
|
|
||||
|
/** |
||||
|
* Make a grid builder. |
||||
|
* |
||||
|
* @return Grid |
||||
|
*/ |
||||
|
protected function grid() |
||||
|
{ |
||||
|
return Grid::make(new Agent(), function (Grid $grid) { |
||||
|
$grid->disableRowSelector(); |
||||
|
$grid->disableCreateButton(); |
||||
|
$grid->disableActions(); |
||||
|
|
||||
|
$grid->model() |
||||
|
->whereIn('type', [AgentType::OPERATOR, AgentType::SUPPLIER]) |
||||
|
->where([['status', '=', UserStatus::NORMAL], ['id', '>', 1]]); //隐藏ID=1的领峰云管理员
|
||||
|
|
||||
|
$grid->tools(new MiniProgramPull('更新小程序模板')); |
||||
|
|
||||
|
$grid->column('id')->sortable(); |
||||
|
$grid->column('username'); |
||||
|
$grid->column('appid'); |
||||
|
$grid->column('name'); |
||||
|
$grid->column('company_name'); |
||||
|
$grid->column('created_at'); |
||||
|
|
||||
|
$last_template_id = MiniProgramTemplate::max('template_id'); |
||||
|
$grid->column('op', '操作') |
||||
|
->style('min-width:7em;') |
||||
|
->help('新用户入驻时,请先注册小程序。待企业法人认证通过之后,并设置邮箱、头像、昵称等,再上传小程序即可') |
||||
|
->if(fn() => true) |
||||
|
->display('') |
||||
|
->then(function ($column) use ($last_template_id) { |
||||
|
$is_success = $this->miniUpload->is_success ?? null; |
||||
|
$template_id = $this->miniUpload->template_id ?? null; |
||||
|
|
||||
|
if (empty($this->appid)) { //注册小程序
|
||||
|
$column->append((new MiniProgramReg(null, 1))->setKey($this->id))->append(' '); |
||||
|
$column->append((new MiniProgramReg(null, 2))->setKey($this->id)); |
||||
|
} else if ($is_success === 0 && $template_id === $last_template_id) { |
||||
|
$column->append("已发布(模板:{$template_id})"); |
||||
|
} else if (in_array($is_success, [-1, 2, 4])) { //如果状态是-1未检查过,或2审核中,或4审核延后,则显示审核状态按钮
|
||||
|
$column->append((new MiniProgramAuditStatus(null, 1))->setKey($this->id))->append(' '); |
||||
|
$column->append((new MiniProgramAuditStatus(null, 2))->setKey($this->id)); |
||||
|
} else { |
||||
|
$column->append((new MiniProgramUpload(null, 1))->setKey($this->id)); |
||||
|
$statusArr = [0 => '审核成功', 1 => '审核被拒绝', 2 => '审核中', 3 => '已撤回', 4 => '审核延后']; |
||||
|
if (isset($is_success, $statusArr[$is_success])) { |
||||
|
$column->append('<br>(模板' . $template_id . $statusArr[$is_success] . ')'); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
$grid->filter(function (Grid\Filter $filter) { |
||||
|
$filter->panel(); |
||||
|
|
||||
|
$filter->equal('id')->width(2); |
||||
|
$filter->like('name')->width(3); |
||||
|
$filter->like('company_name')->width(3); |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,133 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Extensions\Form; |
||||
|
use Dcat\Admin\Form\Field\Radio; |
||||
|
use Dcat\Admin\Widgets\Radio as WidgetRadio; |
||||
|
|
||||
|
/** |
||||
|
* 由于信息收集表单中,hasMany中的radio存在多个时出现问题,故重写覆盖 |
||||
|
* Class Radio2 |
||||
|
* @package App\Admin\Extensions\Form |
||||
|
*/ |
||||
|
class Radio2 extends Radio |
||||
|
{ |
||||
|
protected $view = 'admin::form.radio'; |
||||
|
|
||||
|
/** |
||||
|
* {@inheritdoc} |
||||
|
*/ |
||||
|
public function render() |
||||
|
{ |
||||
|
if ($this->options instanceof \Closure) { |
||||
|
$this->options( |
||||
|
$this->options->call($this->values(), $this->value(), $this) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
$this->addCascadeScript(); |
||||
|
|
||||
|
$radio = WidgetRadio::make($this->getElementName(), $this->options, $this->style); |
||||
|
|
||||
|
if ($this->attributes['disabled'] ?? false) { |
||||
|
$radio->disable(); |
||||
|
} |
||||
|
|
||||
|
$radio |
||||
|
->inline($this->inline) |
||||
|
->check($this->value()) |
||||
|
->class($this->getElementClassString()) |
||||
|
->size($this->size); |
||||
|
|
||||
|
$this->addVariables([ |
||||
|
'radio' => $radio, |
||||
|
]); |
||||
|
|
||||
|
return parent::render(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Add cascade scripts to contents. |
||||
|
* |
||||
|
* @return string |
||||
|
*/ |
||||
|
protected function getCascadeScript() |
||||
|
{ |
||||
|
if (empty($this->conditions)) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
$cascadeGroups = collect($this->conditions)->map(function ($condition) { |
||||
|
return [ |
||||
|
'class' => $this->getCascadeClass($condition['value'], $condition['operator']), |
||||
|
'operator' => $condition['operator'], |
||||
|
'value' => $condition['value'], |
||||
|
]; |
||||
|
})->toJson(); |
||||
|
|
||||
|
return <<<JS |
||||
|
(function () { |
||||
|
var compare = function (a, b, o) { |
||||
|
if (! $.isArray(b)) { |
||||
|
return operator_table[o](a, b) |
||||
|
} |
||||
|
|
||||
|
if (o === '!=') { |
||||
|
var result = true; |
||||
|
for (var i in b) { |
||||
|
if (! operator_table[o](a, b[i])) { |
||||
|
result = false; |
||||
|
|
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
for (var i in b) { |
||||
|
if (operator_table[o](a, b[i])) { |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
var operator_table = { |
||||
|
'=': function(a, b) { |
||||
|
if ($.isArray(a) && $.isArray(b)) { |
||||
|
return $(a).not(b).length === 0 && $(b).not(a).length === 0; |
||||
|
} |
||||
|
|
||||
|
return String(a) === String(b); |
||||
|
}, |
||||
|
'>': function(a, b) { |
||||
|
return a > b; |
||||
|
}, |
||||
|
'<': function(a, b) { |
||||
|
return a < b; |
||||
|
}, |
||||
|
'>=': function(a, b) { return a >= b; }, |
||||
|
'<=': function(a, b) { return a <= b; }, |
||||
|
'!=': function(a, b) { |
||||
|
return ! operator_table['='](a, b); |
||||
|
}, |
||||
|
'in': function(a, b) { return Dcat.helpers.inObject(a, String(b), true); }, |
||||
|
'notIn': function(a, b) { return ! Dcat.helpers.inObject(a, String(b), true); }, |
||||
|
'has': function(a, b) { return Dcat.helpers.inObject(b, String(b), true); }, |
||||
|
}; |
||||
|
var cascade_groups = {$cascadeGroups}, event = '{$this->cascadeEvent}'; |
||||
|
|
||||
|
\$this.on(event, function (e) { |
||||
|
var checked = $(e.target).parent().parent().find(':checked').val(); |
||||
|
|
||||
|
cascade_groups.forEach(function (event) { |
||||
|
var group = $(e.target).closest('.form-group.form-field').next('div.cascade-group.'+event.class); |
||||
|
if (compare(checked, event.value, event.operator)) { |
||||
|
group.removeClass('d-none'); |
||||
|
} else { |
||||
|
group.addClass('d-none'); |
||||
|
} |
||||
|
}); |
||||
|
}).trigger(event); |
||||
|
})(); |
||||
|
JS; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,94 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\AdminAgent\Actions\Tree; |
||||
|
|
||||
|
use App\Models\Category; |
||||
|
use Dcat\Admin\Actions\Response; |
||||
|
use Dcat\Admin\Admin; |
||||
|
use Dcat\Admin\Traits\HasPermissions; |
||||
|
use Dcat\Admin\Tree\AbstractTool; |
||||
|
use Illuminate\Contracts\Auth\Authenticatable; |
||||
|
use Illuminate\Database\Eloquent\Model; |
||||
|
use Illuminate\Http\Request; |
||||
|
|
||||
|
class LoadSystemCategory extends AbstractTool |
||||
|
{ |
||||
|
/** |
||||
|
* @return string |
||||
|
*/ |
||||
|
protected $title = '导入系统分类'; |
||||
|
|
||||
|
/** |
||||
|
* Handle the action request. |
||||
|
* |
||||
|
* @param Request $request |
||||
|
* |
||||
|
* @return Response |
||||
|
*/ |
||||
|
public function handle(Request $request) |
||||
|
{ |
||||
|
$system_cate = Category::where('agent_id', 0)->orderBy('pid')->get(); |
||||
|
$system_name = $system_cate->pluck('name')->toArray(); |
||||
|
|
||||
|
$own_cate = Category::where('agent_id', Admin::user()->id)->get(); |
||||
|
$own_name = $own_cate->pluck('name')->toArray(); |
||||
|
|
||||
|
$no_name = array_diff($system_name, $own_name); //找到系统有,但自己没有的分类名
|
||||
|
$max_id = Category::where('agent_id', Admin::user()->id)->max('id'); |
||||
|
|
||||
|
Category::insert(array_map(function ($name) { |
||||
|
return [ |
||||
|
'agent_id' => Admin::user()->id, |
||||
|
'name' => $name, |
||||
|
'pid' => 0, |
||||
|
'sort' => 255, |
||||
|
]; |
||||
|
}, $no_name)); |
||||
|
|
||||
|
$own_cate = Category::where('agent_id', Admin::user()->id)->orderBy('id')->get(); //获取所有分类,包含新插入的分类
|
||||
|
$system_pid = $system_cate->pluck('pid', 'name')->toArray(); //获取原来系统的PID
|
||||
|
$own_id = $own_cate->pluck('id', 'name')->toArray(); //获取自己的PID,不考虑name重复的情况
|
||||
|
|
||||
|
foreach ($own_cate as $cate) { |
||||
|
//不是新插入的分类不处理
|
||||
|
if ($cate->id <= $max_id) continue; |
||||
|
|
||||
|
//如果原来系统PID不是0,则获取父类的名称,并在自己的分类中获取对应名称ID,再设置父分类
|
||||
|
$sys_pid = $system_pid[$cate['name']]; |
||||
|
if ($sys_pid != 0) { |
||||
|
$sys_pid_name = $system_cate->find($sys_pid)['name']; |
||||
|
|
||||
|
$cate->pid = $own_id[$sys_pid_name]; |
||||
|
$cate->save(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return $this->response()->success('操作成功!')->refresh(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return string|void |
||||
|
*/ |
||||
|
protected function href() |
||||
|
{ |
||||
|
// return admin_url('auth/users');
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return string|array|void |
||||
|
*/ |
||||
|
public function confirm() |
||||
|
{ |
||||
|
return ['操作确认', '确定要导入系统分类吗?']; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param Model|Authenticatable|HasPermissions|null $user |
||||
|
* |
||||
|
* @return bool |
||||
|
*/ |
||||
|
protected function authorize($user): bool |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue