Просмотр исходного кода

修改后台秒杀、产品、订单、积分列表页样式,后台发货模版通知

sugar1569 7 лет назад
Родитель
Сommit
aab614620f

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
application/admin/controller/order/StoreOrder.php


+ 10 - 8
application/admin/controller/ump/StoreSeckill.php

@@ -75,13 +75,13 @@ class StoreSeckill extends AuthController
     public function create()
     {
         $f = array();
-        $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::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::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');
     }
@@ -128,6 +128,7 @@ class StoreSeckill extends AuthController
         ],$request);
         if(!$data['title']) return Json::fail('请输入产品标题');
         if(!$data['unit_name']) return Json::fail('请输入产品单位');
+        if(!$data['product_id']) return Json::fail('产品ID不能为空');
 //        var_dump($this->request->post());
         if(count($data['section_time'])<1) return Json::fail('请选择活动时间');
         $data['start_time'] = strtotime($data['section_time'][0]);
@@ -217,6 +218,7 @@ class StoreSeckill extends AuthController
         $product = StoreSeckillModel::get($id);
         if(!$product) return Json::fail('数据不存在!');
         $f = array();
+        $f[] = Form::hidden('product_id',$product->getData('product_id'));
         $f[] = Form::input('title','产品标题',$product->getData('title'));
         $f[] = Form::input('info','秒杀活动简介',$product->getData('info'))->type('textarea');
         $f[] = Form::input('unit_name','单位',$product->getData('unit_name'))->placeholder('个、位');

+ 89 - 25
application/admin/model/order/StoreOrder.php

@@ -10,11 +10,15 @@ namespace app\admin\model\order;
 
 use app\admin\model\wechat\WechatUser;
 use app\admin\model\ump\StorePink;
+use app\admin\model\order\StoreOrderCartInfo;
 use app\admin\model\store\StoreProduct;
+use app\admin\model\routine\RoutineFormId;
+use app\admin\model\routine\RoutineTemplate;
 use service\PHPExcelService;
 use traits\ModelTrait;
 use basic\ModelBasic;
 use service\WechatTemplateService;
+use service\RoutineTemplateService;
 use think\Url;
 use think\Db;
 /**
@@ -47,7 +51,12 @@ class StoreOrder extends ModelBasic
         }else{
             $model = $model->order('a.id desc');
         }
-        $data=($data=$model->page((int)$where['page'],(int)$where['limit'])->select()) && count($data) ? $data->toArray() : [];
+        if(isset($where['excel']) && $where['excel']==1){
+            $data=($data=$model->select()) && count($data) ? $data->toArray() : [];
+        }else{
+            $data=($data=$model->page((int)$where['page'],(int)$where['limit'])->select()) && count($data) ? $data->toArray() : [];
+        }
+//        $data=($data=$model->page((int)$where['page'],(int)$where['limit'])->select()) && count($data) ? $data->toArray() : [];
         foreach ($data as &$item){
             $_info = Db::name('store_order_cart_info')->where('oid',$item['id'])->field('cart_info')->select();
             foreach ($_info as $k=>$v){
@@ -460,6 +469,7 @@ HTML;
      * @return array
      */
     public static function getOrderPrice($where){
+        $where['is_del'] = 0;//删除订单不统计
         $model = new self;
         $price = array();
         $price['pay_price'] = 0;//支付金额
@@ -473,7 +483,7 @@ HTML;
         $price['deduction_price'] = 0;//抵扣金额
         $price['total_num'] = 0; //商品总数
         $model = self::getOrderWhere($where,$model);
-        $list = $model->select()->toArray();
+        $list = $model->where('is_del',0)->select()->toArray();
         foreach ($list as $v){
             $price['total_num'] = bcadd($price['total_num'],$v['total_num'],0);
             $price['pay_price'] = bcadd($price['pay_price'],$v['pay_price'],2);
@@ -871,30 +881,84 @@ HTML;
             ]
         ];
     }
-    /*
-     * 退款列表
-     * $where array
-     * return array
+
+    /**微信 订单发货
+     * @param $oid
+     * @param array $postageData
+     */
+    public static function orderPostageAfter($oid,$postageData = [])
+    {
+        $order = self::where('id',$oid)->find();
+        $openid = WechatUser::uidToOpenid($order['uid']);
+        $url = Url::build('wap/My/order',['uni'=>$order['order_id']],true,true);
+        $group = [
+            'first'=>'亲,您的订单已发货,请注意查收',
+            'remark'=>'点击查看订单详情'
+        ];
+        if($postageData['delivery_type'] == 'send'){//送货
+            $goodsName = StoreOrderCartInfo::getProductNameList($order['id']);
+            $group = array_merge($group,[
+                'keyword1'=>$goodsName,
+                'keyword2'=>$order['pay_type'] == 'offline' ? '线下支付' : date('Y/m/d H:i',$order['pay_time']),
+                'keyword3'=>$order['user_address'],
+                'keyword4'=>$postageData['delivery_name'],
+                'keyword5'=>$postageData['delivery_id']
+            ]);
+            WechatTemplateService::sendTemplate($openid,WechatTemplateService::ORDER_DELIVER_SUCCESS,$group,$url);
+
+        }else if($postageData['delivery_type'] == 'express'){//发货
+            $group = array_merge($group,[
+                'keyword1'=>$order['order_id'],
+                'keyword2'=>$postageData['delivery_name'],
+                'keyword3'=>$postageData['delivery_id']
+            ]);
+            WechatTemplateService::sendTemplate($openid,WechatTemplateService::ORDER_POSTAGE_SUCCESS,$group,$url);
+        }
+    }
+    /**
+     * 小程序 订单发货提醒
+     * @param int $oid
+     * @param array $postageData
+     * @return bool
      */
-//    public static function getRefundList($where){
-//        $refundlist=self::setEchatWhere($where)->field([
-//            'order_id','total_price','coupon_price','deduction_price',
-//            'use_integral','FROM_UNIXTIME(add_time,"%Y-%m-%d") as add_time','FROM_UNIXTIME(pay_time,"%Y-%m-%d") as pay_time','combination_id',
-//            'seckill_id','bargain_id','cost','status','cart_id','pay_price','refund_status'
-//        ])->page((int)$where['page'],(int)$where['limit'])->select();
-//        count($refundlist) && $refundlist=$refundlist->toArray();
-//        foreach($refundlist as &$item){
-//            $item['product']=StoreProduct::where('id','in',function ($quers) use($item){
-//                $quers->name('store_cart')->where('id','in',json_decode($item['cart_id'],true))->field('product_id');
-//            })->field(['store_name','cost','price','image'])->select()->toArray();
-//            if($item['refund_status']==1) {
-//                $item['_refund'] = '申请退款中';
-//            }elseif ($item['refund_status']==2){
-//                $item['_refund'] = '退款成功';
-//            }
-//        }
-//        return $refundlist;
-//    }
+    public static function sendOrderGoods($oid = 0,$postageData=array()){
+        if(!$oid || !$postageData) return true;
+        $order = self::where('id',$oid)->find();
+        $routine_openid = WechatUser::uidToRoutineOpenid($order['uid']);
+        if(!$routine_openid) return true;
+        if($postageData['delivery_type'] == 'send'){//送货
+            $data['keyword1']['value'] =  $order['order_id'];
+            $data['keyword2']['value'] =  $order['delivery_name'];
+            $data['keyword3']['value'] =  $order['delivery_id'];
+            $data['keyword4']['value'] =  date('Y-m-d H:i:s',time());
+            $data['keyword5']['value'] =  '您的商品已经发货请注意查收';
+            $formId = RoutineFormId::getFormIdOne($order['uid']);
+            if($formId){
+                RoutineFormId::delFormIdOne($formId);
+                RoutineTemplateService::sendTemplate($routine_openid,
+                    RoutineTemplateService::setTemplateId(RoutineTemplateService::ORDER_DELIVER_SUCCESS),
+                    '',
+                    $data,
+                    $formId);
+            }
+        }else if($postageData['delivery_type'] == 'express'){//发货
+            $data['keyword1']['value'] =  $order['order_id'];
+            $data['keyword2']['value'] =  $order['delivery_name'];
+            $data['keyword3']['value'] =  $order['delivery_id'];
+            $data['keyword4']['value'] =  date('Y-m-d H:i:s',time());
+            $data['keyword5']['value'] =  '您的商品已经发货请注意查收';
+            $formId = RoutineFormId::getFormIdOne($order['uid']);
+            if($formId){
+                RoutineFormId::delFormIdOne($formId);
+                RoutineTemplateService::sendTemplate($routine_openid,
+                    RoutineTemplateService::setTemplateId(RoutineTemplateService::ORDER_POSTAGE_SUCCESS),
+                    '',
+                    $data,
+                    $formId);
+            }
+        }
+    }
+
 
     /**
      * 获取订单总数

+ 33 - 0
application/admin/model/order/StoreOrderCartInfo.php

@@ -0,0 +1,33 @@
+<?php
+/**
+ *
+ * @author: xaboy<365615158@qq.com>
+ * @day: 2017/12/26
+ */
+
+namespace app\admin\model\order;
+
+
+use basic\ModelBasic;
+use traits\ModelTrait;
+
+class StoreOrderCartInfo extends ModelBasic
+{
+    use ModelTrait;
+
+    /** 获取订单产品列表
+     * @param $oid
+     * @return array
+     */
+    public static function getProductNameList($oid)
+    {
+        $cartInfo = self::where('oid',$oid)->select();
+        $goodsName = [];
+        foreach ($cartInfo as $cart){
+            $suk = isset($cart['cart_info']['productInfo']['attrInfo']) ? '('.$cart['cart_info']['productInfo']['attrInfo']['suk'].')' : '';
+            $goodsName[] = $cart['cart_info']['productInfo']['store_name'].$suk;
+        }
+        return $goodsName;
+    }
+
+}

+ 43 - 0
application/admin/model/routine/RoutineFormId.php

@@ -0,0 +1,43 @@
+<?php
+namespace  app\admin\model\routine;
+
+use basic\ModelBasic;
+use traits\ModelTrait;
+
+/**
+ * 表单ID表
+ * Class RoutineFormId
+ * @package app\routine\model\routine
+ */
+class RoutineFormId extends ModelBasic {
+
+    use ModelTrait;
+
+    /**
+     * 删除已失效的formID
+     * @return int
+     */
+    public static function delStatusInvalid(){
+        return self::where('status',2)->where('stop_time','LT',time())->delete();
+    }
+
+    /**
+     * 获取一个可以使用的formId
+     * @return bool|mixed
+     */
+    public static function getFormIdOne($uid = 0){
+        $formId = self::where('status',1)->where('stop_time','GT',time())->where('uid',$uid)->order('id asc')->find();
+        if($formId) return $formId['form_id'];
+        else return false;
+    }
+
+    /**
+     * 修改一个FormID为已使用
+     * @param string $formId
+     * @return $this|bool
+     */
+    public static function delFormIdOne($formId = ''){
+        if($formId == '') return true;
+        return self::where('form_id',$formId)->update(['status'=>2]);
+    }
+}

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
application/admin/model/user/User.php


+ 51 - 0
application/admin/model/user/UserAddress.php

@@ -0,0 +1,51 @@
+<?php
+/**
+ *
+ * @author: xaboy<365615158@qq.com>
+ * @day: 2017/12/25
+ */
+
+namespace app\admin\model\user;
+
+
+use basic\ModelBasic;
+use traits\ModelTrait;
+
+class UserAddress extends ModelBasic
+{
+    use ModelTrait;
+
+    protected $insert = ['add_time'];
+
+    protected function setAddTimeAttr()
+    {
+        return time();
+    }
+
+    public static function setDefaultAddress($id,$uid)
+    {
+        self::beginTrans();
+        $res1 = self::where('uid',$uid)->update(['is_default'=>0]);
+        $res2 = self::where('id',$id)->where('uid',$uid)->update(['is_default'=>1]);
+        $res =$res1 !== false && $res2 !== false;
+        self::checkTrans($res);
+        return $res;
+    }
+
+    public static function userValidAddressWhere($model=null,$prefix = '')
+    {
+        if($prefix) $prefix .='.';
+        $model = self::getSelfModel($model);
+        return $model->where("{$prefix}is_del",0);
+    }
+
+    public static function getUserValidAddressList($uid,$field = '*')
+    {
+        return self::userValidAddressWhere()->where('uid',$uid)->order('add_time DESC')->field($field)->select()->toArray()?:[];
+    }
+
+    public static function getUserDefaultAddress($uid,$field = '*')
+    {
+        return self::userValidAddressWhere()->where('uid',$uid)->where('is_default',1)->field($field)->find();
+    }
+}

+ 18 - 3
application/admin/model/wechat/WechatUser.php

@@ -33,7 +33,7 @@ use service\SystemConfigService;
     protected $insert = ['add_time'];
 
      /**
-      * 用uid获得openid
+      * 用uid获得 微信openid
       * @param $uid
       * @return mixed
       */
@@ -47,6 +47,21 @@ use service\SystemConfigService;
          Cache::set($cacheName,$openid,0);
          return $openid;
      }
+     /**
+      * 用uid获得 小程序 openid
+      * @param $uid
+      * @return mixed
+      */
+     public static function uidToRoutineOpenid($uid,$update = false)
+     {
+         $cacheName = 'routine_openid'.$uid;
+         $openid = Cache::get($cacheName);
+         if($openid && !$update) return $openid;
+         $openid = self::where('uid',$uid)->value('routine_openid');
+         if(!$openid) exception('对应的routine_openid不存在!');
+         Cache::set($cacheName,$openid,0);
+         return $openid;
+     }
 
     public static function setAddTimeAttr($value)
     {
@@ -145,7 +160,7 @@ use service\SystemConfigService;
      * @return array
      */
     public static function agentSystemPage($where = array(),$isall=false){
-        self::setWechatUserOrder();//设置 一级推荐人 二级推荐人 一级推荐人订单 二级推荐人订单 佣金
+//        self::setWechatUserOrder();//设置 一级推荐人 二级推荐人 一级推荐人订单 二级推荐人订单 佣金
         $model = new self;
         if($isall==false) {
             $status = (int)SystemConfigService::get('store_brokerage_statu');
@@ -200,7 +215,7 @@ use service\SystemConfigService;
                 ->ExcelSave();
         }
         return self::page($model,function ($item){
-            $item['qr_code'] = QrcodeService::getForeverQrcode('spread',$item['uid'])?:'';
+            $item['qr_code'] = QrcodeService::getForeverQrcode('spread',$item['uid']);
             $item['extract_count_price'] = UserExtract::getUserCountPrice($item['uid']);//累计提现
             $item['extract_count_num'] = UserExtract::getUserCountNum($item['uid']);//提现次数
         },$where);

+ 1 - 0
application/admin/view/order/store_order/index.php

@@ -486,6 +486,7 @@
                     });
                 },
                 search:function () {
+                    this.where.excel=0;
                     this.getBadge();
                     layList.reload(this.where);
                 },

+ 1 - 34
application/routine/model/routine/RoutineTemplate.php

@@ -86,38 +86,5 @@ class RoutineTemplate{
         RoutineFormId::delFormIdOne($formId);
         RoutineTemplateService::sendTemplate(WechatUser::getOpenId($order['uid']),RoutineTemplateService::setTemplateId(RoutineTemplateService::ORDER_PAY_SUCCESS),'',$data,$formId);
     }
-    /**
-     * 订单发货提醒
-     * @param int $oid
-     * @param array $postageData
-     * @return bool
-     */
-    public static function sendOrderGoods($oid = 0,$postageData=array()){
-        if(!$oid || !$postageData) return true;
-        $order = StoreOrder::where('id',$oid)->find();
-        if(!RoutineUser::isRoutineUser($order['uid'])) return true;
-        if($postageData['delivery_type'] == 'send'){//送货
-            $data['keyword1']['value'] =  $order['order_id'];
-            $data['keyword2']['value'] =  $order['delivery_name'];
-            $data['keyword3']['value'] =  $order['delivery_id'];
-            $data['keyword4']['value'] =  date('Y-m-d H:i:s',time());
-            $data['keyword5']['value'] =  '您的商品已经发货请注意查收';
-            $formId = RoutineFormId::getFormIdOne($order['uid']);
-            if($formId){
-                RoutineFormId::delFormIdOne($formId);
-                RoutineTemplateService::sendTemplate(WechatUser::getOpenId($order['uid']),RoutineTemplateService::setTemplateId(RoutineTemplateService::ORDER_DELIVER_SUCCESS),'',$data,$formId);
-            }
-        }else if($postageData['delivery_type'] == 'express'){//发货
-            $data['keyword1']['value'] =  $order['order_id'];
-            $data['keyword2']['value'] =  $order['delivery_name'];
-            $data['keyword3']['value'] =  $order['delivery_id'];
-            $data['keyword4']['value'] =  date('Y-m-d H:i:s',time());
-            $data['keyword5']['value'] =  '您的商品已经发货请注意查收';
-            $formId = RoutineFormId::getFormIdOne($order['uid']);
-            if($formId){
-                RoutineFormId::delFormIdOne($formId);
-                RoutineTemplateService::sendTemplate(WechatUser::getOpenId($order['uid']),RoutineTemplateService::setTemplateId(RoutineTemplateService::ORDER_POSTAGE_SUCCESS),'',$data,$formId);
-            }
-        }
-    }
+
 }