From dfd2b68aaa7af8cd52a1fcbf944527be57ba74be Mon Sep 17 00:00:00 2001 From: sugar1569 Date: Wed, 12 Dec 2018 16:29:30 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=A4=9A=E4=B8=AA=E9=80=89=E6=8B=A9=E4=B8=8D?= =?UTF-8?q?=E8=B5=B7=E4=BD=9C=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/model/store/StoreProductAttr.php | 2 +- view/crmebN/pages/product-con/index.wxml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/admin/model/store/StoreProductAttr.php b/application/admin/model/store/StoreProductAttr.php index d685496b..910cb945 100644 --- a/application/admin/model/store/StoreProductAttr.php +++ b/application/admin/model/store/StoreProductAttr.php @@ -77,7 +77,7 @@ class StoreProductAttr extends ModelBasic ]; } foreach ($valueList as $k=>$value){ - ksort($value['detail'],SORT_STRING); + sort($value['detail'],SORT_STRING); $suk = implode(',',$value['detail']); $valueGroup[$suk] = [ 'product_id'=>$productId, diff --git a/view/crmebN/pages/product-con/index.wxml b/view/crmebN/pages/product-con/index.wxml index f61f8452..fd8e9ff3 100644 --- a/view/crmebN/pages/product-con/index.wxml +++ b/view/crmebN/pages/product-con/index.wxml @@ -78,7 +78,7 @@ {{reply.comment}} {{reply.add_time}} - + 管理员回复: {{reply.merchant_reply_content}} {{reply.merchant_reply_time}} From 8f84eaeffc0716d7bcbc22499855f9f56f6e0083 Mon Sep 17 00:00:00 2001 From: xaboy Date: Thu, 13 Dec 2018 15:51:29 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=95=86=E5=93=81?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/store/StoreProduct.php | 23 +++++++++++-------- .../admin/controller/ump/StoreCoupon.php | 2 +- .../admin/controller/ump/StoreSeckill.php | 16 ++++++------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/application/admin/controller/store/StoreProduct.php b/application/admin/controller/store/StoreProduct.php index 5c53624d..f2a976bd 100644 --- a/application/admin/controller/store/StoreProduct.php +++ b/application/admin/controller/store/StoreProduct.php @@ -138,22 +138,27 @@ class StoreProduct extends AuthController $menus[] = ['value'=>$menu['id'],'label'=>$menu['html'].$menu['cate_name'],'disabled'=>$menu['pid']== 0];//,'disabled'=>$menu['pid']== 0]; } return $menus; - })->filterable(1)->multiple(1), - Form::input('store_name','产品名称')->col(Form::col(24)), + })->filterable(1)->multiple(1)->required(), + Form::input('store_name','产品名称')->col(Form::col(24))->validateFn(function($validate){ + $validate->min(5)->max(32); + })->required(), Form::input('store_info','产品简介')->type('textarea'), Form::input('keyword','产品关键字')->placeholder('多个用英文状态下的逗号隔开'), - Form::input('unit_name','产品单位','件'), - Form::frameImageOne('image','产品主图片(305*305px)',Url::build('admin/widget.images/index',array('fodder'=>'image')))->icon('image')->width('100%')->height('500px'), - Form::frameImages('slider_image','产品轮播图(640*640px)',Url::build('admin/widget.images/index',array('fodder'=>'slider_image')))->maxLength(5)->icon('images')->width('100%')->height('500px')->spin(0), - Form::number('price','产品售价')->min(0)->col(8), + Form::input('unit_name','产品单位','件')->required(), + Form::frameImageOne('image','产品主图片(305*305px)',Url::build('admin/widget.images/index',array('fodder'=>'image')))->icon('image')->width('100%')->height('500px')->required(), + Form::frameImages('slider_image','产品轮播图(640*640px)',Url::build('admin/widget.images/index',array('fodder'=>'slider_image')))->maxLength(5)->icon('images')->width('100%')->height('500px')->spin(0) + ->required()->validateFn(function($validate){ + $validate->min(1)->max(5); + }), + Form::number('price','产品售价')->min(0)->col(8)->required(), Form::number('ot_price','产品市场价')->min(0)->col(8), Form::number('give_integral','赠送积分')->min(0)->precision(0)->col(8), - Form::number('postage','邮费')->min(0)->col(Form::col(8)), + Form::number('postage','邮费')->min(0)->col(Form::col(8))->required(), Form::number('sales','销量',0)->min(0)->precision(0)->col(8)->readonly(1), Form::number('ficti','虚拟销量')->min(0)->precision(0)->col(8), - Form::number('stock','库存')->min(0)->precision(0)->col(8), + Form::number('stock','库存')->min(0)->precision(0)->col(8)->required(), Form::number('cost','产品成本价')->min(0)->col(8), - Form::number('sort','排序')->col(8), + Form::number('sort','排序',0)->col(8)->required(), Form::radio('is_show','产品状态',0)->options([['label'=>'上架','value'=>1],['label'=>'下架','value'=>0]])->col(8), Form::radio('is_hot','热卖单品',0)->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(8), Form::radio('is_benefit','促销单品',0)->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(8), diff --git a/application/admin/controller/ump/StoreCoupon.php b/application/admin/controller/ump/StoreCoupon.php index dc6a847e..a0c4aa9b 100644 --- a/application/admin/controller/ump/StoreCoupon.php +++ b/application/admin/controller/ump/StoreCoupon.php @@ -42,7 +42,7 @@ class StoreCoupon extends AuthController public function create() { $f = array(); - $f[] = Form::input('title','优惠券名称'); + $f[] = Form::input('title','优惠券名称')->required(); $f[] = Form::number('coupon_price','优惠券面值',0)->min(0); $f[] = Form::number('use_min_price','优惠券最低消费')->min(0); $f[] = Form::number('coupon_time','优惠券有效期限')->min(0); diff --git a/application/admin/controller/ump/StoreSeckill.php b/application/admin/controller/ump/StoreSeckill.php index 0e58be25..71e5605d 100644 --- a/application/admin/controller/ump/StoreSeckill.php +++ b/application/admin/controller/ump/StoreSeckill.php @@ -75,13 +75,13 @@ class StoreSeckill extends AuthController public function create() { $f = array(); - $f[] = Form::input('title','产品标题'); - $f[] = Form::input('info','秒杀活动简介')->type('textarea'); - $f[] = Form::input('unit_name','单位')->placeholder('个、位'); - $f[] = Form::dateTimeRange('section_time','活动时间'); - $f[] = Form::frameImageOne('image','产品主图片(305*305px)',Url::build('admin/widget.images/index',array('fodder'=>'image')))->icon('image'); - $f[] = Form::frameImages('images','产品轮播图(640*640px)',Url::build('admin/widget.images/index',array('fodder'=>'images')))->maxLength(5)->icon('images'); - $f[] = Form::number('price','秒杀价')->min(0)->col(12); + $f[] = Form::input('title','产品标题')->required(); + $f[] = Form::input('info','秒杀活动简介')->type('textarea')->required(); + $f[] = Form::input('unit_name','单位')->placeholder('个、位')->required(); + $f[] = Form::dateTimeRange('section_time','活动时间')->required(); + $f[] = Form::frameImageOne('image','产品主图片(305*305px)',Url::build('admin/widget.images/index',array('fodder'=>'image')))->icon('image')->required(); + $f[] = Form::frameImages('images','产品轮播图(640*640px)',Url::build('admin/widget.images/index',array('fodder'=>'images')))->maxLength(5)->icon('images')->required(); + $f[] = Form::number('price','秒杀价')->min(0)->col(12)->required(); $f[] = Form::number('ot_price','原价')->min(0)->col(12); $f[] = Form::number('cost','成本价')->min(0)->col(12); $f[] = Form::number('stock','库存')->min(0)->precision(0)->col(12); @@ -93,7 +93,7 @@ class StoreSeckill extends AuthController $f[] = Form::radio('is_postage','是否包邮',1)->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(12); $f[] = Form::radio('is_hot','热门推荐',1)->options([['label'=>'开启','value'=>1],['label'=>'关闭','value'=>0]])->col(12); $f[] = Form::radio('status','活动状态',1)->options([['label'=>'开启','value'=>1],['label'=>'关闭','value'=>0]])->col(12); - $form = Form::make_post_form('添加用户通知',$f,Url::build('save')); + $form = Form::make_post_form('开启秒杀',$f,Url::build('save')); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } From 978d4862d2d40258706c386822cfc14ed4e3c5ba Mon Sep 17 00:00:00 2001 From: sugar1569 Date: Sat, 15 Dec 2018 11:00:20 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B4=AD=E7=89=A9?= =?UTF-8?q?=E8=BD=A6=E4=B8=BA=E7=A9=BA=20=E6=8A=A5500=E9=94=99=E8=AF=AF?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=90=8E=E5=8F=B0=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83=E8=8F=9C=E5=8D=95=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/setting/SystemGroupData.php | 3 ++- application/wap/model/store/StoreCart.php | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/application/admin/controller/setting/SystemGroupData.php b/application/admin/controller/setting/SystemGroupData.php index ed319378..f8f93628 100644 --- a/application/admin/controller/setting/SystemGroupData.php +++ b/application/admin/controller/setting/SystemGroupData.php @@ -109,7 +109,8 @@ class SystemGroupData extends AuthController foreach ($params as $key => $param) { foreach ($Fields['fields'] as $index => $field) { if($key == $field["title"]){ - if($param == "" || count($param) == 0) +// if($param == "" || count($param) == 0) + if($param == "") return Json::fail($field["name"]."不能为空!"); else{ $value[$key]["type"] = $field["type"]; diff --git a/application/wap/model/store/StoreCart.php b/application/wap/model/store/StoreCart.php index 2cb52f6c..6cc90684 100644 --- a/application/wap/model/store/StoreCart.php +++ b/application/wap/model/store/StoreCart.php @@ -99,14 +99,15 @@ class StoreCart extends ModelBasic foreach ($list as $k=>$cart) { if ($cart['seckill_id']) { $product = StoreSeckill::field($seckillInfoField) - ->find($cart['seckill_id'])->toArray(); + ->find($cart['seckill_id']); }elseif($cart['bargain_id']){ $product = StoreBargain::field($bargainInfoField) - ->find($cart['bargain_id'])->toArray(); + ->find($cart['bargain_id']); }else{ $product = StoreProduct::field($productInfoField) - ->find($cart['product_id'])->toArray(); + ->find($cart['product_id']); } + if(!empty($product)) $product = $product->toArray(); $cart['productInfo'] = $product; //商品不存在 if (!$product) { From dbc47863efe7c46c4c3914b360beb80be03bedc4 Mon Sep 17 00:00:00 2001 From: sugar1569 Date: Thu, 20 Dec 2018 17:25:12 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=88=86=E7=B1=BB=E6=8A=A5=E9=94=99=EF=BC=8C?= =?UTF-8?q?=E5=92=8C=E4=BA=A7=E5=93=81=E5=88=97=E8=A1=A8=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E7=BE=8E=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/store/StoreCategory.php | 1 - .../admin/model/store/StoreCategory.php | 26 +- .../admin/view/store/store_category/index.php | 265 ++++++++++-------- .../admin/view/store/store_product/index.php | 18 +- extend/service/WechatService.php | 30 +- view/crmebN/pages/orders-con/orders-con.js | 2 +- 6 files changed, 195 insertions(+), 147 deletions(-) diff --git a/application/admin/controller/store/StoreCategory.php b/application/admin/controller/store/StoreCategory.php index 71d72375..782f7eb7 100644 --- a/application/admin/controller/store/StoreCategory.php +++ b/application/admin/controller/store/StoreCategory.php @@ -1,5 +1,4 @@ page((int)$where['page'],(int)$where['limit'])->select()) && count($data) ? $data->toArray() :[]; + foreach ($data as &$item){ + if($item['pid']){ + $item['pid_name'] = self::where('id',$item['pid'])->value('cate_name'); + }else{ + $item['pid_name'] = '顶级'; + } + } + $count=self::systemPage($where,true)->count(); + return compact('count','data'); + } /** * @param $where * @return array */ - public static function systemPage($where){ + public static function systemPage($where,$isAjax=false){ $model = new self; if($where['pid'] != '') $model = $model->where('pid',$where['pid']); else if($where['pid']=='' && $where['cate_name']=='') $model = $model->where('pid',0); if($where['is_show'] != '') $model = $model->where('is_show',$where['is_show']); if($where['cate_name'] != '') $model = $model->where('cate_name','LIKE',"%$where[cate_name]%"); + if($isAjax===true){ + if(isset($where['order']) && $where['order']!=''){ + $model=$model->order(self::setOrder($where['order'])); + } + return $model; + } return self::page($model,function ($item){ if($item['pid']){ $item['pid_name'] = self::where('id',$item['pid'])->value('cate_name'); diff --git a/application/admin/view/store/store_category/index.php b/application/admin/view/store/store_category/index.php index eb58749b..f6d948f9 100644 --- a/application/admin/view/store/store_category/index.php +++ b/application/admin/view/store/store_category/index.php @@ -1,133 +1,172 @@ {extend name="public/container"} {block name="content"} -
-
-
-
- 分类首页 - -
+
+
+
+
+
搜索条件
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
-
-
-
-
- - -
- - -
-
+
+ +
+
+
分类列表
+
+ - +
+ 分类首页 + +
+
+ + + +
-
- - - - - - - - - - - - - - - {volist name="list" id="vo"} - - - - - - - - - - - {/volist} - -
编号父级分类名称分类图标排序是否显示操作
- {$vo.id} - - {$vo.pid_name} - - {$vo.cate_name} - - {$vo.cate_name} - - {$vo.sort} - - - -
-
- - -
-
-
-
- {include file="public/inner_page"}
+ {/block} {block name="script"} {/block} diff --git a/application/admin/view/store/store_product/index.php b/application/admin/view/store/store_product/index.php index f86bc0a3..c5877ccd 100644 --- a/application/admin/view/store/store_product/index.php +++ b/application/admin/view/store/store_product/index.php @@ -71,7 +71,7 @@
{switch name='type'} {case value="1"} - + {/case} {case value="2"} @@ -175,15 +175,15 @@ case 2: join=[ {type:'checkbox'}, - {field: 'id', title: 'ID', sort: true,event:'id',width:'5%'}, - {field: 'image', title: '产品图片',templet:'#image'}, + {field: 'id', title: 'ID', sort: true,event:'id',width:'6%'}, + {field: 'image', title: '产品图片',templet:'#image',width:'10%'}, {field: 'store_name', title: '产品名称',templet:'#store_name'}, - {field: 'price', title: '产品价格',edit:'price'}, - {field: 'ficti', title: '虚拟销量',edit:'ficti'}, - {field: 'stock', title: '库存',edit:'stock'}, - {field: 'sort', title: '排序',edit:'sort'}, - {field: 'sales', title: '销量',sort: true,event:'sales'}, - {field: 'status', title: '状态',templet:"#checkboxstatus"}, + {field: 'price', title: '价格',edit:'price',width:'8%'}, + {field: 'ficti', title: '虚拟销量',edit:'ficti',width:'8%'}, + {field: 'stock', title: '库存',edit:'stock',width:'6%'}, + {field: 'sort', title: '排序',edit:'sort',width:'6%'}, + {field: 'sales', title: '销量',sort: true,event:'sales',width:'6%'}, + {field: 'status', title: '状态',templet:"#checkboxstatus",width:'8%'}, {field: 'right', title: '操作',align:'center',toolbar:'#act',width:'14%'}, ]; break; diff --git a/extend/service/WechatService.php b/extend/service/WechatService.php index a18875db..347c069f 100644 --- a/extend/service/WechatService.php +++ b/extend/service/WechatService.php @@ -27,25 +27,24 @@ class WechatService { private static $instance = null; - /**获取微信配置参数 - * @return array - */ public static function options() { - $wechat = SystemConfigService::more(['wechat_appid','wechat_appsecret','wechat_token']); + $wechat = SystemConfigService::more(['wechat_appid','wechat_appsecret','wechat_token','wechat_encodingaeskey','wechat_encode']); $payment = SystemConfigService::more(['pay_weixin_mchid','pay_weixin_client_cert','pay_weixin_client_key','pay_weixin_key','pay_weixin_open']); $config = [ - 'app_id'=>isset($wechat['wechat_appid']) ? trim($wechat['wechat_appid']):'', - 'secret'=>isset($wechat['wechat_appsecret']) ? trim($wechat['wechat_appsecret']):'', - 'token'=>isset($wechat['wechat_token']) ? trim($wechat['wechat_token']):'', + 'app_id'=>isset($wechat['wechat_appid']) ? $wechat['wechat_appid']:'', + 'secret'=>isset($wechat['wechat_appsecret']) ? $wechat['wechat_appsecret']:'', + 'token'=>isset($wechat['wechat_token']) ? $wechat['wechat_token']:'', 'guzzle' => [ 'timeout' => 10.0, // 超时时间(秒) ], ]; + if((int)$wechat['wechat_encode']>0 && isset($wechat['wechat_encodingaeskey']) && !empty($wechat['wechat_encodingaeskey'])) + $config['aes_key'] = $wechat['wechat_encodingaeskey']; if(isset($payment['pay_weixin_open']) && $payment['pay_weixin_open'] == 1){ $config['payment'] = [ - 'merchant_id'=>trim($payment['pay_weixin_mchid']), - 'key'=>trim($payment['pay_weixin_key']), + 'merchant_id'=>$payment['pay_weixin_mchid'], + 'key'=>$payment['pay_weixin_key'], 'cert_path'=>realpath('.'.$payment['pay_weixin_client_cert']), 'key_path'=>realpath('.'.$payment['pay_weixin_client_key']), 'notify_url'=>SystemConfigService::get('site_url').Url::build('wap/Wechat/notify') @@ -62,9 +61,6 @@ class WechatService return self::$instance; } - /** - * 微信接口 - */ public static function serve() { $wechat = self::application(true); @@ -133,6 +129,7 @@ class WechatService $response = HookService::resultListen('wechat_message_other',$message,null,true,$behavior); break; } + return $response; }); } @@ -370,11 +367,6 @@ class WechatService return self::paymentService()->refund($orderNo,$refundNo,$totalFee,$refundFee,$opUserId,$type,$refundAccount,$refundReason); } - /**订单退款 - * @param $orderNo - * @param array $opt - * @return bool - */ public static function payOrderRefund($orderNo, array $opt) { if(!isset($opt['pay_price'])) exception('缺少pay_price'); @@ -420,10 +412,6 @@ class WechatService return self::application()->js; } - /** jsSdk - * @param string $url - * @return array|string - */ public static function jsSdk($url = '') { $apiList = ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone', 'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'playVoice', 'pauseVoice', 'stopVoice', 'onVoicePlayEnd', 'uploadVoice', 'downloadVoice', 'chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'translateVoice', 'getNetworkType', 'openLocation', 'getLocation', 'hideOptionMenu', 'showOptionMenu', 'hideMenuItems', 'showMenuItems', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem', 'closeWindow', 'scanQRCode', 'chooseWXPay', 'openProductSpecificView', 'addCard', 'chooseCard', 'openCard']; diff --git a/view/crmebN/pages/orders-con/orders-con.js b/view/crmebN/pages/orders-con/orders-con.js index 6f5b7919..b9bb340e 100644 --- a/view/crmebN/pages/orders-con/orders-con.js +++ b/view/crmebN/pages/orders-con/orders-con.js @@ -66,7 +66,7 @@ Page({ }) setTimeout(function () { wx.navigateTo({ //跳转至指定页面并关闭其他打开的所有页面(这个最好用在返回至首页的的时候) - url: '/pages/orders-con/orders-con?order_id=' + data.result.orderId + url: '/pages/orders-con/orders-con?order_id=' + data.result.order_id }) }, 1200) }, From 322b7d463eea9a4b402d52b6aabfff21e9dd8da9 Mon Sep 17 00:00:00 2001 From: sugar1569 Date: Thu, 20 Dec 2018 17:27:56 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=85=BC=E5=AE=B9windows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/system/SystemFile.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/application/admin/controller/system/SystemFile.php b/application/admin/controller/system/SystemFile.php index 87eb8417..09234cdc 100644 --- a/application/admin/controller/system/SystemFile.php +++ b/application/admin/controller/system/SystemFile.php @@ -20,11 +20,11 @@ class SystemFile extends AuthController public function opendir($filedir=''){ $fileAll = array('dir'=>[],'file'=>[]); if(Request::instance()->param('superior') && !empty(Request::instance()->param('dir'))){ - $path = '.'.DS.Request::instance()->param('dir'); + $path = './'.Request::instance()->param('dir'); $path = dirname($path); }else{ $path = !empty(Request::instance()->param('dir'))?Request::instance()->param('dir'):'.'; - $path = $path.DS.Request::instance()->param('filedir'); + $path = $path.'/'.Request::instance()->param('filedir'); } $list = scandir($path); foreach($list as $key=>$v) { @@ -38,6 +38,9 @@ class SystemFile extends AuthController } } // var_dump($fileAll['file']); + //兼容windows + $uname=php_uname('s'); + if(strstr($uname,'Windows')!==false) $path = ltrim($path,'\\'); $dir = ltrim($path,'./'); $this->assign(compact('fileAll','dir')); return $this->fetch(); @@ -65,6 +68,10 @@ class SystemFile extends AuthController $comment = $this->request->post('comment'); $filepath = $this->request->post('filepath'); if(!empty($comment) && !empty($filepath)){ + //兼容windows + $uname=php_uname('s'); + if(strstr($uname,'Windows')!==false) + $filepath = ltrim(str_replace('/', DS, $filepath),'.'); $res = FileClass::write_file($filepath,$comment); if($res){ return Json::successful('保存成功!'); From 23aafa1a17a011ece70a87717dbf74afa71b3830 Mon Sep 17 00:00:00 2001 From: sugar1569 Date: Thu, 20 Dec 2018 18:27:37 +0800 Subject: [PATCH 6/8] =?UTF-8?q?tp5=20=E6=BC=8F=E6=B4=9E=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- thinkphp/library/think/db/Builder.php | 145 ++++++++++++++++---------- 1 file changed, 91 insertions(+), 54 deletions(-) diff --git a/thinkphp/library/think/db/Builder.php b/thinkphp/library/think/db/Builder.php index 213cb090..9412821d 100644 --- a/thinkphp/library/think/db/Builder.php +++ b/thinkphp/library/think/db/Builder.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- @@ -11,7 +11,6 @@ namespace think\db; -use BadMethodCallException; use PDO; use think\Exception; @@ -26,7 +25,7 @@ abstract class Builder protected $exp = ['eq' => '=', 'neq' => '<>', 'gt' => '>', 'egt' => '>=', 'lt' => '<', 'elt' => '<=', 'notlike' => 'NOT LIKE', 'not like' => 'NOT LIKE', 'like' => 'LIKE', 'in' => 'IN', 'exp' => 'EXP', 'notin' => 'NOT IN', 'not in' => 'NOT IN', 'between' => 'BETWEEN', 'not between' => 'NOT BETWEEN', 'notbetween' => 'NOT BETWEEN', 'exists' => 'EXISTS', 'notexists' => 'NOT EXISTS', 'not exists' => 'NOT EXISTS', 'null' => 'NULL', 'notnull' => 'NOT NULL', 'not null' => 'NOT NULL', '> time' => '> TIME', '< time' => '< TIME', '>= time' => '>= TIME', '<= time' => '<= TIME', 'between time' => 'BETWEEN TIME', 'not between time' => 'NOT BETWEEN TIME', 'notbetween time' => 'NOT BETWEEN TIME']; // SQL表达式 - protected $selectSql = 'SELECT%DISTINCT% %FIELD% FROM %TABLE%%FORCE%%JOIN%%WHERE%%GROUP%%HAVING%%ORDER%%LIMIT% %UNION%%LOCK%%COMMENT%'; + protected $selectSql = 'SELECT%DISTINCT% %FIELD% FROM %TABLE%%FORCE%%JOIN%%WHERE%%GROUP%%HAVING%%UNION%%ORDER%%LIMIT%%LOCK%%COMMENT%'; protected $insertSql = '%INSERT% INTO %TABLE% (%FIELD%) VALUES (%DATA%) %COMMENT%'; protected $insertAllSql = '%INSERT% INTO %TABLE% (%FIELD%) %DATA% %COMMENT%'; protected $updateSql = 'UPDATE %TABLE% SET %SET% %JOIN% %WHERE% %ORDER%%LIMIT% %LOCK%%COMMENT%'; @@ -99,8 +98,11 @@ abstract class Builder $result = []; foreach ($data as $key => $val) { - $item = $this->parseKey($key, $options); - if (is_object($val) && method_exists($val, '__toString')) { + $item = $this->parseKey($key, $options, true); + if ($val instanceof Expression) { + $result[$item] = $val->getValue(); + continue; + } elseif (is_object($val) && method_exists($val, '__toString')) { // 对象数据写入 $val = $val->__toString(); } @@ -110,8 +112,23 @@ abstract class Builder } } elseif (is_null($val)) { $result[$item] = 'NULL'; - } elseif (isset($val[0]) && 'exp' == $val[0]) { - $result[$item] = $val[1]; + } elseif (is_array($val) && !empty($val)) { + switch (strtolower($val[0])) { + case 'inc': + //$result[$item] = $item . '+' . floatval($val[1]); + if ($key == $val[1]) { + $result[$item] = $this->parseKey($val[1]) . '+' . floatval($val[2]); + } + break; + case 'dec': + //$result[$item] = $item . '-' . floatval($val[1]); + if ($key == $val[1]) { + $result[$item] = $this->parseKey($val[1]) . '-' . floatval($val[2]); + } + break; + case 'exp': + throw new Exception('not support data:[' . $val[0] . ']'); + } } elseif (is_scalar($val)) { // 过滤非标量数据 if (0 === strpos($val, ':') && $this->query->isBind(substr($val, 1))) { @@ -133,7 +150,7 @@ abstract class Builder * @param array $options * @return string */ - protected function parseKey($key, $options = []) + protected function parseKey($key, $options = [], $strict = false) { return $key; } @@ -174,8 +191,10 @@ abstract class Builder // 支持 'field1'=>'field2' 这样的字段别名定义 $array = []; foreach ($fields as $key => $field) { - if (!is_numeric($key)) { - $array[] = $this->parseKey($key, $options) . ' AS ' . $this->parseKey($field, $options); + if ($field instanceof Expression) { + $array[] = $field->getValue(); + } elseif (!is_numeric($key)) { + $array[] = $this->parseKey($key, $options) . ' AS ' . $this->parseKey($field, $options, true); } else { $array[] = $this->parseKey($field, $options); } @@ -197,9 +216,6 @@ abstract class Builder $item = []; foreach ((array) $tables as $key => $table) { if (!is_numeric($key)) { - if (strpos($key, '@think')) { - $key = strstr($key, '@think', true); - } $key = $this->parseSqlTable($key); $item[] = $this->parseKey($key) . ' ' . (isset($options['alias'][$table]) ? $this->parseKey($options['alias'][$table]) : $this->parseKey($table)); } else { @@ -257,7 +273,9 @@ abstract class Builder foreach ($where as $key => $val) { $str = []; foreach ($val as $field => $value) { - if ($value instanceof \Closure) { + if ($value instanceof Expression) { + $str[] = ' ' . $key . ' ( ' . $value->getValue() . ' )'; + } elseif ($value instanceof \Closure) { // 使用闭包查询 $query = new Query($this->connection); call_user_func_array($value, [ & $query]); @@ -298,7 +316,7 @@ abstract class Builder protected function parseWhereItem($field, $val, $rule = '', $options = [], $binds = [], $bindName = null) { // 字段分析 - $key = $field ? $this->parseKey($field, $options) : ''; + $key = $field ? $this->parseKey($field, $options, true) : ''; // 查询规则和条件 if (!is_array($val)) { @@ -331,13 +349,15 @@ abstract class Builder throw new Exception('where express error:' . $exp); } } - $bindName = $bindName ?: 'where_' . str_replace(['.', '-'], '_', $field); + $bindName = $bindName ?: 'where_' . $rule . '_' . str_replace(['.', '-'], '_', $field); if (preg_match('/\W/', $bindName)) { // 处理带非单词字符的字段名 $bindName = md5($bindName); } - if (is_object($value) && method_exists($value, '__toString')) { + if ($value instanceof Expression) { + + } elseif (is_object($value) && method_exists($value, '__toString')) { // 对象数据写入 $value = $value->__toString(); } @@ -374,7 +394,11 @@ abstract class Builder } } elseif ('EXP' == $exp) { // 表达式查询 - $whereStr .= '( ' . $key . ' ' . $value . ' )'; + if ($value instanceof Expression) { + $whereStr .= '( ' . $key . ' ' . $value->getValue() . ' )'; + } else { + throw new Exception('where express error:' . $exp); + } } elseif (in_array($exp, ['NOT NULL', 'NULL'])) { // NULL 查询 $whereStr .= $key . ' IS ' . $exp; @@ -492,6 +516,11 @@ abstract class Builder } } $bindName = $bindName ?: $key; + + if ($this->query->isBind($bindName)) { + $bindName .= '_' . str_replace('.', '_', uniqid('', true)); + } + $this->query->bind($bindName, $value, $bindType); return ':' . $bindName; } @@ -522,7 +551,9 @@ abstract class Builder list($table, $type, $on) = $item; $condition = []; foreach ((array) $on as $val) { - if (strpos($val, '=')) { + if ($val instanceof Expression) { + $condition[] = $val->getValue(); + } elseif (strpos($val, '=')) { list($val1, $val2) = explode('=', $val, 2); $condition[] = $this->parseKey($val1, $options) . '=' . $this->parseKey($val2, $options); } else { @@ -546,28 +577,29 @@ abstract class Builder */ protected function parseOrder($order, $options = []) { - if (is_array($order)) { - $array = []; - foreach ($order as $key => $val) { - if (is_numeric($key)) { - if ('[rand]' == $val) { - if (method_exists($this, 'parseRand')) { - $array[] = $this->parseRand(); - } else { - throw new BadMethodCallException('method not exists:' . get_class($this) . '-> parseRand'); - } - } elseif (false === strpos($val, '(')) { - $array[] = $this->parseKey($val, $options); - } else { - $array[] = $val; - } - } else { - $sort = in_array(strtolower(trim($val)), ['asc', 'desc']) ? ' ' . $val : ''; - $array[] = $this->parseKey($key, $options) . ' ' . $sort; - } - } - $order = implode(',', $array); + if (empty($order)) { + return ''; } + + $array = []; + foreach ($order as $key => $val) { + if ($val instanceof Expression) { + $array[] = $val->getValue(); + } elseif ('[rand]' == $val) { + $array[] = $this->parseRand(); + } else { + if (is_numeric($key)) { + list($key, $sort) = explode(' ', strpos($val, ' ') ? $val : $val . ' '); + } else { + $sort = $val; + } + $sort = strtoupper($sort); + $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : ''; + $array[] = $this->parseKey($key, $options, true) . $sort; + } + } + $order = implode(',', $array); + return !empty($order) ? ' ORDER BY ' . $order : ''; } @@ -601,6 +633,9 @@ abstract class Builder */ protected function parseComment($comment) { + if (false !== strpos($comment, '*/')) { + $comment = strstr($comment, '*/', true); + } return !empty($comment) ? ' /* ' . $comment . ' */' : ''; } @@ -630,12 +665,12 @@ abstract class Builder unset($union['type']); foreach ($union as $u) { if ($u instanceof \Closure) { - $sql[] = $type . ' ' . $this->parseClosure($u, false); + $sql[] = $type . ' ' . $this->parseClosure($u); } elseif (is_string($u)) { - $sql[] = $type . ' ' . $this->parseSqlTable($u); + $sql[] = $type . ' ( ' . $this->parseSqlTable($u) . ' )'; } } - return implode(' ', $sql); + return ' ' . implode(' ', $sql); } /** @@ -650,11 +685,7 @@ abstract class Builder return ''; } - if (is_array($index)) { - $index = join(",", $index); - } - - return sprintf(" FORCE INDEX ( %s ) ", $index); + return sprintf(" FORCE INDEX ( %s ) ", is_array($index) ? implode(',', $index) : $index); } /** @@ -749,7 +780,7 @@ abstract class Builder $fields = $options['field']; } - foreach ($dataSet as &$data) { + foreach ($dataSet as $data) { foreach ($data as $key => $val) { if (!in_array($key, $fields, true)) { if ($options['strict']) { @@ -770,19 +801,25 @@ abstract class Builder } $value = array_values($data); $values[] = 'SELECT ' . implode(',', $value); + + if (!isset($insertFields)) { + $insertFields = array_keys($data); + } } - $fields = array_map([$this, 'parseKey'], array_keys(reset($dataSet))); - $sql = str_replace( + + foreach ($insertFields as $field) { + $fields[] = $this->parseKey($field, $options, true); + } + + return str_replace( ['%INSERT%', '%TABLE%', '%FIELD%', '%DATA%', '%COMMENT%'], [ $replace ? 'REPLACE' : 'INSERT', $this->parseTable($options['table'], $options), - implode(' , ', $fields), + implode(' , ', $insertFields), implode(' UNION ALL ', $values), $this->parseComment($options['comment']), ], $this->insertAllSql); - - return $sql; } /** From 2b351f8b15dbfa1f2d3d205b3501eda89b289b1f Mon Sep 17 00:00:00 2001 From: sugar1569 Date: Sat, 22 Dec 2018 11:47:10 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E7=A7=92=E6=9D=80=E3=80=81=E7=A0=8D=E4=BB=B7=E3=80=81=E6=8B=BC?= =?UTF-8?q?=E5=9B=A2=E3=80=81=E4=BA=A7=E5=93=81=E3=80=81=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E3=80=81=E7=A7=AF=E5=88=86=E3=80=81=E5=85=B3=E9=94=AE=E8=AF=8D?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=A1=B5=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/model/order/StoreOrder.php | 18 ++ .../admin/view/order/store_order/index.php | 51 ++++-- .../view/ump/store_combination/index.php | 4 +- .../admin/view/ump/store_seckill/index.php | 22 +-- .../admin/view/ump/user_point/index.php | 2 +- .../admin/view/wechat/reply/keyword.php | 2 +- public/system/css/layui-admin.css | 162 ++++++++++++------ 7 files changed, 177 insertions(+), 84 deletions(-) diff --git a/application/admin/model/order/StoreOrder.php b/application/admin/model/order/StoreOrder.php index bfbd1214..f4d76783 100644 --- a/application/admin/model/order/StoreOrder.php +++ b/application/admin/model/order/StoreOrder.php @@ -54,6 +54,7 @@ class StoreOrder extends ModelBasic $_info[$k]['cart_info'] = json_decode($v['cart_info'],true); } $item['_info'] = $_info; + $item['add_time'] = date('Y-m-d H:i:s',$item['add_time']); if($item['pink_id'] && $item['combination_id']){ $pinkStatus = StorePink::where('order_id_key',$item['id'])->value('status'); switch ($pinkStatus){ @@ -904,4 +905,21 @@ HTML; if(!$uid) return 0; return self::where('uid',$uid)->where('paid',1)->where('refund_status',0)->where('status',2)->count(); } + /** + * 获取已支付的订单 + * @param int $is_promoter + * @return int|string + */ + public static function getOrderPayCount($is_promoter = 0){ + return self::where('o.paid',1)->alias('o')->join('User u','u.uid=o.uid')->where('u.is_promoter',$is_promoter)->count(); + } + + /** + * 获取最后一个月已支付的订单 + * @param int $is_promoter + * @return int|string + */ + public static function getOrderPayMonthCount($is_promoter = 0){ + return self::where('o.paid',1)->alias('o')->whereTime('o.pay_time','last month')->join('User u','u.uid=o.uid')->where('u.is_promoter',$is_promoter)->count(); + } } \ No newline at end of file diff --git a/application/admin/view/order/store_order/index.php b/application/admin/view/order/store_order/index.php index f06384ba..04c64692 100644 --- a/application/admin/view/order/store_order/index.php +++ b/application/admin/view/order/store_order/index.php @@ -82,7 +82,7 @@
@@ -112,32 +112,32 @@ {{# if(item.cart_info.productInfo.attrInfo!=undefined){ }}

- + {{item.cart_info.productInfo.store_name}} {{item.cart_info.productInfo.attrInfo.suk}} | ¥{{item.cart_info.truePrice}}×{{item.cart_info.cart_num}}

{{# }else{ }}

- + {{item.cart_info.productInfo.store_name}} | ¥{{item.cart_info.truePrice}}×{{item.cart_info.cart_num}}

{{# } }} {{# }); }} - - +