Browse Source

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

develop
lemon 4 years ago
parent
commit
c06b5c8ac9
  1. 12
      app/Admin/Repositories/MiniProgramDraft.php
  2. 12
      app/Admin/Repositories/MiniProgramList.php
  3. 12
      app/Admin/Repositories/MiniProgramTemplate.php
  4. 45
      app/AdminAgent/Controllers/OrderController.php
  5. 5
      app/AdminAgent/Controllers/WorkorderController.php
  6. 4
      app/AdminGuide/Controllers/WorkorderController.php
  7. 4
      app/AdminSupplier/Controllers/ProductController.php
  8. 4
      app/AdminSupplier/Controllers/WorkorderController.php
  9. 2
      app/Http/Controllers/Api/MessageController.php
  10. 2
      app/Http/Controllers/Api/OrderController.php
  11. 31
      app/Http/Controllers/Api/TestController.php
  12. 16
      app/Service/Admin/GlobalNoticeService.php
  13. 45
      public/js/workorder-notice.js
  14. 30
      resources/views/admin/filter/select.blade.php
  15. 6
      resources/views/admin/pages/workorder.blade.php

12
app/Admin/Repositories/MiniProgramDraft.php

@ -7,6 +7,7 @@ use Dcat\Admin\Repositories\Repository;
use EasyWeChat\Factory;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Facades\Cache;
/**
* 小程序草稿箱
@ -15,10 +16,7 @@ use Illuminate\Pagination\LengthAwarePaginator;
*/
class MiniProgramDraft extends Repository
{
public function getPrimaryKeyColumn()
{
return 'draft_id';
}
protected $keyName = 'draft_id';
/**
* 查询表格数据
@ -37,6 +35,10 @@ class MiniProgramDraft extends Repository
'aes_key' => $setting['service_aeskey'],
];
$cache_key = 'mini_program:draft_list';
if ($data['subjects'] = Cache::get($cache_key)) {
$data['total'] = count($data['subjects']);
} else {
$openPlatform = Factory::openPlatform($config);
$codeTemplate = $openPlatform['code_template'];
@ -46,6 +48,8 @@ class MiniProgramDraft extends Repository
} else {
$data['total'] = count($list['draft_list']);
$data['subjects'] = $list['draft_list'] ?? [];
Cache::put($cache_key, $list['draft_list'], 120);
}
}
return $model->makePaginator(

12
app/Admin/Repositories/MiniProgramList.php

@ -7,6 +7,7 @@ use Dcat\Admin\Repositories\Repository;
use EasyWeChat\Factory;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Facades\Cache;
/**
* 小程序草稿箱
@ -15,10 +16,7 @@ use Illuminate\Pagination\LengthAwarePaginator;
*/
class MiniProgramList extends Repository
{
public function getPrimaryKeyColumn()
{
return '';
}
protected $keyName = 'id';
/**
* 查询表格数据
@ -37,6 +35,10 @@ class MiniProgramList extends Repository
'aes_key' => $setting['service_aeskey'],
];
$cache_key = 'mini_program:list';
if ($data['subjects'] = Cache::get($cache_key)) {
$data['total'] = count($data['subjects']);
} else {
$openPlatform = Factory::openPlatform($config);
$codeTemplate = $openPlatform['code_template'];
@ -46,6 +48,8 @@ class MiniProgramList extends Repository
} else {
$data['total'] = count($list['list']);
$data['subjects'] = $list['list'] ?? [];
Cache::put($cache_key, $list['list'], 120);
}
}
return $model->makePaginator(

12
app/Admin/Repositories/MiniProgramTemplate.php

@ -7,6 +7,7 @@ use Dcat\Admin\Repositories\Repository;
use EasyWeChat\Factory;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Facades\Cache;
/**
* 小程序模板
@ -15,10 +16,7 @@ use Illuminate\Pagination\LengthAwarePaginator;
*/
class MiniProgramTemplate extends Repository
{
public function getPrimaryKeyColumn()
{
return 'template_id';
}
protected $keyName = 'template_id';
/**
* 查询表格数据
@ -37,6 +35,10 @@ class MiniProgramTemplate extends Repository
'aes_key' => $setting['service_aeskey'],
];
$cache_key = 'mini_program:template_list';
if ($data['subjects'] = Cache::get($cache_key)) {
$data['total'] = count($data['subjects']);
} else {
$openPlatform = Factory::openPlatform($config);
$codeTemplate = $openPlatform['code_template'];
@ -46,6 +48,8 @@ class MiniProgramTemplate extends Repository
} else {
$data['total'] = count($list['template_list']);
$data['subjects'] = $list['template_list'] ?? [];
Cache::put($cache_key, $list['template_list'], 120);
}
}
return $model->makePaginator(

45
app/AdminAgent/Controllers/OrderController.php

@ -12,9 +12,12 @@ use App\Models\Supplier;
use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\Filter\AbstractFilter;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Widgets\Dropdown;
use Dcat\Admin\Widgets\Table;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Storage;
class OrderController extends AdminController
@ -26,15 +29,15 @@ class OrderController extends AdminController
*/
protected function grid()
{
return Grid::make(new Order(['product']), function (Grid $grid) {
return Grid::make(new Order(['product.supplier:id,name']), function (Grid $grid) {
$grid->disableDeleteButton();
$grid->disableBatchDelete();
$grid->disableCreateButton();
$grid->disableRowSelector();
$grid->disableEditButton();
$grid->disableQuickEditButton(false);
$grid->quickSearch(['mobile', 'order_no', 'title'])
->placeholder('搜索手机号、订单号、产品名称')->width(20);
$grid->quickSearch(['id', 'mobile', 'order_no', 'title'])
->placeholder('搜索ID、手机号、订单号、产品名称')->width(25);
$grid->model()->where('agent_id', Admin::user()->id);
@ -112,15 +115,32 @@ class OrderController extends AdminController
$grid->filter(function (Grid\Filter $filter) {
$filter->panel();
$filter->expand();
$filter->equal('id')->width(2);
$filter->like('mobile')->width(2);
$filter->like('order_no')->width(3);
$filter->like('title')->width(3);
$filter->equal('status')->select(OrderStatus::array())->width(2);
//自定义过滤器
$filter->extend('statusIn', new class ($column = null, $label = '') extends AbstractFilter {
protected $query = 'whereIn';
protected $width = 2;
public function condition($inputs)
{
$value = Arr::get($inputs, $this->column);
if ($value === null) {
return;
}
$this->value = is_array($value) ? $value : explode(',', $value);
return $this->buildCondition($this->column, $this->value);
}
});
$option = Supplier::query()->pluck('name', 'id');
$filter->equal('product.supplier_id', '供应商')->select($option)->width(3);
$filter->statusIn('status')->select([
join(',', [OrderStatus::UNPAID, OrderStatus::PAY_EARNEST]) => '待付款',
join(',', [OrderStatus::PAID, OrderStatus::OFFLINE_PAID, OrderStatus::PAID_RETAINAGE]) => '已付款',
OrderStatus::CANCEL => '已取消',
OrderStatus::SUCCESS => '已完成',
OrderStatus::REFUNDING => '退款中',
OrderStatus::REFUNDED => '已退款',
OrderStatus::REFUSED_REFUND => '已拒绝',
])->width(2);
$filter->between('created_at')->datetime()->width(4);
});
@ -201,7 +221,10 @@ class OrderController extends AdminController
if ($form->status !== null) {
if (in_array($form->status, [OrderStatus::REFUNDED, OrderStatus::REFUSED_REFUND])) {
return $form->response()->error('请通过订单列表的”通过“和”拒绝“按钮来审核退款');
} else if ($form->status != OrderStatus::OFFLINE_PAID) {
} else if ($form->status == OrderStatus::OFFLINE_PAID) {
$form->hidden('timeout');
$form->timeout = null; //清空超时时间
} else {
return $form->response()->error('操作禁止');
}
}

5
app/AdminAgent/Controllers/WorkorderController.php

@ -365,12 +365,7 @@ class WorkorderController extends AdminController
public function checkUnread()
{
if (\request('badge', '')) {
return (new GlobalNoticeService())->unreadWOrder(DemandTraits::$col[0], true);
} else {
return (new GlobalNoticeService())->unreadWOrder(DemandTraits::$col[0]);
}
}
}

4
app/AdminGuide/Controllers/WorkorderController.php

@ -328,10 +328,6 @@ class WorkorderController extends AdminController
public function checkUnread()
{
if (\request('badge', '')) {
return (new GlobalNoticeService())->unreadWOrder(DemandTraits::$col[2], true);
} else {
return (new GlobalNoticeService())->unreadWOrder(DemandTraits::$col[2]);
}
}
}

4
app/AdminSupplier/Controllers/ProductController.php

@ -190,7 +190,7 @@ class ProductController extends AdminController
});
if ($form->isEditing()) {
$form->confirm('提示', '修改标题、价格、产品图片、旅游须知、产品详情需要重新审核,同时<span class="btn-danger">下架所有</span>关联的代理商产品,是否继续?');
$form->confirm('提示', '修改标题、价格、产品图片、旅游须知、产品详情、产品类型及信息需要重新审核,同时<span class="btn-danger">下架所有</span>关联的代理商产品,是否继续?');
}
})->saving(function (Form $form) {
//不允许编辑非自己数据
@ -225,7 +225,7 @@ class ProductController extends AdminController
DB::beginTransaction();
try {
//如果修改标题、价格、产品图片、旅游须知、产品详情,状态将变为未审核
if ($form->model()->wasChanged(['title', 'price', 'original_price', 'pictures', 'know', 'content'])) {
if ($form->model()->wasChanged(['title', 'price', 'original_price', 'pictures', 'know', 'content', 'extends'])) {
$form->model()->update(['status' => ProductStatus::UNAUDITED]);
//下架所有代理商产品,未审核的产品,不能同步信息到代理商产品

4
app/AdminSupplier/Controllers/WorkorderController.php

@ -330,10 +330,6 @@ class WorkorderController extends AdminController
public function checkUnread()
{
if (\request('badge', '')) {
return (new GlobalNoticeService())->unreadWOrder(DemandTraits::$col[1], true);
} else {
return (new GlobalNoticeService())->unreadWOrder(DemandTraits::$col[1]);
}
}
}

2
app/Http/Controllers/Api/MessageController.php

@ -19,7 +19,7 @@ class MessageController extends Controller
$list = Message::query()->where('agent_id', $this->agent_id)
->whereIn('user_id', [$this->user_id, 0]) //0是所有人都接收的系统消息
->select('id', 'title', 'created_at')
->selectRaw('IF(( SELECT 1 FROM `message_reads` AS `mr` WHERE mr.id = messages.id AND mr.user_id = messages.user_id ), 1, 0) AS `is_read`')
->selectRaw('IF((SELECT 1 FROM `message_reads` AS `mr` WHERE mr.id = messages.id AND mr.user_id = ' . $this->user_id . '), 1, 0) AS `is_read`')
->orderBy('id', 'DESC')
->simplePaginate(15);

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

@ -86,7 +86,9 @@ class OrderController extends Controller
Status::OFFLINE_UNPAID => '线下付款',
Status::PAY_EARNEST => '付尾款',
];
if (isset($text_arr[$v['status']])) {
$v['status_text'] = '请在' . ceil($second / 60) . "分钟内" . ($text_arr[$v['status']] ?? '付款');
}
} else if ($second < 0 && $v['status'] == Status::PAY_EARNEST) {
$v['status_text'] = '尾款支付已超时';
} /*else { //此部分由定时处理

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

@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api;
use App\Models\Order;
use App\Models\OrderProductItem;
use App\Models\Product;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
/**
@ -14,26 +15,24 @@ use Illuminate\Support\Facades\DB;
*/
class TestController
{
/*public function index()
public function index()
{
//test
$ids = Order::orderBy('id')->get(['id AS order_id', 'product_ids', 'agent_id', 'agent_product_id']);
foreach ($ids as $v) {
$item = Product::query()->whereIn('id', explode(',', $v['product_ids']))
->orderBy('id')->get(['id AS product_id', 'supplier_id'])->toArray();
foreach ($item as $v2) {
if (!OrderProductItem::query()->where(['order_id' => $v['order_id'], 'product_id' => $v2['product_id']])->exists()) {
$v2['order_id'] = $v['order_id'];
$v2['agent_id'] = $v['agent_id'];
$v2['agent_product_id'] = $v['agent_product_id'];
OrderProductItem::query()->create($v2);
}
return $this->login(2);
}
/**
* 模拟登录
* @param $user_id
* @return string
*/
private function login($user_id)
{
$token_key = md5($user_id . env('APP_KEY'));
Cache::put($token_key, $user_id);
return $token_key;
}
return '';
}*/
public function index()
public function index2()
{
$handle = fopen(base_path('area.txt'), 'r');
if ($handle) {

16
app/Service/Admin/GlobalNoticeService.php

@ -15,7 +15,7 @@ use Illuminate\Support\Facades\DB;
*/
class GlobalNoticeService
{
public function unreadWOrder($pointType, $isBadge = false)
public function unreadWOrder($pointType)
{
$cacheNotice = Cache::get('w_order_notice', '[]');
@ -27,19 +27,19 @@ class GlobalNoticeService
$query->where('point_id',Admin::user()->id)
->where('point_type',$pointType);
})
->where('is_read', 0)
->whereIn('id', $cacheNoticeIds);
->where('is_read', 0);
if ($isBadge === true) {
return $builder->count();
}
$count = $builder->count();
$res = $builder->pluck('id')
$res = $builder
->whereIn('id', $cacheNoticeIds)
->pluck('id')
->toArray();
$cacheNoticeIds = array_diff($cacheNoticeIds, $res);
Cache::forever('w_order_notice', json_encode($cacheNoticeIds));
return empty($res) ? 0 : 1;
$notice = empty($res) ? 0 : 1;
return json_encode(['notice' => $notice, 'badge' => $count]);
}
public function cacheWOrderNotice($id)

45
public/js/workorder-notice.js

@ -1,12 +1,16 @@
const workordertimer = setInterval(function () {
function workorderNotice()
{
$.ajax({
url: '/'+window.location.pathname.split('/')[1]+'/workorder_notice',
type: 'POST',
data: {},
dataType: 'text',
dataType: 'json',
success: function (res) {
if (res == true) {
let notice = res.notice ? res.notice : '';
let badge = res.badge ? res.badge : '';
if (notice == 1) {
Dcat.info("你有新的工单信息 <a href='/"+window.location.pathname.split('/')[1]+"/workorder_item' target='_blank'>[前往查看]</a>", '新消息提醒', {
closeButton: true,
escapeHtml: false,
@ -19,21 +23,10 @@ const workordertimer = setInterval(function () {
}
})
}
},
error: function (error) {
}
});
$.ajax({
url: '/'+window.location.pathname.split('/')[1]+'/workorder_notice',
type: 'POST',
data: {badge: 1},
dataType: 'text',
success: function (res) {
if (res > 0) {
if (badge > 0) {
if ($('a[href*="workorder_item"] p .workorder_badge').length > 0) {
$('a[href*="workorder_item"] p .workorder_badge').text(res);
$('a[href*="workorder_item"] p .workorder_badge').text(badge);
} else {
$('a[href*="workorder_item"] p').append('<span class="workorder_badge" style="' +
'display: inline-block; ' +
@ -45,11 +38,11 @@ const workordertimer = setInterval(function () {
'font-size: 12px; ' +
'background-color: red;' +
'color: white;' +
'">'+res+'</span>');
'">'+badge+'</span>');
}
if ($('a[href*="workorder_item"]').parent().parent().parent(':not(.menu-open)').find('a[href="#"] p .workorder_badge').length > 0) {
$('a[href*="workorder_item"]').parent().parent().parent(':not(.menu-open)').find('a[href="#"] p .workorder_badge').text(res);
$('a[href*="workorder_item"]').parent().parent().parent(':not(.menu-open)').find('a[href="#"] p .workorder_badge').text(badge);
} else {
$('a[href*="workorder_item"]').parent().parent().parent(':not(.menu-open)').find('a[href="#"] p').append('<span class="workorder_badge" style="' +
'display: inline-block; ' +
@ -61,13 +54,23 @@ const workordertimer = setInterval(function () {
'font-size: 12px; ' +
'background-color: red;' +
'color: white;' +
'">' + res + '</span>');
'">' + badge + '</span>');
}
} else {
$('a[href*="workorder_item"] p .workorder_badge').remove()
$('a[href*="workorder_item"]').parent().parent().parent(':not(.menu-open)').find('a[href="#"] p .workorder_badge').remove()
}
},
error: function (error) {
}
});
}
$(document).ready(function () {
workorderNotice();
});
}, 1000);
const workordertimer = setInterval(function () {
workorderNotice()
}, 5000);

30
resources/views/admin/filter/select.blade.php

@ -0,0 +1,30 @@
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text bg-white text-capitalize"><b>{!! $label !!}</b></span>
</div>
<select class="form-control {{ $class }}" name="{{$name}}" data-value="{{ is_array($value) ? join(',', $value) : '' }}" style="width: 100%;">
<option value=""></option>
@foreach($options as $select => $option)
<option value="{{$select}}" {{ Dcat\Admin\Support\Helper::equal($select, is_array($value) ? join(',', $value) : '') ?'selected':'' }}>{{$option}}</option>
@endforeach
</select>
</div>
@include('admin::scripts.select')
<script require="@select2?lang={{ config('app.locale') === 'en' ? '' : str_replace('_', '-', config('app.locale')) }}">
var configs = {!! admin_javascript_json($configs) !!};
@yield('admin.select-ajax')
@if(isset($remote))
$.ajax({!! admin_javascript_json($remote['ajaxOptions']) !!}).done(function(data) {
$("{{ $selector }}").select2($.extend({!! admin_javascript_json($configs) !!}, {
data: data,
})).val({!! json_encode($remote['values']) !!}).trigger("change");
});
@else
$("{!! $selector !!}").select2(configs);
@endif
</script>

6
resources/views/admin/pages/workorder.blade.php

@ -103,7 +103,7 @@
@if($item['it_type'] == 1)
{{$item['content']}}
@elseif($item['it_type'] == 2)
<img class="msg-content-image" onclick="viewImage(this)" src="{{$item['content']}}" alt="图片" title="图片" />
<img class="msg-content-image" data-action="preview-img" src="{{$item['content']}}" alt="图片" title="图片" />
@endif
</div>
@ -131,7 +131,7 @@
@if($item['it_type'] == 1)
{{$item['content']}}
@elseif($item['it_type'] == 2)
<img class="msg-content-image" onclick="viewImage(this)" src="{{$item['content']}}" alt="图片" title="图片" />
<img class="msg-content-image" data-action="preview-img" src="{{$item['content']}}" alt="图片" title="图片" />
@endif
</div>
@ -224,7 +224,7 @@
let imageUrl = res.data.content
let msgTime = res.data.created_at
let templateHtml = $('.template-my').html()
let imgDoc = '<img class="msg-content-image" onclick="viewImage(this)" src="'+imageUrl+'" alt="图片" title="图片" />'
let imgDoc = '<img class="msg-content-image" data-action="preview-img" src="'+imageUrl+'" alt="图片" title="图片" />'
templateHtml = templateHtml.replace('#contents', imgDoc)
templateHtml = templateHtml.replace('#times', msgTime)
$(".msg-chat-list").append(templateHtml)

Loading…
Cancel
Save