Browse Source

配置起送价

master
liangyuyan 5 years ago
parent
commit
6338d116fc
  1. 26
      app/Admin/Controllers/v3/SystemConfigController.php
  2. 10
      app/Admin/Forms/CategoryTieForm.php
  3. 10
      app/Admin/Forms/CouponTieForm.php
  4. 74
      app/Constants/v3/SsdbKeys.php

26
app/Admin/Controllers/v3/SystemConfigController.php

@ -8,9 +8,12 @@ use Dcat\Admin\Grid;
use Dcat\Admin\Show; use Dcat\Admin\Show;
use Dcat\Admin\Controllers\AdminController; use Dcat\Admin\Controllers\AdminController;
use App\Models\v3\SystemConfig as SystemConfigModel; use App\Models\v3\SystemConfig as SystemConfigModel;
use App\Libs\SsdbClient;
use App\Constants\v3\SsdbKeys;
class SystemConfigController extends AdminController class SystemConfigController extends AdminController
{ {
/** /**
* Make a grid builder. * Make a grid builder.
* *
@ -47,10 +50,15 @@ class SystemConfigController extends AdminController
protected function detail($id) protected function detail($id)
{ {
return Show::make($id, new SystemConfig(), function (Show $show) { return Show::make($id, new SystemConfig(), function (Show $show) {
$menuName = $show->model()->menu_name;
$show->field('id'); $show->field('id');
$show->field('menu_name'); $show->field('menu_name');
$show->field('category_text'); $show->field('category_text');
$show->field('value');
$show->field('value')->width(6);
if($menuName == 'initial_delivery_amount'){
$delivery = SsdbClient::client()->get(SsdbKeys::INTIAL_DELIVERY_AMOUNT);
$show->field('value_text','已存ssdb的值:')->width(6)->value($delivery);
}
$show->field('info'); $show->field('info');
$show->field('desc'); $show->field('desc');
$show->field('sort'); $show->field('sort');
@ -68,20 +76,32 @@ class SystemConfigController extends AdminController
protected function form() protected function form()
{ {
return Form::make(new SystemConfig(), function (Form $form) { return Form::make(new SystemConfig(), function (Form $form) {
$menuName = $form->model()->menu_name;
$form->hidden('id'); $form->hidden('id');
$form->text('menu_name')->width(4)->required()->rules('regex:/^[0-9a-z_]{1,}$/',['regex'=>'只能输入数字、小写字母和下划线'])->help('本字段在添加成功后不能编辑!'); $form->text('menu_name')->width(4)->required()->rules('regex:/^[0-9a-z_]{1,}$/',['regex'=>'只能输入数字、小写字母和下划线'])->help('本字段在添加成功后不能编辑!');
$form->select('category')->width(4)->options(SystemConfigModel::$_CATEGORY); $form->select('category')->width(4)->options(SystemConfigModel::$_CATEGORY);
$form->text('value')->required()->width(6)->maxLength(100);
$deliveryForm = $form->text('value')->required()->width(6)->maxLength(100);
if($menuName == 'initial_delivery_amount'){
$delivery = SsdbClient::client()->get(SsdbKeys::INTIAL_DELIVERY_AMOUNT);
$deliveryForm->help('已存ssdb的值:'.$delivery);
}
$form->text('info')->maxLength(255); $form->text('info')->maxLength(255);
$form->text('desc')->maxLength(500); $form->text('desc')->maxLength(500);
$form->number('sort')->width(2)->default(0); $form->number('sort')->width(2)->default(0);
$form->saving(function(Form $form){ $form->saving(function(Form $form){
$id = $form->input('id'); $id = $form->input('id');
if($id && $form->input('menu_name') ){
$menuName = $form->input('menu_name');
if($id && $menuName ){
$form->deleteInput('menu_name'); $form->deleteInput('menu_name');
} }
if($id && $menuName == 'initial_delivery_amount'){
$delivery = $form->input('value');
SsdbClient::client()->set(SsdbKeys::INTIAL_DELIVERY_AMOUNT,$delivery);
}
}); });
$form->switch('status') $form->switch('status')
->customFormat(function ($v) { ->customFormat(function ($v) {

10
app/Admin/Forms/CategoryTieForm.php

@ -10,9 +10,6 @@ use Illuminate\Support\Facades\DB;
class CategoryTieForm extends Form class CategoryTieForm extends Form
{ {
protected $ssdb;
/** /**
* Handle the form request. * Handle the form request.
* *
@ -37,9 +34,9 @@ class CategoryTieForm extends Form
if(count($data) > 0){ if(count($data) > 0){
$this->ssdb->client()->hclear('applet_index_category');
SsdbClient::client()->hclear('applet_index_category');
$category = $this->ssdb->client()->multi_hset('applet_index_category',$data);
$category = SsdbClient::client()->multi_hset('applet_index_category',$data);
if($category === false){ if($category === false){
return $this->error('绑定失败'); return $this->error('绑定失败');
@ -55,8 +52,7 @@ class CategoryTieForm extends Form
*/ */
public function form() public function form()
{ {
$this->ssdb = new SsdbClient();
$category = $this->ssdb->client()->hgetall('applet_index_category');
$category = SsdbClient::client()->hgetall('applet_index_category');
$select = array_keys($category); $select = array_keys($category);
// 只查一级 // 只查一级

10
app/Admin/Forms/CouponTieForm.php

@ -8,11 +8,6 @@ use App\Libs\SsdbClient;
class CouponTieForm extends Form class CouponTieForm extends Form
{ {
/**
*
*/
protected $ssdb;
/** /**
* Handle the form request. * Handle the form request.
* *
@ -29,7 +24,7 @@ class CouponTieForm extends Form
'repay' => $input['repay'], 'repay' => $input['repay'],
]; ];
$coupon = $this->ssdb->client()->multi_hset('coupon_rebate_activity',$data);
$coupon = SsdbClient::client()->multi_hset('coupon_rebate_activity',$data);
if($coupon === false){ if($coupon === false){
return $this->error('修改失败'); return $this->error('修改失败');
} }
@ -42,8 +37,7 @@ class CouponTieForm extends Form
*/ */
public function form() public function form()
{ {
$this->ssdb = new SsdbClient();
$coupon = $this->ssdb->client()->hgetall('coupon_rebate_activity');
$coupon = SsdbClient::client()->hgetall('coupon_rebate_activity');
if(empty($coupon)){ if(empty($coupon)){
$coupon = [ $coupon = [
'activity'=> 0, 'activity'=> 0,

74
app/Constants/v3/SsdbKeys.php

@ -0,0 +1,74 @@
<?php
namespace App\Constants\v3;
/**
* @Constants
*/
class SsdbKeys
{
/**
* @Message("短信验证码")
*/
const VERIFY_CODE = 'verify_code_';
/**
* @Message("商品月销")
*/
const GOODS_MONTH_SALES = 'goods_m_sales_';
/**
* @Message("商户月销")
*/
const STORE_MONTH_SALES = 'store_m_sales_';
/**
* @Message("收藏店铺")
*/
const COLLECT_STORE_USER = 'collect_store_user_';
/**
* @Message("用户收藏店铺数量")
*/
const COUNT_COLLECT_STORE_USER = 'count_collect_store_user_';
/**
* @Message("店铺被收藏数量")
*/
const COUNT_COLLECT_STORE = 'count_collect_store_';
/**
* @Message("首页分类")
*/
const APPLET_INDEX_CATEGORY = 'applet_index_category';
/**
* @Message("用户信息")
*/
const USER_INFO = 'user_info_';
/**
* @Message("用户活动商品限购记录")
*/
const ACTIVITY_GOODS_BUY_RECORD = 'activity_goods_buy_record_';
/**
* @Message("优惠券返券活动")
*/
const COUPON_REBATE_ACTIVITY = 'coupon_rebate_activity';
/**
* @Message("优惠券返券领券")
*/
const COUPON_REBATE_RECEIVE = 'coupon_rebate_receive_';
/**
* @Message("优惠券返券列表")
*/
const COUPON_REBATE_LIST = 'coupon_rebate_list_';
/**
* @Message("起送价")
*/
const INTIAL_DELIVERY_AMOUNT = 'intial_delivery_amount';
}
Loading…
Cancel
Save