Compare commits

...

13 Commits
main ... ymwl

Author SHA1 Message Date
lqmac 28ee20a475 1 1 year ago
lqmac 6b906b1b1f 1 1 year ago
lqmac 0d18c65ee6 单点 1 year ago
lqmac 5e5cd0c62c 1 1 year ago
lqmac 88a772aa19 redis锁 1 year ago
lqmac b26f0bd431 1 1 year ago
lqmac 29a858757d 加redis锁 1 year ago
lqmac 7e3949936f 1 1 year ago
lqmac a7db2d00ed 累计收益不累加的问题 1 year ago
lqmac 9879d074ae fix bug 1 year ago
lqmac b3562824ee 1 1 year ago
lqmac d22ea6071f fix bug 1 year ago
lqmac 6e5ebffa14 1 1 year ago
  1. 60
      application/admin/controller/Order.php
  2. 2
      application/admin/view/order/index.html
  3. 10
      application/api/controller/Index.php
  4. 159
      application/api/controller/Order.php
  5. 29
      application/api/controller/User.php
  6. 6
      application/common/library/Auth.php
  7. 18
      application/config.php
  8. 18
      public/assets/js/backend/order.js
  9. 21
      thinkphp/library/think/cache/driver/Redis.php

@ -6,6 +6,10 @@ use app\common\controller\Backend;
use app\admin\model\order\Detail;
use think\Db;
use think\Config;
use app\common\service\UserService;
use app\admin\model\Goods;
use app\admin\model\Order as OrderModel;
/**
*
*
@ -67,7 +71,7 @@ class Order extends Backend
->join('user user', 'user.id = order.buyer_id', 'left')
->join('user user1', 'user1.id = order.seller_id', 'left')
->join('order_detail detail', 'detail.order_id = order.id', 'left')
->field("count(order.id) as order_count,sum(order.order_amount) as order_amount,sum(order.coupon_price) as coupon_price,count(distinct order.buyer_id) as user_count")
->field("count(order.id) as order_count,sum(order.order_amount) as order_amount,sum(order.coupon_price) as coupon_price,sum(detail.dikou_price) as dikou_price,count(distinct order.buyer_id) as user_count")
->where($where)
->find();
// var_dump($single);
@ -76,15 +80,27 @@ class Order extends Backend
$coupon_price = $single['coupon_price'] ?? 0;
$order_count = $single['order_count'] ?? 0;
$user_count = $single['user_count'] ?? 0;
$dikou_price = $single['dikou_price'] ?? 0;
$users = Db::name('order')->field("buyer_id")->where('createtime', ">", strtotime(date("Y-m-d")))->group("buyer_id")->select();
// var_dump($users);
// exit();
$userIds = array_column($users, "buyer_id");
$beforeUsers = Db::name('order')->whereIn('buyer_id', $userIds)->field("buyer_id")->where('createtime', "<", strtotime(date("Y-m-d")))->group("buyer_id")->select();
$new_user_count = count($users) - count($beforeUsers);
// var_dump($userIds);
// exit();
$result = array(
"total" => $list->total(),
"rows" => $list->items(),
"extend" => [
'order_amount' => bcdiv($order_amount, 1, 2),
'coupon_price' => bcdiv($coupon_price, 1, 2),
'dikou_price' => bcdiv($dikou_price, 1, 2),
'order_count' => $order_count,
'user_count' => $user_count,
'new_user_count' => $new_user_count,
]
);
@ -123,5 +139,45 @@ class Order extends Backend
$this->view->assign("type", $type);
return $this->view->fetch();
}
public function cancel($ids = NULL){
$row = $this->model->get($ids);
// var_dump($row);
// exit;
if (!$row)
$this->error(__('No Results were found'));
if ($this->request->isPost()){
$params = $this->request->post("row/a");
$info = OrderModel::where('id', $ids)->update(['status' => -1,'cancel_time' => time()]);
if ($info === false) {
$this->error("取消失败");
}
$detail = Detail::where("order_id", $ids)->find();
if (!$detail)
$this->error(__('No Results were found'));
//上架商品
Goods::where('id', $detail['goods_id'])->update(['status' => 'normal', "updatetime" => time()]);
//分佣给买家上级
$site = Config::get("site");
$commission = bcmul($row->order_amount, $site['primary_distribution'] * 0.01, 2);
$user = Db::name('user')->where('id', $row->buyer_id)->find();
$obj = new UserService();
$ret = $obj->userCommission(1, $user, $row->order_sn, -$commission);
if(!$ret){
$this->error(__('Operation failed'));
}
return $this->success();
}
}
}

@ -17,7 +17,9 @@
订单数:<span id="order_count" style="color:red">0</span>
订单金额:<span id="order_amount" style="color:red">0</span>
优惠金额:<span id="coupon_price" style="color:red">0</span>
佣金抵扣金额:<span id="dikou_price" style="color:red">0</span>
购买人数:<span id="user_count" style="color:red">0</span>
新购人数:<span id="new_user_count" style="color:red">0</span>
</span>
</a>

@ -3,7 +3,7 @@
namespace app\api\controller;
use app\common\controller\Api;
use think\Db;
/**
* 首页接口
*/
@ -18,6 +18,14 @@ class Index extends Api
*/
public function index()
{
echo "111";
exit();
$list = Db::name('user')->where('status','normal')->select();
foreach ($list as $key => $value) {
$amount = Db::name('transaction_record')->where('type',2)->where('user_id', $value['id'])->sum('amount');
$ret = Db::name('user')->where('id', $value['id'])->update(['profit_amount' => $amount]);
var_dump($ret);
}
$this->success('请求成功');
}
}

@ -18,7 +18,7 @@ use Yansongda\Pay\Exceptions\GatewayException;
use app\admin\model\transaction\Record;
use think\Log;
use addons\shopro\traits\CouponSend;
use think\Cache;
/**
* 首页接口
*/
@ -27,7 +27,7 @@ class Order extends Api
use CouponSend;
protected $noNeedLogin = ['callback'];
protected $noNeedRight = ['*'];
const CACHE_TIME = 5;
/**
* 首页
*
@ -41,7 +41,7 @@ class Order extends Api
$this->success('succ');
}
$time = time();
foreach ($list as $key => $value) {
foreach ($list as $key => &$value) {
if ($value['id'] != $user['warehouse_id']) {
unset($list[$key]);
@ -52,7 +52,10 @@ class Order extends Api
if ($user['pid'] > 0) {
$value['is_allow_access'] = 1;
}
if (in_array($user['id'], [61])) {
$value['status'] ='normal';
$value['is_allow_access'] = 1;
}
}
$this->success('succ', array_values($list));
@ -120,30 +123,30 @@ class Order extends Api
*/
public function limitBuyNum($user, $warehouse){
$is_allow_access = 0;
//return $is_allow_access;
//是否在时间范围内
$start = strtotime($warehouse['start']);
$end = strtotime($warehouse['end']);
$start_date = date("Y-m-d H:i:s",$start);
$end_date = date("Y-m-d H:i:s", $end);
$code = $start."-".$end;
//仓库限制用户总抢购次数
$count = Db::name('user_access_record')->where('user_id', $user['id'])->where('warehouse_id', $warehouse['id'])->where('code', $code)->count();
if ($warehouse['limit_buy_num'] > 0 && $count > $warehouse['limit_buy_num']) {
$start_date = date("Y-m-d H:i",$start);
$end_date = date("Y-m-d H:i", $end);
$code = $start_date."-".$end_date;
//提前下单次数(买单)
$advance_count = OrderModel::where('buyer_id', $user['id'])->where('warehouse_id', $warehouse['id'])->where('code', $code)->where('is_advance', 1)->count();
if ($user['advance_access_num'] > 0 && $advance_count >= $user['advance_access_num']) {
$is_allow_access = 1;
return $is_allow_access;
}
//提前进入次数
$count = Db::name('user_access_record')->where('user_id', $user['id'])->where('warehouse_id', $warehouse['id'])->where('code', $code)->where('is_advance', 1)->count();
if ($user['advance_access_num'] > 0 && $count > $user['advance_access_num']) {
//正常下单次数(买单)
$normal_count = OrderModel::where('buyer_id', $user['id'])->where('warehouse_id', $warehouse['id'])->where('code', $code)->where('is_advance', 0)->count();
// var_dump($normal_count);
// exit();
if ($user['buy_goods_num_per_day'] > 0 && $normal_count >= $user['buy_goods_num_per_day']) {
$is_allow_access = 1;
return $is_allow_access;
}
//正常进入次数
$count = Db::name('user_access_record')->where('user_id', $user['id'])->where('warehouse_id', $warehouse['id'])->where('code', $code)->where('is_advance',0)->count();
if ($user['buy_goods_num_per_day'] > 0 && $count > $user['buy_goods_num_per_day']) {
$count = $advance_count + $normal_count;
//总下单次数
if ($warehouse['limit_buy_num'] > 0 && $count >= $warehouse['limit_buy_num']) {
$is_allow_access = 1;
return $is_allow_access;
}
@ -179,7 +182,6 @@ class Order extends Api
$this->error("区域不存在");
}
$is_allow_access = $this->limitBuyNum($user, $warehouse);
// $is_allow_access = $this->userIsAllowAccess($user, $warehouse, time());
if ($is_allow_access > 0 ) {
$this->error("抢购次数被限制");
}
@ -207,11 +209,10 @@ class Order extends Api
}
$user = $this->auth->getUserinfo();
$warehouse = Warehouse::where('id', $info['warehouse_id'])->find();
// $is_allow_access = $this->userIsAllowAccess($user, $warehouse, time());
// if ($is_allow_access == 0) {
// $this->error("不允许进入抢购");
// }
$warehouse = Warehouse::where('id', $info['warehouse_id'])->find();
$is_allow_access = $this->limitBuyNum($user, $warehouse);
if ($is_allow_access > 0 ) {
$this->error("抢购次数被限制");
}
$this->getBuyTime($warehouse, $user);
$owner = User::where('id', $info['owner_id'])->find();
$info['warehouse'] = $warehouse;
@ -219,13 +220,13 @@ class Order extends Api
$info['image'] = cdnurl($info['image'], true);
//写进入记录
$start = date("Y-m-d H:i:s", strtotime($warehouse['start']));
$end = date("Y-m-d H:i:s", strtotime($warehouse['end']));
$code = $start."-".$end;
$info1 = Db::name('user_access_record')->where('warehouse_id', $info['warehouse_id'])->where('user_id', $user['id'])->where('code', $code)->count();
if (!$info1) {
Db::name('user_access_record')->insert(['user_id' => $user['id'],'warehouse_id' => $info['warehouse_id'],'code' => $code, "createtime"=>time(), 'is_advance' => $user['advance_access_minute'] > 0 ? 1 : 0]);
}
// $start = date("Y-m-d H:i:s", strtotime($warehouse['start']));
// $end = date("Y-m-d H:i:s", strtotime($warehouse['end']));
// $code = $start."-".$end;
// $info1 = Db::name('user_access_record')->where('warehouse_id', $info['warehouse_id'])->where('user_id', $user['id'])->where('code', $code)->count();
// if (!$info1) {
// Db::name('user_access_record')->insert(['user_id' => $user['id'],'warehouse_id' => $info['warehouse_id'],'code' => $code, "createtime"=>time(), 'is_advance' => $user['advance_access_minute'] > 0 ? 1 : 0]);
// }
$this->success("succ", $info);
}
/**
@ -234,26 +235,51 @@ class Order extends Api
* @return [type] [description]
*/
public function createOrder(){
$address_id = $this->request->post("address_id", 0);
$goods_id = $this->request->post("goods_id", 0);
$num = $this->request->post("num", 1);
$coupon_id = $this->request->post("coupon_id", 0);
$user_id = $this->auth->id;
$user = $this->auth->getUserinfo();
//var_dump($user_id);
$address = Address::where('id', $address_id)->where('user_id', $user_id)->find();
if (!$address) {
$this->error("收货地址不存在");
}
$goods = Goods::where('id', $goods_id)->where('status','normal')->find();
if (!$goods) {
$this->error("商品不存在");
$this->error("商品已被抢完");
}
$warehouse = Warehouse::where('id', $goods['warehouse_id'])->find();
$this->getBuyTime($warehouse, $user);
if (time() < strtotime($warehouse['start'])) {
$this->error("抢购时间还没到!");
}
if (time() > strtotime($warehouse['end'])) {
$this->error("抢购时间已结束!");
}
$is_allow_access = $this->limitBuyNum($user, $warehouse);
if ($is_allow_access > 0) {
$this->error("抢购次数被限制");
}
//使用redis锁,限制下单
$lock_key = $this->request->domain()."_createOrder_".$goods_id;
$res = Cache::store('redis')->setnx($lock_key, 1);
if (!$res) {
$this->error("您的手速太慢了,商品已被抢!");
}
Cache::store('redis')->expire($lock_key, self::CACHE_TIME);
$order_amount = $goods['price'] * $num;
$coupon_price = 0;
$pay_amount = $order_amount - $coupon_price;
$order_sn = "ZH".date("YmdHis").rand(1000,9999);
$start = date("Y-m-d H:i", strtotime($warehouse['start']));
$end = date("Y-m-d H:i", strtotime($warehouse['end']));
$code = $start."-".$end;
//创建订单
$orderData = [
"buyer_id" => $user_id,
@ -270,6 +296,8 @@ class Order extends Api
"city" => $address['city_name'],
"district" => $address['district_name'],
"address" => $address['address'],
"is_advance" => $start > time() ? 1 : 0,
"code" => $code,
];
$order = OrderModel::create($orderData);
if ($order === false) {
@ -289,18 +317,17 @@ class Order extends Api
if ($ret === false) {
$this->error("下单失败");
}
//使用优惠卷
$ret = UserCouponModel::where("id", $coupon_id)->update(['use_order_id' => $order->id, 'use_time' => time()]);
if ($ret === false) {
$this->error("下单失败");
}
//更新商品状态为下架
Goods::where('id', $goods_id)->update(['status' => 'hidden', "updatetime" => time()]);
//分佣给买家上级
$site = Config::get("site");
$commission = bcmul($order_amount, $site['primary_distribution'] * 0.01, 2);
$obj = new UserService();
$obj->userCommission(0, $this->auth->getUserinfo(), $order_sn, $commission);
//更新商品状态为下架
Goods::where('id', $goods_id)->update(['status' => 'hidden', "updatetime" => time()]);
Cache::store('redis')->rm($lock_key);
$this->success("succ");
}
/**
@ -317,7 +344,7 @@ class Order extends Api
if ($status != "") {
$where['status'] = ['in', explode(",", $status)];
} else {
$where['status'] = ['in', [0,1,3,4,5,6]];
$where['status'] = ['in', [0,1,3,4,5]];
}
$list = OrderModel::where('seller_id', $user_id)->where($where)->order('id', 'desc')->paginate($this->request->param('list_rows', $limit))->each(function ($item, $key){
$order_goods = Detail::where('order_id', $item['id'])->select();
@ -348,13 +375,18 @@ class Order extends Api
if ($status != "") {
$where['status'] = ['in', explode(",", $status)];
} else {
$where['status'] = ['in', [0,1,2,3,4,5,6,7]];
$where['status'] = ['in', [0,1,2,3,4,5,7]];
}
$list = OrderModel::where('buyer_id', $user_id)->where($where)->order('id', 'desc')->paginate($this->request->param('list_rows', $limit))->each(function ($item, $key){
$order_goods = Detail::where('order_id', $item['id'])->select();
if ($order_goods) {
foreach ($order_goods as $key => $value) {
$value['goods_image'] = cdnurl($value['goods_image'], true);
if ($item['status'] == 7) {
$value['goods_price'] = $value['commission_price'];
$item['pay_amount'] = $value['commission_price'];
$item['order_amount'] = $value['commission_price'];
}
}
}
@ -391,7 +423,9 @@ class Order extends Api
$info['entrusted_ratio'] = Config::get("site.entrusted_ratio");
$info['entrustment_ratio'] = Config::get("site.entrustment_ratio");
$seller = User::where('id', $info['seller_id'])->field(['id', 'username', 'nickname', 'mobile', 'avatar', 'score','sign_image','sign_status','alipay_image','wechat_image','buy_goods_num_per_day','advance_access_num','bank_realname','bank_mobile','bank_no','bank_address','reason','warehouse_id','advance_access_minute','deadline','pid','total_commission_amount','available_commission_amount'])->find();
$buyer = User::where('id', $info['buyer_id'])->field(['id', 'username', 'nickname', 'mobile', 'avatar', 'score','sign_image','sign_status','alipay_image','wechat_image','buy_goods_num_per_day','advance_access_num','bank_realname','bank_mobile','bank_no','bank_address','reason','warehouse_id','advance_access_minute','deadline','pid','total_commission_amount','available_commission_amount'])->find();
$info['seller'] = $seller;
$info['buyer'] = $buyer;
$info['pay_voucher'] = cdnurl($info['pay_voucher'], true);
$this->success("succ", $info);
}
@ -436,11 +470,24 @@ class Order extends Api
$this->error("订单不存在");
}
$upData = ['updatetime' => time()];
if ($pay_voucher) {
if ($status == 1) {
$upData['pay_voucher'] = $pay_voucher;
$upData['pay_time'] = time();
$upData['pay_method'] = $pay_method;
$upData['status'] = $status;
$detail = Detail::where("order_id", $id)->find();
//更新该商品的最后一个已上架的订单为已完成
$single = Db::name('order')->alias('order')
->join('order_detail detail', 'detail.order_id = order.id', 'left')
->field("order.id")
->where("goods_id", $detail['goods_id'])
->where("status", 7)
->order("order.id desc")
->find();
if ($single) {
OrderModel::where('id', $single['id'])->update(['status' => 6, "updatetime" =>time()]);
}
} else {
$upData['status'] = $status;
}
@ -470,9 +517,11 @@ class Order extends Api
$user_id = $user['id'];
$goods = Detail::where('order_id', $order_id)->find();
if (!$goods) {
$order = OrderModel::where("id", $order_id)->where('status', 2)->find();
if (!$goods || !$order) {
$this->error("订单不存在");
}
//商品是否上架
$goods_info = Goods::where('id', $goods['goods_id'])->where('status', 'hidden')->find();
if (!$goods_info) {
@ -507,8 +556,8 @@ class Order extends Api
$this->error("优惠卷已过期");
}
$coupon_price = $coupon['amount'] ?? 0;
OrderModel::where("id", $order_id)->update(['coupon_id' => $coupon_id, 'coupon_price' => $coupon_price]);
}
OrderModel::where("id", $order_id)->update(['coupon_id' => $coupon_id, 'coupon_price' => $coupon_price]);
$pay_sn = "NO".date("YmdHis").rand(1000,9999);
$fee = bcmul($order_amount, Config::get("site.entrustment_ratio") * 0.01, 2);
$pay_amount = $fee - $coupon_price;
@ -538,6 +587,7 @@ class Order extends Api
// var_dump($order_data);
// var_dump($params);
// exit();
//是否使用佣金
if ($use_commission) {
if ($pay_amount < $user['available_commission_amount']) {
$order_data['pay_source'] = 0;//佣金支付
@ -551,7 +601,7 @@ class Order extends Api
$profit = $profit + $coupon_price + $pay_amount;
Record::create(["user_id" => $user_id, "type" => 2, "item_id" => $order_id,"amount"=> $profit]);
//修改用户可用佣金
User::where('id', $user_id)->update(['available_commission_amount' => $user['available_commission_amount'] - $pay_amount,"profit_amount" =>$profit, "updatetime" => time()]);
User::where('id', $user_id)->update(['available_commission_amount' => $user['available_commission_amount'] - $pay_amount,"profit_amount" =>$user['profit_amount'] + $profit, "updatetime" => time()]);
//更新订单信息
OrderModel::where("id", $order_id)->update(['status' => 7]);
Detail::where("order_id", $order_id)->update(['commission_price' => $goods_price, "fee" => $fee, "dikou_price" => $pay_amount]);
@ -580,6 +630,17 @@ class Order extends Api
Detail::where("order_id", $order_id)->update(['commission_price' => $goods_price, "fee" => $fee, "dikou_price" => $user['available_commission_amount']]);
}
} else {
//写微信支付
$order_data['pay_source'] = 1;//微信支付
$order_data['out_trade_no'] = $pay_sn;//微信支付
$order_data['pay_amount'] = $pay_amount;
Db::name("pay_record")->insert($order_data);
//修改微信支付信息
$params['amount'] = $order_data['pay_amount'];
$params['orderid'] = $pay_sn;
Detail::where("order_id", $order_id)->update(['commission_price' => $goods_price, "fee" => $fee, "dikou_price" => 0]);
}
//$params['amount'] = 0.01;
try {

@ -63,9 +63,10 @@ class User extends Api
if (!$account || !$password) {
$this->error(__('Invalid parameters'));
}
$site = Config::get("site");
$config = [
'app_id' => 'wx183e3fbc925f1ba3',
'secret' => 'b3e26edaa7642673dd98a951564e02c7',
'app_id' => $site['wx_appid'],
'secret' => $site['wx_secrect'],
// 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
'response_type' => 'array',
];
@ -166,10 +167,10 @@ class User extends Api
$extend['pid'] = $user->id;
}
}
// $ret = Sms::check($mobile, $code, 'register');
// if (!$ret) {
// $this->error(__('Captcha is incorrect'));
// }
$ret = Sms::check($mobile, $code, 'register');
if (!$ret) {
$this->error(__('Captcha is incorrect'));
}
$ret = $this->auth->register($username, $password, $email, $mobile, $extend);
if ($ret) {
$data = ['userinfo' => $this->auth->getUserinfo()];
@ -270,6 +271,16 @@ class User extends Api
if (isset($params['avatar']) && $params['avatar']) {
$upData['avatar'] = $params['avatar'];
}
if ((isset($params['bank_realname']) && $params['bank_realname'] ) || (isset($params['wechat_image']) && $params['wechat_image']) || (isset($params['alipay_image']) && $params['alipay_image'])) {
if (isset($params['code']) && $params['code']) {
$user = $this->auth->getUserinfo();
$ret = Sms::check($user['mobile'], $params['code'], 'notice');
if (!$ret) {
$this->error(__('Captcha is incorrect'));
}
}
}
if (!$upData) {
$this->success();
}
@ -541,8 +552,8 @@ class User extends Api
$user_ids = array_column($users, "id");
$data = [
'total_fans_order_amount' => order::whereIn('buyer_id', $user_ids)->whereIn('status', [0,1,2,3,4,5])->count(),
'today_fans_order_num' => order::whereIn('buyer_id', $user_ids)->whereIn('status', [0,1,2,3,4,5])->sum('order_amount'),
'total_fans_order_amount' => order::whereIn('buyer_id', $user_ids)->whereIn('status', [0,1,2,3,4,5,6,7])->sum('order_amount'),
'today_fans_order_num' => order::whereIn('buyer_id', $user_ids)->whereIn('status', [0,1,2,3,4,5,6,7])->count(),
];
$this->success("succ", $data);
}
@ -557,7 +568,7 @@ class User extends Api
$users = UserModel::where('pid', $this->auth->id)->select();
$user_ids = array_column($users, "id");
$list = order::whereIn('buyer_id', $user_ids)->whereIn('status', [0,1,2,3,4,5])->order('id', 'desc')->paginate($this->request->param('list_rows', $limit))->each(function ($item, $key){
$list = order::whereIn('buyer_id', $user_ids)->whereIn('status', [0,1,2,3,4,5,6,7])->order('id', 'desc')->paginate($this->request->param('list_rows', $limit))->each(function ($item, $key){
$order_goods = Detail::where('order_id', $item['id'])->select();
if ($order_goods) {
foreach ($order_goods as $key => $value) {

@ -182,7 +182,8 @@ class Auth
$user = User::create($params, true);
$this->_user = User::get($user->id);
//清除之前所有的Token
Token::clear($user->id);
//设置Token
$this->_token = Random::uuid();
Token::set($this->_token, $user->id, $this->keeptime);
@ -317,7 +318,8 @@ class Auth
$user->save();
$this->_user = $user;
//清除之前所有的Token
Token::clear($user->id);
$this->_token = Random::uuid();
Token::set($this->_token, $user->id, $this->keeptime);

@ -183,11 +183,23 @@ return [
// +----------------------------------------------------------------------
// | 缓存设置
// +----------------------------------------------------------------------
// 'cache' => [
// // 驱动方式
// 'type' => 'File',
// // 缓存保存目录
// 'path' => CACHE_PATH,
// // 缓存前缀
// 'prefix' => '',
// // 缓存有效期 0表示永久缓存
// 'expire' => 0,
// ],
'cache' => [
// 驱动方式
'type' => 'File',
// 缓存保存目录
'path' => CACHE_PATH,
'type' => 'redis',
'host' => '127.0.0.1',
'port' => '6379',
'password' => '',
// 缓存前缀
'prefix' => '',
// 缓存有效期 0表示永久缓存

@ -21,8 +21,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
$("#order_count").text(data.extend.order_count);
$("#order_amount").text(data.extend.order_amount);
$("#coupon_price").text(data.extend.coupon_price);
$("#dikou_price").text(data.extend.dikou_price);
$("#user_count").text(data.extend.user_count);
$("#new_user_count").text(data.extend.new_user_count);
});
// 初始化表格
@ -63,6 +65,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
_html += '<br/>' + row.user.mobile;
return _html;
}, operate:false},
{field: 'user.nickname', title: __('联系人'),operate:"LIKE",sortable:true},
{field: 'user', title: __('状态/下单时间/支付时间'),operate:'LIKE', align: 'left', formatter: function (value, row) {
var _html = ' ';
_html += '<br/>' + row.status_text;
@ -99,6 +102,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
{field: 'operate', title: __('Operate'), table: table,events: Table.api.events.operate,
buttons:[
{
name:'cancel',
text:'取消订单',
title:'取消订单',
classname: 'btn btn-xs btn-info btn-ajax',
icon: 'fa fa-check',
url: 'order/cancel',
visible:function(row){
if (row.status == 0) {
return true;
}
return false;
},
refresh:true
},
{
name:'split',
text:'发货',

@ -185,4 +185,25 @@ class Redis extends Driver
return $this->handler->flushDB();
}
/**
* 设置一个key,如果key存在,不做任何操作.
* @param unknown $key
* @param unknown $value
*/
public function setnx($name, $value)
{
$key = $this->getCacheKey($name);
return $this->handler->setnx($key, $value);
}
/**
* 设置一个key,如果key存在,不做任何操作.
* @param unknown $key
* @param unknown $value
*/
public function expire($name, $expire)
{
$key = $this->getCacheKey($name);
return $this->handler->expire($key, $expire);
}
}

Loading…
Cancel
Save