Browse Source

checkredis

yuenan
娄梦宁 3 years ago
parent
commit
b0ee6c7129
5 changed files with 161 additions and 111 deletions
  1. +39
    -4
      addons/unishop/controller/Order.php
  2. +2
    -2
      addons/unishop/controller/Product.php
  3. +12
    -9
      application/admin/controller/unishop/Order.php
  4. +19
    -19
      application/admin/view/unishop/order/index.html
  5. +89
    -77
      public/assets/js/backend/unishop/order.js

+ 39
- 4
addons/unishop/controller/Order.php View File

@@ -10,6 +10,7 @@
namespace addons\unishop\controller;

use addons\unishop\extend\Hashids;
use addons\unishop\extend\Snowflake;
use addons\unishop\model\Area;
use addons\unishop\model\Config;
use addons\unishop\model\Evaluate;
@@ -129,11 +130,45 @@ class Order extends Base
public function submit()
{
$data = $this->request->post();
$order = new \addons\unishop\model\Order();
$out_trade_no = date('Ymd',time()).uniqid()."1";
$snowflake = new Snowflake();
$id = $snowflake->id();
$productId = \addons\unishop\extend\Hashids::decodeHex($data["product_id"]);
$products = Db::name('unishop_product')
->where(['id' =>$productId , 'switch' => Product::SWITCH_ON])
->find();

$specs = explode(',', $data['spec']);
foreach ($specs as &$spec) {
$spec = str_replace('|', ',', $spec);
}
$productInfo = (new \addons\unishop\extend\Product())->getBaseData($products, $specs[0] ? $specs[0] : '');
$price = $productInfo["sales_price"]*$data["number"];
$order->save([
'id' => $id,
// 'user_id' => $userId,
'out_trade_no' => $out_trade_no,
'order_price' => $price,
'total_price' => $price,
'ip' => $_SERVER['REMOTE_ADDR'] ?? '',
'remark' => $data['remark'] ?? '',
'status' => $order::STATUS_NORMAL,
'product_id'=>$productId,
'name'=>$data["name"],
'mobile'=>$data["mobile"],
'address'=>$data["address"],
'email'=>$data["email"],
"spec"=>$data["spec"],
]);
$this->success('', []);
return ;

try {
$validate = Loader::validate('\\addons\\unishop\\validate\\Order');
if (!$validate->check($data, [], 'submit')) {
throw new Exception($validate->getError());
}
// $validate = Loader::validate('\\addons\\unishop\\validate\\Order');
// if (!$validate->check($data, [], 'submit')) {
// throw new Exception($validate->getError());
// }

Db::startTrans();



+ 2
- 2
addons/unishop/controller/Product.php View File

@@ -12,7 +12,7 @@ use think\Exception;

class Product extends Base
{
protected $noNeedLogin = ['detail', 'lists'];
protected $noNeedLogin = ['detail', 'lists',"evaluate"];

/**
* 获取产品数据
@@ -206,7 +206,7 @@ class Product extends Base
$evaluate = (new Evaluate)->alias('e')
->join('user u', 'e.user_id = u.id')
->where(['e.product_id' => $productId])
->field('u.username,u.avatar,e.*')
->field('e.*')
->order(['toptime' => 'desc', 'createtime' => 'desc'])
->page($page, $pageSize)
->select();


+ 12
- 9
application/admin/controller/unishop/Order.php View File

@@ -53,30 +53,33 @@ class Order extends Backend
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->alias('order')
->join('user', 'user.id = order.user_id')
->join('unishop_product', 'unishop_product.id = order.product_id')
// ->join('user', 'user.id = order.user_id')
->where($where)
->count();

$list = $this->model
->alias('order')
->join('user', 'user.id = order.user_id')
// ->join('user', 'user.id = order.user_id')
->join('unishop_product', 'unishop_product.id = order.product_id')
->where($where)
->order($sort, $order)
->limit($offset, $limit)
->field('order.*,user.username')
->field('unishop_product.title,order.*')
->select();

$list = collection($list)->toArray();
foreach ($list as &$item) {
$item['id'] = (string)$item['id']; // 整形数字太大js会失准
$item['user'] = [];
$item['user']['username'] = $item['username'] ? $item['username'] : __('Tourist');
// $item['user'] = [];
// $item['user']['username'] = $item['username'] ? $item['username'] : __('Tourist');

$item['have_paid_status'] = $item['have_paid'];
$item['have_delivered_status'] = $item['have_delivered'];
$item['have_received_status'] = $item['have_received'];
$item['have_commented_status'] = $item['have_commented'];
// $item['have_paid_status'] = $item['have_paid'];
// $item['have_delivered_status'] = $item['have_delivered'];
// $item['have_received_status'] = $item['have_received'];
// $item['have_commented_status'] = $item['have_commented'];
}

$result = array("total" => $total, "rows" => $list);
return json($result);
}


+ 19
- 19
application/admin/view/unishop/order/index.html View File

@@ -1,14 +1,14 @@
<div class="panel panel-default panel-intro">

<div class="panel-heading">
{:build_heading(null,FALSE)}
<ul class="nav nav-tabs" data-field="status">
<li class="active"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li>
{foreach name="statusList" item="vo"}
<li><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li>
{/foreach}
</ul>
</div>
<!-- <div class="panel-heading">-->
<!-- {:build_heading(null,FALSE)}-->
<!-- <ul class="nav nav-tabs" data-field="status">-->
<!-- <li class="active"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li>-->
<!-- {foreach name="statusList" item="vo"}-->
<!-- <li><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li>-->
<!-- {/foreach}-->
<!-- </ul>-->
<!-- </div>-->


<div class="panel-body">
@@ -18,19 +18,19 @@
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<!-- <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('unishop/order/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>-->
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('unishop/order/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('unishop/order/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<!-- <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('unishop/order/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>-->
<!-- <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('unishop/order/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>-->
<!-- <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('unishop/order/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>-->

<div class="dropdown btn-group {:$auth->check('unishop/order/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
</ul>
</div>
<!-- <div class="dropdown btn-group {:$auth->check('unishop/order/multi')?'':'hide'}">-->
<!-- <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->
<!-- <ul class="dropdown-menu text-left" role="menu">-->
<!-- <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>-->
<!-- <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>-->
<!-- </ul>-->
<!-- </div>-->

<a class="btn btn-success btn-recyclebin btn-dialog {:$auth->check('unishop/order/recyclebin')?'':'hide'}" href="unishop/order/recyclebin" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> {:__('Recycle bin')}</a>
<!-- <a class="btn btn-success btn-recyclebin btn-dialog {:$auth->check('unishop/order/recyclebin')?'':'hide'}" href="unishop/order/recyclebin" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> {:__('Recycle bin')}</a>-->
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('unishop/order/edit')}"


+ 89
- 77
public/assets/js/backend/unishop/order.js View File

@@ -83,31 +83,36 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
[ {checkbox: true},
{field: 'id', title: __('Id'),visible:false},
{field: 'user_id', title: __('User_id')},
{field: 'user.username', title: __('User name')},

{field: 'name', title: __('姓名'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
{field: 'mobile', title: __('手机号'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
{field: 'email', title: __('邮箱'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
{field: 'address', title: __('地址'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
{field: 'title', title: __('商品')},
{field: 'spec', title: __('规格')},
// {field: 'user_id', title: __('User_id')},
// {field: 'user.username', title: __('User name')},
{field: 'out_trade_no', title: __('Out_trade_no')},
{field: 'order_price', title: __('Order_price'), operate:'BETWEEN'},
{field: 'discount_price', title: __('Discount_price'), operate:'BETWEEN'},
{field: 'delivery_price', title: __('Delivery_price'), operate:'BETWEEN'},
// {field: 'discount_price', title: __('Discount_price'), operate:'BETWEEN'},
// {field: 'delivery_price', title: __('Delivery_price'), operate:'BETWEEN'},
{field: 'total_price', title: __('Total_price'), operate:'BETWEEN'},
{field: 'status', title: __('Status'), searchList: {"-1":__('Refund'),"0":__('Cancel'),"1":__('Normal')}, formatter: Table.api.formatter.status},
{field: 'pay_type', title: __('Pay_type'), searchList: {"1":__('Online'),"2":__('Offline'),"3":__('wxPay'),"4":__('aliPay')}, formatter: Table.api.formatter.normal},
// {field: 'pay_type', title: __('Pay_type'), searchList: {"1":__('Online'),"2":__('Offline'),"3":__('wxPay'),"4":__('aliPay')}, formatter: Table.api.formatter.normal},
{field: 'ip', title: __('Ip'), visible:false},
{field: 'have_paid_status', title: __('Have_paid'), searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
{field: 'have_delivered_status', title: __('Have_delivered'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
{field: 'have_received_status', title: __('Have_received'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
{field: 'have_commented_status', title: __('Have_commented'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
{field: 'refund_status', title: __('Refund status'),searchList: {"0":__('None'),"1":__('Apply'),"2":__('Waiting for shipment'),"3":__('Pass'),"4":__('Refuse')}, formatter: Table.api.formatter.status},
{field: 'have_paid', title: __('Pay time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
{field: 'have_delivered', title: __('Delivered time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
{field: 'have_received', title: __('Received time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
{field: 'have_commented', title: __('Commented time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
{field: 'status', title: __('Status'), searchList: {"-1":__('Refund'),"0":__('Cancel'),"1":__('Normal')}, formatter: Table.api.formatter.status},
// {field: 'have_paid_status', title: __('Have_paid'), searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
// {field: 'have_delivered_status', title: __('Have_delivered'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
// {field: 'have_received_status', title: __('Have_received'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
// {field: 'have_commented_status', title: __('Have_commented'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
// {field: 'refund_status', title: __('Refund status'),searchList: {"0":__('None'),"1":__('Apply'),"2":__('Waiting for shipment'),"3":__('Pass'),"4":__('Refuse')}, formatter: Table.api.formatter.status},
// {field: 'have_paid', title: __('Pay time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
// {field: 'have_delivered', title: __('Delivered time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
// {field: 'have_received', title: __('Received time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
// {field: 'have_commented', title: __('Commented time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'remark', title: __('Remark'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
{
field: 'operate',
title: __('Operate'),
@@ -115,35 +120,35 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
events: Table.api.events.operate,
formatter: Table.api.formatter.operate,
buttons:[
{
name: 'refund',
text: __('Refund'),
classname: 'btn btn-xs btn-info btn-refund',
extend: 'data-toggle="tooltip"',
icon: 'fa fa-handshake-o'
},
{
name: 'delivere',
text: __('Delivere'),
classname: 'btn btn-xs btn-info btn-delivere',
extend: 'data-toggle="tooltip"',
icon: 'fa fa-plane'
},
{
name: 'product',
text: __('Product'),
classname: 'btn btn-xs btn-info btn-product',
extend: 'data-toggle="tooltip"',
icon: 'fa fa-star-half'
},
{
name: 'edit',
icon: 'fa fa-pencil',
text: __('Edit'),
extend: 'data-toggle="tooltip"',
classname: 'btn btn-xs btn-success btn-editone',
url: $.fn.bootstrapTable.defaults.extend.edit_url
}
// {
// name: 'refund',
// text: __('Refund'),
// classname: 'btn btn-xs btn-info btn-refund',
// extend: 'data-toggle="tooltip"',
// icon: 'fa fa-handshake-o'
// },
// {
// name: 'delivere',
// text: __('Delivere'),
// classname: 'btn btn-xs btn-info btn-delivere',
// extend: 'data-toggle="tooltip"',
// icon: 'fa fa-plane'
// },
// {
// name: 'product',
// text: __('Product'),
// classname: 'btn btn-xs btn-info btn-product',
// extend: 'data-toggle="tooltip"',
// icon: 'fa fa-star-half'
// },
// {
// name: 'edit',
// icon: 'fa fa-pencil',
// text: __('Edit'),
// extend: 'data-toggle="tooltip"',
// classname: 'btn btn-xs btn-success btn-editone',
// url: $.fn.bootstrapTable.defaults.extend.edit_url
// }
]
}
]
@@ -172,25 +177,32 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[
{checkbox: true},
{field: 'id', title: __('Id'),visible:false},
{field: 'user_id', title: __('User_id')},
{field: 'user.username', title: __('User name')},

{field: 'name', title: __('姓名'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
{field: 'mobile', title: __('手机号'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
{field: 'email', title: __('邮箱'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
{field: 'address', title: __('地址'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
{field: 'product_name', title: __('商品')},
{field: 'spec', title: __('规格')},
// {field: 'user_id', title: __('User_id')},
// {field: 'user.username', title: __('User name')},
{field: 'out_trade_no', title: __('Out_trade_no')},
{field: 'order_price', title: __('Order_price'), operate:'BETWEEN'},
{field: 'discount_price', title: __('Discount_price'), operate:'BETWEEN'},
{field: 'delivery_price', title: __('Delivery_price'), operate:'BETWEEN'},
// {field: 'discount_price', title: __('Discount_price'), operate:'BETWEEN'},
// {field: 'delivery_price', title: __('Delivery_price'), operate:'BETWEEN'},
{field: 'total_price', title: __('Total_price'), operate:'BETWEEN'},
{field: 'pay_type', title: __('Pay_type'), searchList: {"1":__('Online'),"2":__('Offline'),"3":__('wxPay'),"4":__('aliPay')}, formatter: Table.api.formatter.normal},
// {field: 'pay_type', title: __('Pay_type'), searchList: {"1":__('Online'),"2":__('Offline'),"3":__('wxPay'),"4":__('aliPay')}, formatter: Table.api.formatter.normal},
{field: 'ip', title: __('Ip'), visible:false},
{field: 'status', title: __('Status'), searchList: {"-1":__('Refund'),"0":__('Cancel'),"1":__('Normal')}, formatter: Table.api.formatter.status},
{field: 'have_paid_status', title: __('Have_paid'), searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
{field: 'have_delivered_status', title: __('Have_delivered'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
{field: 'have_received_status', title: __('Have_received'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
{field: 'have_commented_status', title: __('Have_commented'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
{field: 'refund_status', title: __('Refund status'),searchList: {"0":__('None'),"1":__('Apply'),"2":__('Waiting for shipment'),"3":__('Pass'),"4":__('Refuse')}, formatter: Table.api.formatter.status},
{field: 'have_paid', title: __('Pay time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
{field: 'have_delivered', title: __('Delivered time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
{field: 'have_received', title: __('Received time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
{field: 'have_commented', title: __('Commented time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
// {field: 'have_paid_status', title: __('Have_paid'), searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
// {field: 'have_delivered_status', title: __('Have_delivered'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
// {field: 'have_received_status', title: __('Have_received'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
// {field: 'have_commented_status', title: __('Have_commented'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
// {field: 'refund_status', title: __('Refund status'),searchList: {"0":__('None'),"1":__('Apply'),"2":__('Waiting for shipment'),"3":__('Pass'),"4":__('Refuse')}, formatter: Table.api.formatter.status},
// {field: 'have_paid', title: __('Pay time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
// {field: 'have_delivered', title: __('Delivered time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
// {field: 'have_received', title: __('Received time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
// {field: 'have_commented', title: __('Commented time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'remark', title: __('Remark'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
{
@@ -207,22 +219,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
table: table,
events: Table.api.events.operate,
buttons: [
{
name: 'Restore',
text: __('Restore'),
classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
icon: 'fa fa-rotate-left',
url: 'unishop/order/restore',
refresh: true
},
{
name: 'Destroy',
text: __('Destroy'),
classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
icon: 'fa fa-times',
url: 'unishop/order/destroy',
refresh: true
}
// {
// name: 'Restore',
// text: __('Restore'),
// classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
// icon: 'fa fa-rotate-left',
// url: 'unishop/order/restore',
// refresh: true
// },
// {
// name: 'Destroy',
// text: __('Destroy'),
// classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
// icon: 'fa fa-times',
// url: 'unishop/order/destroy',
// refresh: true
// }
],
formatter: Table.api.formatter.operate
}


Loading…
Cancel
Save