nan.zhang 4 роки тому
батько
коміт
1bd51bedca
55 змінених файлів з 6305 додано та 1 видалено
  1. 1 1
      application/expand/controller/WechatPay.php
  2. 692 0
      application/index/controller/Activity.php
  3. 192 0
      application/index/controller/Alipay.php
  4. 20 0
      application/index/controller/Auth.php
  5. 67 0
      application/index/controller/CmsController.php
  6. 611 0
      application/index/controller/Hotel.php
  7. 36 0
      application/index/controller/Index.php
  8. 185 0
      application/index/controller/Photo.php
  9. 999 0
      application/index/controller/Product.php
  10. 154 0
      application/index/controller/ShortUrl.php
  11. 92 0
      application/index/controller/Sms.php
  12. 1020 0
      application/index/controller/Wechat.php
  13. 480 0
      application/index/controller/WechatJs.php
  14. 8 0
      application/index/model/AliPayRecordModel.php
  15. 11 0
      application/index/model/AuthCompanyModel.php
  16. 12 0
      application/index/model/AuthModel.php
  17. 113 0
      application/index/model/BaseModel.php
  18. 22 0
      application/index/model/BuyCarModel.php
  19. 21 0
      application/index/model/LogApiModel.php
  20. 8 0
      application/index/model/ProductAttrModel.php
  21. 7 0
      application/index/model/ProductAttrValueModel.php
  22. 8 0
      application/index/model/ProductCategoryModel.php
  23. 7 0
      application/index/model/ProductImgModel.php
  24. 8 0
      application/index/model/ProductModel.php
  25. 8 0
      application/index/model/ProductOrderDetailModel.php
  26. 31 0
      application/index/model/ProductOrderModel.php
  27. 8 0
      application/index/model/RelProductAttrModel.php
  28. 7 0
      application/index/model/ShortUrlModel.php
  29. 17 0
      application/index/model/TokenModel.php
  30. 8 0
      application/index/model/UserAddressModel.php
  31. 8 0
      application/index/model/WxPayRecordModel.php
  32. 69 0
      application/index/model/activity/ActivityModel.php
  33. 9 0
      application/index/model/activity/ActivityOrderDetailModel.php
  34. 25 0
      application/index/model/activity/ActivityOrderModel.php
  35. 10 0
      application/index/model/activity/ActivityPriceModel.php
  36. 10 0
      application/index/model/activity/ActivityTimeModel.php
  37. 25 0
      application/index/model/activity/CollectionModel.php
  38. 10 0
      application/index/model/activity/WxPayRecordModel.php
  39. 10 0
      application/index/model/hotel/HotelModel.php
  40. 14 0
      application/index/model/hotel/OrderModel.php
  41. 37 0
      application/index/model/hotel/RoomModel.php
  42. 10 0
      application/index/model/hotel/WxPayRecordModel.php
  43. 35 0
      application/index/service/ActivityService.php
  44. 64 0
      application/index/service/AuthService.php
  45. 26 0
      application/index/service/BaseService.php
  46. 486 0
      application/index/service/HelperService.php
  47. 182 0
      application/index/service/ProductService.php
  48. 119 0
      application/index/service/SmsService.php
  49. 51 0
      application/index/service/TokenService.php
  50. 13 0
      application/index/service/alipay/AliPayConfig.php
  51. 34 0
      application/index/view/alipay/pay.html
  52. 15 0
      application/index/view/common/error.html
  53. 7 0
      application/index/view/wechat/oauth2.php
  54. 85 0
      application/index/view/wechat/wxPay.php
  55. 98 0
      application/index/view/wechat/wxPlatformPay.php

+ 1 - 1
application/expand/controller/WechatPay.php

@@ -257,7 +257,7 @@ class WechatPay extends BaseAuth
             HelperService::returnJson(['code'=>400,'msg'=>$validate->getError()],$params);
         }
 
-        require_once(APP_PATH.'/common/service/wechat/WxPayPubHelper.php');
+        require_once(APP_PATH.'/index/service/wechat/WxPayPubHelper.php');
         $Refund = new Refund_pub();
         $Refund->setParameter('out_trade_no',$params['out_trade_no']);
         $Refund->setParameter('out_refund_no',uniqid());

+ 692 - 0
application/index/controller/Activity.php

@@ -0,0 +1,692 @@
+<?php
+namespace app\index\controller;
+
+use app\index\model\activity\ActivityModel;
+use app\index\model\activity\ActivityOrderDetailModel;
+use app\index\model\activity\ActivityOrderModel;
+use app\index\model\activity\ActivityPriceModel;
+use app\index\model\activity\ActivityTimeModel;
+use app\index\model\activity\CollectionModel;
+use app\index\service\ActivityService;
+use app\index\service\HelperService;
+
+class Activity extends CmsController
+{
+
+    /**
+     * 添加活动接口
+     */
+    public function addActivity(){
+        $param_list = [
+            'title'=>'string',
+            'position_description'=>'string',
+            'contain'=>'int',
+            'telephone'=>'mobile',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $data = [
+            'activity_img'=>isset($this->post['activity_img'])?$this->post['activity_img']:'',
+            'title'=>$this->post['title'],
+            'sub_title'=>isset($this->post['sub_title'])?$this->post['sub_title']:'',
+            'show_param'=>isset($this->post['show_param'])?$this->post['show_param']:'',
+            'position_description'=>$this->post['position_description'],
+            'contain'=>$this->post['contain'],
+            'telephone'=>$this->post['telephone'],
+            'type'=>isset($this->post['type'])?$this->post['type']:0,
+            'status'=>0
+        ];
+
+        $activityModel = new ActivityModel();
+        $res = $activityModel->addInfo($data);
+
+        $this->returnJson($res);
+    }
+
+    /**
+     * 修改活动接口
+     */
+    public function updateActivity(){
+        $param_list = [
+            'activity_id'=>'number',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $data = [
+            'activity_img'=>isset($this->post['activity_img'])?$this->post['activity_img']:'',
+            'title'=>isset($this->post['title'])?$this->post['title']:'',
+            'sub_title'=>isset($this->post['sub_title'])?$this->post['sub_title']:'',
+            'position_description'=>isset($this->post['position_description'])?$this->post['position_description']:'',
+            'contain'=>isset($this->post['contain'])?$this->post['contain']:0,
+            'telephone'=>isset($this->post['telephone'])?$this->post['telephone']:'',
+            'show_param'=>isset($this->post['show_param'])?$this->post['show_param']:'',
+        ];
+
+        $data = array_filter($data);
+        if(isset($this->post['status'])){
+            $data['status'] = $this->post['status'];
+        }
+        if(isset($this->post['type'])){
+            $data['type']   = $this->post['type'];
+        }
+
+        $activityModel = new ActivityModel();
+        $row = $activityModel->upInfo(['activity_id'=>$this->post['activity_id']],$data);
+
+        $this->returnJson(['row'=>$row]);
+    }
+
+    /**
+     * 获取当前活动列表
+     */
+    public function getActivityList(){
+
+        $param_list = [
+            'user_id'=>'number',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $where = [
+            'activity.status'=>0,
+        ];
+        $activityModel = new ActivityModel();
+
+        $order = "sort desc,activity_id desc";
+        if(isset($this->post['type']) && is_numeric($this->post['type'])){
+            $order = "type <> {$this->post['type']},sort desc,activity_id desc";
+        }
+
+        $list = $activityModel->getListAndCollection($where,$order);
+
+        $collectionActivityIds = $activityModel->getCurrentUserCollectionList($this->post['user_id']);
+        foreach($list as &$item){
+            if(isset($collectionActivityIds[$item['activity_id']])){
+                $item['is_collection'] = 1;
+            }else{
+                $item['is_collection'] = 0;
+            }
+        }
+
+        $this->returnJson($list);
+    }
+
+    /**
+     * 获取当前活动列表
+     */
+    public function getActivityPage(){
+
+        $param_list = [
+            'page'=>'number',
+            'pageSize'=>'number',
+            'condition'=>'array'
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $search_key = ['title','telephone','status'];
+        $condition = $this->post['condition'];
+
+        $where = [];
+        foreach($condition as $key=>$item){
+            if(!in_array($key,$search_key)){
+                continue;
+            }
+            switch($key){
+                case "status":
+                    $where[$key] = $item;
+                    break;
+                case 'title':
+                case 'telephone':
+                    $where[$key] = ['like',"%{$item}%"];
+                    break;
+            }
+        }
+
+
+        $page = $this->post['page']>1?$this->post['page']:1;
+        $pageSize = $this->post['pageSize']>2?$this->post['pageSize']:2;
+
+        $activityModel = new ActivityModel();
+        $list = $activityModel->getPage($where,"sort desc,activity_id desc",
+            $page,$pageSize);
+
+        $this->returnJson($list);
+    }
+
+    /**
+     * 通过条件获取订单信息
+     */
+    public function getUserOrderByType(){
+        $param_list = [
+            'user_id'=>'number',
+            'status'=>'int'
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        if(!in_array($this->post['status'],[0,1,2,3,4,10])){
+            $this->returnJson([],400,'status is error');
+        }
+
+        $params = [];
+        $params['user_id'] = $this->post['user_id'];
+        if($this->post['status']!=10){
+            $params['status'] = $this->post['status'];
+        }
+
+        $activityOrderModel = new ActivityOrderModel();
+        $activityOrder = $activityOrderModel->getList($params,"activity_order_id desc",100);
+        if(empty($activityOrder)){
+            $activityOrder = [];
+        }else{
+            foreach($activityOrder as $key=>$item) {
+                $activityOrder[$key]['detail'] = $item['people_json']?json_decode($item['people_json']):[];
+                unset($activityOrder[$key]['people_json']);
+            }
+        }
+
+        $this->returnJson($activityOrder);
+    }
+
+    /**
+     * 用户每种类型订单的数量
+     */
+    public function getUserOrderCountByType(){
+        $param_list = [
+            'user_id'=>'number',
+            'status'=>'int'
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        if(!in_array($this->post['status'],[0,1,2,3,4,10])){
+            $this->returnJson([],400,'status is error');
+        }
+
+        $params = [];
+        $params['user_id'] = $this->post['user_id'];
+        if($this->post['status']!=10){
+            $params['status'] = $this->post['status'];
+        }
+
+        $activityOrderModel = new ActivityOrderModel();
+        $activityOrder = $activityOrderModel->where($params)->count();
+
+        $this->returnJson($activityOrder);
+    }
+
+    /**
+     * 前后台修改订单(通用)
+     */
+    public function saveOrderStatus(){
+        $param_list = [
+            'activity_order_no'=>'string',
+            'status'=>'number',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        if(!in_array($this->post['status'],[0,1,2,3,4])){
+            $this->returnJson([],400,'status is error');
+        }
+
+        $where = ['activity_order_no' => $this->post['activity_order_no']];
+        $data  = ['status' => $this->post['status']];
+
+
+        $activityOrderModel = new ActivityOrderModel();
+        $activityOrderModel->upInfo($where,$data);
+
+        $this->returnJson('success');
+    }
+
+
+    /**
+     * 根据订单编号或许订单详情
+     */
+    public function getOrderByOrderNo(){
+        $param_list = [
+            'activity_order_no'=>'string'
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $params = [];
+        $params['activity_order_no'] = $this->post['activity_order_no'];
+
+        $activityOrderModel = new ActivityOrderModel();
+        $activityOrder = $activityOrderModel->getOne($params);
+
+        $activityOrder['detail'] = $activityOrder['people_json']?json_decode($activityOrder['people_json']):[];
+        unset($activityOrder['people_json']);
+
+        $this->returnJson($activityOrder);
+    }
+
+    /**
+     * 加入到活动订单里面
+     */
+    public function addActivityOrder(){
+        $params_list = [
+            'user_id'=>'number',
+            'activity_id'=>'number',
+            'total_price'=>'number',
+            'total_people'=>'number',
+            'pay_style'=>'int',
+            'peopleType_num_price_array'=>'array',
+        ];
+
+        HelperService::diffParam($params_list,$this->post);
+
+        $data = [
+            'user_id'=>$this->post['user_id'],
+            'activity_id'=>$this->post['activity_id'],
+            'total_price'=>$this->post['total_price'],
+            'total_people'=>$this->post['total_people'],
+            'pay_style'=>$this->post['pay_style'],
+            'people_json'=>json_encode($this->post['peopleType_num_price_array']),
+            'add_time'=>time(),
+            'add_date'=>date('Y-m-d'),
+            'data'=>isset($this->post['data'])?$this->post['data']:'',
+            'status'=>0
+        ];
+
+        $uni_qid = uniqid();//为了保证子项业务先执行的机制,建立唯一字段关联
+        $data['activity_order_no'] = $uni_qid;
+        $row     = 0;//受影响的行数
+        $activityOrderDetailModel = new ActivityOrderDetailModel();
+        $peopleType_num_price_array = $this->post['peopleType_num_price_array'];
+        foreach($peopleType_num_price_array as $item) {
+            if (is_array($item) && isset($item['type']) && isset($item['num'])
+                && isset($item['single_price'])) {
+
+                $params = [
+                    'activity_order_no'=>$uni_qid,
+                    'people_type'=>$item['type'],
+                    'single_price'=>$item['single_price'],
+                    'people_num'=>$item['num'],
+                    'add_time'=>time(),
+                ];
+
+                $activityOrderDetail = $activityOrderDetailModel->addInfo($params);
+                if($activityOrderDetail){
+                    $row += 1;
+                }
+            }
+        }
+
+        if($row == 0){
+            $this->returnJson(null,400,'please give me a valid array of peopleType_num_price_array');
+        }
+
+        $activityOrderModel = new ActivityOrderModel();
+        $id = $activityOrderModel->addInfo($data);
+        $this->returnJson($uni_qid);
+    }
+
+
+    /**
+     * 获取各种类型的活动订单列表
+     */
+    public function ActivityOrderListByType(){
+        $params_list =[
+            'type'=>'int',
+            'user_id'=>'number'
+        ];
+
+        HelperService::diffParam($params_list,$this->post);
+
+        $activityService = new ActivityService();
+        $condition = [
+            'user_id' => $this->post['user_id']
+        ];
+
+        if(in_array($this->post['type'],[0,1,2,3])){
+            $condition['status'] = $this->post['type'];
+        }
+
+        $activityOrderList = $activityService->getActivityOrderListByCondition($condition);
+
+        foreach($activityOrderList as $key=>$activityOrder){
+            $activityOrderList[$key]['detail'] = json_decode($activityOrderList[$key]['people_json'],true);
+            unset($activityOrderList[$key]['people_json']);
+        }
+
+        $this->returnJson($activityOrderList);
+    }
+
+    /**
+     * 通过订单id获取订单信息
+     */
+    public function getActivityOrderInfoById(){
+        $param_list = [
+            'order_id'=>'number',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $activityOrderModel = new ActivityOrderModel();
+        $activityOrder = $activityOrderModel->getOne(['activity_order_id'=>$this->post['order_id']]);
+        if(!empty($activityOrder)){
+            $activityOrder['detail'] = json_decode($activityOrder['people_json'],true);
+            unset($activityOrder['people_json']);
+        }
+
+        $this->returnJson($activityOrder);
+    }
+
+    /**
+     * 获取活动订单分页
+     */
+    public function ActivityOrderPage(){
+        $params_list =[
+            'page'=>'number',
+            'pageSize'=>'number',
+            'condition'=>'array',
+        ];
+
+        HelperService::diffParam($params_list,$this->post);
+
+        $activityService = new ActivityService();
+
+        $page     = $this->post['page'] >1?$this->post['page']:1;
+        $pageSize = $this->post['pageSize'] >2? $this->post['pageSize']:2;
+
+        $condition = $this->post['condition'];
+        $where = [
+            'user_id'=>isset($condition['user_id'])?$condition['user_id']:0,
+            'activity_id'=>isset($condition['activity_id'])?$condition['activity_id']:0,
+        ];
+
+        $where = array_filter($where);
+
+        if(isset($condition['status']) && is_numeric($condition['status'])
+            && in_array($condition['status'],[0,1,2,3])){
+            $where['status'] = $condition['status'];
+        }
+
+        $activityOrderList = $activityService->getActivityOrderPageByCondition($where,'activity_id desc',$page,$pageSize);
+
+        foreach($activityOrderList['list'] as $key=>$activityOrder){
+
+            $activityOrderList['list'][$key]['detail'] = !empty($activityOrder['people_json'])?json_decode($activityOrder['people_json'],true):[];
+            unset($activityOrderList['list'][$key]['people_json']);
+        }
+
+        $this->returnJson($activityOrderList);
+    }
+
+
+    /**
+     * 针对于活动订单的处理
+     */
+    public function dealActivityOrder(){
+        $param_list = [
+            'activity_order_id'=>'number',
+            'status'=>'number',
+        ];
+
+        HelperService::diffParam($param_list,$this->post);
+        if(!in_array($this->post['status'],[0,1,2,3])){
+            $this->returnJson('',400,'status is error');
+        }
+
+        $data = [
+           'status'=>$this->post['status'],
+        ];
+        if(isset($this->post['note']) && !empty($this->post['note'])){
+            $data['note'] = $this->post['note'];
+        }
+
+        $activityOrderModel = new ActivityOrderModel();
+        $row = $activityOrderModel->upInfo([
+            'activity_order_id'=>$this->post['activity_order_id']
+        ],$data);
+
+        $this->returnJson(['row'=>$row]);
+    }
+
+    /**
+     * 根据活动id获取活动信息
+     */
+    public function getActivityInfoById(){
+        $param_list = [
+            'activity_id'=>'number',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $activityModel = new ActivityModel();
+        $activity = $activityModel->getOne(['activity_id'=>$this->post['activity_id']]);
+
+        $this->returnJson($activity);
+    }
+
+    /**
+     *活动每日订单数量
+     */
+    public function ActivityOrderDayNum(){
+        $param = $this->request->param();
+        $end_date = isset($param['end_date'])?strtotime($param['end_date']):strtotime("-1 seconds",strtotime(date('Y-m-d')));
+        $start_date = isset($param['start_date'])?strtotime($param['start_date']):0;
+
+        //控制时间,以免增加服务器压力
+        if(empty($start_date) || $end_date-$start_date>86400*20){
+            $start_date = $end_date-86400*20;
+        }
+
+        $activityOrderModel = new ActivityOrderModel();
+        $activityOrder = $activityOrderModel
+            ->field('count(activity_order_id) as total_count,add_date')
+            ->where(['add_date'=>['between',[date('Y-m-d',$start_date),date('Y-m-d',$end_date)]]])->group('add_date')->cache(3600*2)->select();
+        $this->returnJson($activityOrder);
+    }
+
+    /**
+     *订单总数量
+     */
+    public function totalOrderNum(){
+        $activityOrderModel = new ActivityOrderModel();
+        $activityOrder = $activityOrderModel->cache(10)->count();
+
+        $this->returnJson(['count'=>$activityOrder]);
+    }
+
+    /**
+     * 根据活动id获取活动信息
+     */
+    public function getActivityInfoByIdAndUserId(){
+        $param_list = [
+            'activity_id'=>'number',
+            'user_id'=>'int',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $activityModel = new ActivityModel();
+        $activity = $activityModel->getOne(['activity_id'=>$this->post['activity_id']]);
+
+        //判断当前的人是否收藏了该活动
+        $is_collection = $activityModel->getCurrentUserIsCollection(
+              $this->post['user_id'],
+              $this->post['activity_id']
+        );
+
+        //获取当前活动时间的信息
+        $activityTime = new ActivityTimeModel();
+        $time_arr = $activityTime->getList(['activity_id'=>$this->post['activity_id']]);
+
+        $activity['is_collection'] = empty($is_collection)?0:1;
+        $activity['time_arr'] = empty($time_arr)?[]:$time_arr;
+        $activity['collection_num'] = $activityModel->getCollectionCount($this->post['activity_id']);
+
+        $this->returnJson($activity);
+    }
+
+
+    /**
+     * 保存活动收藏
+     */
+    public function saveCollection(){
+        $param_list = [
+            'user_id'=>'number',
+            'activity_id'=>'number',
+            'status'=>'int'
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $data = [
+            'user_id'=>$this->post['user_id'],
+            'activity_id'=>$this->post['activity_id'],
+            'status'=>$this->post['status']
+        ];
+
+        $collectionModel = new CollectionModel();
+        //判断活动是否存在
+        $collection = $collectionModel->getOne(['user_id'=>$data['user_id'],'activity_id'=>$data['activity_id']]);
+
+        if(empty($collection) && $this->post['status'] == 0) {
+            $data['add_time'] = time();
+            $id = $collectionModel->addInfo($data);
+            $this->returnJson(['id'=>$id]);
+        }else{
+            if($this->post['status'] == 0) {
+                $row = $collectionModel->upInfo(['id' => $collection['id']], $data);
+                $this->returnJson(['row' => $row]);
+            }else{
+                $row = $collectionModel->where(['id' => $collection['id']])->delete();
+                $this->returnJson(['row' => $row]);
+            }
+        }
+
+    }
+
+    /**
+     * 获取用户的收藏列表
+     */
+    public function getCollectionByUid(){
+        $param_list = [
+            'user_id'=>'number',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $collectionModel = new CollectionModel();
+        $collection = $collectionModel->getActivityCollection(
+            ['user_id'=>$this->post['user_id']]
+        );
+
+        $this->returnJson($collection);
+    }
+
+    /**
+     * 活动保存价格的接口
+     */
+    public function saveActivityPrice(){
+        $param_list = [
+            'activity_id'=>'number',
+            'people_price_array'=>'array'
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        //首先删除这个活动的所有价格,然后再去填充数据库
+        $activityPriceModel = new ActivityPriceModel();
+        $activityPriceModel->where(['activity_id'=>$this->post['activity_id']])->delete();
+        //拆分数组
+        $people_price_array = $this->post['people_price_array'];
+        $row = 0;
+        foreach($people_price_array as $key=>$item){
+            if(is_numeric($item)){
+                $id = $activityPriceModel->addInfo([
+                    'activity_id'=>$this->post['activity_id'],
+                    'people_type'=>$key,
+                    'price'=>$item,
+                ]);
+
+                if($id){
+                    $row += 1;
+                }
+            }
+        }
+
+        $this->returnJson(['row'=>$row]);
+    }
+
+
+
+    /**
+     * 活动保存价格的接口
+     */
+    public function saveActivityTime(){
+        $param_list = [
+            'activity_id'=>'number',
+            'start_end_time_sort_array'=>'array'
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        //首先删除这个活动的所有时间,然后再去填充数据库
+        $activityTimeModel = new ActivityTimeModel();
+        $activityTimeModel->where(['activity_id'=>$this->post['activity_id']])->delete();
+        //拆分数组
+        $start_end_time_sort_array = $this->post['start_end_time_sort_array'];
+        $row = 0;
+        foreach($start_end_time_sort_array as $item){
+            if(is_array($item) && isset($item['start_time'])
+                && isset($item['end_time']) && isset($item['sort'])){
+                $id = $activityTimeModel->addInfo([
+                    'activity_id'=>$this->post['activity_id'],
+                    'start_time'=>intval($item['start_time']),
+                    'end_time'=>intval($item['end_time']),
+                    'sort'=>intval($item['sort']),
+                ]);
+
+                if($id){
+                    $row += 1;
+                }
+            }
+        }
+
+        $this->returnJson(['row'=>$row]);
+    }
+
+
+    /**
+     * 获取活动时间列表
+     */
+    public function getActivityTimeList(){
+        $param_list = [
+            'activity_id'=>'number',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $activityTimeModel = new ActivityTimeModel();
+        $list = $activityTimeModel->getList(['activity_id'=>$this->post['activity_id']],
+            'sort desc,id desc',100);
+
+        $this->returnJson($list);
+    }
+
+
+    /**
+     *获取活动价格
+     */
+    public function getActivityPriceList(){
+        $param_list = [
+            'activity_id'=>'number',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $activityPriceModel = new ActivityPriceModel();
+        $activityPriceList = $activityPriceModel->where(['activity_id'=>$this->post['activity_id']])->select();
+
+        $this->returnJson($activityPriceList);
+    }
+
+    /**
+     * 获取活动最新关注的人
+     */
+    public function getNewOrderByActivityId(){
+        $param_list = [
+            'activity_id'=>'int',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $activityOrderModel = new ActivityOrderModel();
+
+        $limit = isset($this->post['limit'])?intval($this->post['limit']):10;
+        $activityOrderList  = $activityOrderModel->getOrderListByActivityId($this->post['activity_id'],$limit,"user_id");
+
+        $this->returnJson($activityOrderList);
+    }
+}

+ 192 - 0
application/index/controller/Alipay.php

@@ -0,0 +1,192 @@
+<?php
+namespace app\index\controller;
+use alipay\Wappay;
+use app\index\model\AliPayRecordModel;
+use app\index\model\AuthCompanyModel;
+use app\index\service\HelperService;
+use think\Controller;
+use think\Log;
+use think\Validate;
+
+/**
+ * 功能:支付宝手机网站支付接口(alipay.trade.wap.pay)接口调试入口页面
+ * 版本:2.0
+ * 修改日期:2016-11-01
+ * 说明:
+ * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。请确保项目文件有可写权限,不然打印不了日志。
+ */
+
+class Alipay extends Controller
+{
+    public function PlatformAlipay(){
+
+        $params = $this->request->param();
+
+        $rule = [
+            'return_url'=>'require',
+            'out_trade_no'=>'require',
+            'total_amount'=>'require',
+            'discountable_amount'=>'require',
+            'subject'=>'require',
+            //'body'=>'require',
+            //goods_id,goods_name,quantity,price,goods_category,body,show_url
+            'goods_detail'=>'isset',
+            'store_id'=>'isset',
+            'terminal_id'=>'isset',
+            'extend_params'=>'isset',
+            'company_code'=>'require'
+        ];
+
+        $validate = new Validate($rule);
+        if(!$validate->check($params)){
+            HelperService::returnJson(['code'=>400,'msg'=>$validate->getError()]);
+        }
+        Log::record($params);
+        
+        $companyCode = $params['company_code'];
+        unset($params['company_code']);
+        
+        if(!file_exists("./$companyCode/alipay/app_private_key.pem")){
+            $this->error('很抱歉,暂不支持支付宝平台');
+        }
+
+        $body = "";
+        $goods_detail = isset($params['goods_detail'])?json_decode($params['goods_detail'],true):'';
+//        if(!empty($goods_detail)){
+//            $body .= '消费详情:';
+//            foreach($goods_detail as $key=>$item){
+//                $list_no = $key+1;
+//                $body .= " ({$list_no})、{$item['goods_name']}x{$item['quantity']}份 = {$item['price']}元;";
+//            }
+//        }
+
+//        try {
+            //$out_trade_no_arr = explode('_',"{$params['out_trade_no']}");
+            $order_no = @reset(explode('_',"{$params['out_trade_no']}"));
+
+            //判断改公司是否存在
+            $companySmsJson = $this->_companyExist($companyCode);
+
+            if ($companySmsJson === false) {
+                die("<script>window.alert = function(name){var iframe = document.createElement('IFRAME');iframe.style.display='none';iframe.setAttribute('src', 'data:text/plain,');document.documentElement.appendChild(iframe);window.frames[0].window.alert(name);iframe.parentNode.removeChild(iframe);};alert('公司不存在!');window.history.go(-1);</script>");
+            }
+
+            //判断订单号是否已经支付过
+            $AliPayRecordModel = new AliPayRecordModel();
+            $AliPayRecord = $AliPayRecordModel->where(['order_no' => "{$order_no}", 'company_code' => "{$companyCode}"])->find();
+            if (!empty($AliPayRecord)) {
+                die("<script>window.alert = function(name){var iframe = document.createElement('IFRAME');iframe.style.display='none';iframe.setAttribute('src', 'data:text/plain,');document.documentElement.appendChild(iframe);window.frames[0].window.alert(name);iframe.parentNode.removeChild(iframe);};alert('该订单已经支付');window.history.go(-1);</script>");
+            }
+
+            Log::record('ALIPAY-SQL'.$AliPayRecordModel->getLastSql());
+
+            $submitForm = Wappay::pay(array_filter([
+                'out_trade_no' => $params['out_trade_no'],
+                'subject' => "{$params['subject']}",//售卖项目(Iphone6 16G)
+                'total_amount' => $params['total_amount'],
+                'discountable_amount' => $params['discountable_amount'],
+                'body' => $body,
+                //'goods_detail'=>$goods_detail,
+                'auth_token' => isset($companySmsJson['app_auth_token'])?$companySmsJson['app_auth_token']:"",
+                'extend_params'=>isset($companySmsJson['sys_service_provider_id'])?['sys_service_provider_id'=>$companySmsJson['sys_service_provider_id']]:[],
+                'seller_id' => isset($companySmsJson['ali_seller_id'])?$companySmsJson['ali_seller_id']:"",
+                'operator_id' => isset($params['operator_id']) ? $params['operator_id'] : 'ky_vapi',
+                'terminal_id' => $params['terminal_id'],
+                'timeout_express' => '1m'
+            ]), [
+                'gatewayUrl' => 'https://openapi.alipay.com/gateway.do',
+                //'app_id' => $params['app_id'],
+                'app_id' => $companySmsJson['app_id'],
+                'merchant_private_key' => file_get_contents("./$companyCode/alipay/app_private_key.pem"),
+                'alipay_public_key' => file_get_contents("./$companyCode/alipay/app_public_key.pem"),
+                'sign_type' => isset($companySmsJson['sign_type'])?$companySmsJson['sign_type']:'RSA2',
+                'format' => 'JSON',
+                'return_url' => $params['return_url'],
+                'notify_url' => 'http://' . $_SERVER['SERVER_NAME'] . '/index/Alipay/notifyPlatformAlipay',
+            ]);
+
+            Log::record("$submitForm");
+            $this->assign('submitForm', $submitForm);
+
+//        }catch (\Exception $ex){
+//            die("<script>window.alert = function(name){var iframe = document.createElement('IFRAME');iframe.style.display='none';iframe.setAttribute('src', 'data:text/plain,');document.documentElement.appendChild(iframe);window.frames[0].window.alert(name);iframe.parentNode.removeChild(iframe);};alert('".$ex->getMessage()."');window.history.go(-1);</script>");
+//        }
+
+        return $this->fetch('alipay/pay');
+    }
+
+
+    private function _companyExist($companyCode){
+        $AuthCompanyModel = new AuthCompanyModel();
+        $companyInfo = $AuthCompanyModel->getInfo(['company_code'=>$companyCode]);
+        if(empty($companyInfo) || empty($companyInfo['sms_json'])){
+            return false;
+        }
+        return json_decode($companyInfo['sms_json'],true);
+    }
+
+    public function notifyPlatformAlipay(){
+        $params = $this->request->param();
+
+        try {
+            $AliPayRecordModel = new AliPayRecordModel();
+            $res = $AliPayRecordModel->where(['out_trade_no'=>"{$params['out_trade_no']}"])->find();
+            if(!empty($res)){
+                die('success');
+            }
+            
+            $out_trade_no_arr = explode('_', "{$params['out_trade_no']}");
+            $order_no = current($out_trade_no_arr);
+            $companyCode = end($out_trade_no_arr);
+
+            $data = [
+                'order_no' => "{$order_no}",
+                'total_fee' => "{$params['total_amount']}",
+                'out_trade_no' => "{$params['out_trade_no']}",
+                'add_ts' => time(),
+                'alipay_msg' => json_encode($params),
+                'trade_no' => "{$params['trade_no']}",
+                'company_code' => $companyCode,
+            ];
+
+          try{
+            $AliPayRecordModel->save($data);
+          }  catch (\Exception $ex){
+              Log::record('重复插入记录'.$ex->getMessage());
+              die('success');
+          }
+
+            $companyInfo = $this->_validCompanyCode($companyCode);
+            if ($companyInfo === false) {
+                Log::record('notifyPlatformAlipay:公司信息不存在');
+                die('fail(company dont have)');
+            }
+
+            $smsJson = json_decode($companyInfo['sms_json'], true);
+            if (isset($smsJson['alipay_url'])) {
+                $url = $smsJson['alipay_url'];
+                $url = strpos($url,'?')>0?$url."&":$url."?";
+                $url = $url."order_no=$order_no&out_trade_no={$params['out_trade_no']}&total_amount={$params['total_amount']}";
+                HelperService::httpPost("{$url}", json_encode($data));
+                Log::record('notifyPlatformAlipay:success');
+                die('success');
+            }
+
+            Log::record('notifyPlatformAlipay:alipay_url dont have');
+            die('fail(alipay_url dont have)');
+        }catch (\Exception $ex){
+            $datetime = date('Y-m-d H:i:s');
+            Log::record("[$datetime]notifyPlatformAlipay:".$ex->getMessage());
+        }
+    }
+
+    private function _validCompanyCode($companyCode){
+
+        $AuthCompanyModel = new AuthCompanyModel();
+        $company = $AuthCompanyModel->getInfo(['company_code'=>"$companyCode"]);
+        if(empty($company)){
+            return false;
+        }
+        return $company;
+    }
+}

+ 20 - 0
application/index/controller/Auth.php

@@ -0,0 +1,20 @@
+<?php
+namespace app\index\controller;
+use app\index\service\AuthService;
+use app\index\service\HelperService;
+use think\Controller;
+
+
+class Auth extends Controller
+{
+    public function authorization()
+    {
+        $post = $this->request->post();
+        $param_list = ['account'=>'string','password'=>'string'];
+        HelperService::diffParam($param_list,$post);
+
+        $AuthService = new AuthService();
+        $res = $AuthService->checkAuth($post);
+        die(HelperService::returnParam($res));
+    }
+}

+ 67 - 0
application/index/controller/CmsController.php

@@ -0,0 +1,67 @@
+<?php
+namespace app\index\controller;
+use app\index\service\HelperService;
+use app\index\service\TokenService;
+use \think\Controller;
+
+
+class CmsController extends Controller
+{
+    public $post = [];
+    public $allowCompany = [
+        'YAWY','YTMALL','GREENLNNHOTEL','VOWKIN','TMZJ','VWHEEL','JINRONGYUAN',
+        'CCHLK','MISAP','AYKJ','ALJL','YLBG','SMDD','GD','RHZB',"WPCW"
+    ];
+
+    public function _initialize()
+    {
+        HelperService::$_startExecTime = microtime(true);
+        $params_list = ['token'=>'string','companyCode'=>'string'];
+        $this->post = $this->request->post();
+        //跳过验证的特殊办法
+        if(isset($this->request->param()['leo_debug'])
+            && $this->request->param()['leo_debug']== 'leo'){
+
+            return true;
+        }
+        HelperService::diffParam($params_list,$this->post);
+
+        $TokenService = new TokenService();
+        $res = $TokenService->checkToken($this->post);
+        if($res !== true){
+            HelperService::returnJson($res);
+        }else{
+            unset($this->post['token']);
+        }
+    }
+
+    protected function returnJson($data,$code=200,$msg='success'){
+        HelperService::returnJson([
+            'code'=>$code,
+            'msg'=>$msg,
+            'data'=>$data
+        ]);
+    }
+
+    protected function toArray($res){
+        $data = [];
+        if(!empty($res)){
+            foreach($res as $k=>$v){
+                $data[] = $res[$k]->toArray();
+            }
+        }
+        return $data ;
+    }
+
+    /**
+     * 生成订单号
+     * @return string
+     */
+    protected function createOrderNum(){
+        $key = date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 4, 5);
+        $key.=rand(100,999);
+        usleep(1000);
+        return $key;
+    }
+
+}

+ 611 - 0
application/index/controller/Hotel.php

@@ -0,0 +1,611 @@
+<?php
+namespace app\index\controller;
+
+use app\index\model\hotel\HotelModel;
+use app\index\model\hotel\OrderModel;
+use app\index\model\hotel\RoomModel;
+use app\index\service\HelperService;
+
+class Hotel extends CmsController
+{
+
+    public function _initialize(){
+        parent::_initialize();
+        //结束掉,订单结束时间小于当前时间的支付完成的订单
+        $this->_endOrder();
+    }
+
+    /**
+     * 将已支付的,并且结束时间到期的订单结束掉
+     */
+    private function _endOrder(){
+        $date = date('Y-m-d');
+        $hours = date('H');
+        if($hours > 13){
+            $orderModel = new OrderModel();
+            $orderModel->upInfo(['status'=>1,'end_date'=>['elt',$date]],['status'=>3]);
+        }else{
+            $orderModel = new OrderModel();
+            $orderModel->upInfo(['status'=>1,'end_date'=>['lt',$date]],['status'=>3]);
+        }
+    }
+    /**
+     * 通过条件获取房间类型的分页
+     */
+    public function getRoomPageByCondition(){
+        $param_list = [
+            'page'=>'number',
+            'pageSize'=>'number',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $where = [];
+        //判断可选项 hotel_id
+        if(isset($this->post['hotel_id']) && is_numeric($this->post['hotel_id'])){
+            $where['hotel_id'] = $this->post['hotel_id'];
+        }
+
+        //判断可选项 room_name
+        if(isset($this->post['room_name']) && is_string($this->post['room_name'])){
+            $where['room_name'] = ['like',"%{$this->post['room_name']}%"];
+        }
+        //判断可选项 status
+        if(isset($this->post['status']) && is_numeric($this->post['status'])){
+            $where['status'] = $this->post['status'];
+        }
+
+        $page = $this->post['page']>1?$this->post['page']:1;
+        $pageSize = $this->post['pageSize']>2?$this->post['pageSize']:2;
+
+        $roomModel = new RoomModel();
+        $roomList = $roomModel->getPage($where,'sort desc,room_id desc',$page,$pageSize);
+
+        //取出list部分
+        $list = $roomList['list'];
+        $hotelModel = new HotelModel();
+        //获取当前所有的正常运行的hotel
+        $hotel_list = $hotelModel->getList(['status'=>0],'',1000);
+        $hotel_list = $this->toArray($hotel_list);
+        $hotel_list = array_column($hotel_list,'hotel_name','hotel_id');
+        foreach($list as &$item){
+            $item['hotel_name'] = $hotel_list[$item['hotel_id']];
+            $item['room_imgs']  = $item['room_imgs']?json_decode($item['room_imgs'],true):$item['room_imgs'];
+            $item['base_info']  = $item['base_info']?json_decode($item['base_info'],true):$item['base_info'];
+            $item['base_attr']  = $item['base_attr']?json_decode($item['base_attr'],true):$item['base_attr'];
+            $item['base_other'] = $item['base_other']?json_decode($item['base_other'],true):$item['base_other'];
+        }
+
+        $roomList['list'] = $list;
+        $this->returnJson($roomList);
+    }
+
+    /**
+     * 获取房间信息,通过room_id
+     */
+    public function getRoomInfoByRoomId(){
+        $param_list = [
+            'room_id'=>'number',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $roomModel = new RoomModel();
+        $roomInfo = $roomModel->getOne(['room_id'=>$this->post['room_id']]);
+
+        $roomInfo['room_imgs']  = $roomInfo['room_imgs']?json_decode($roomInfo['room_imgs'],true):$roomInfo['room_imgs'];
+        $roomInfo['base_info']  = $roomInfo['base_info']?json_decode($roomInfo['base_info'],true):$roomInfo['base_info'];
+        $roomInfo['base_attr']  = $roomInfo['base_attr']?json_decode($roomInfo['base_attr'],true):$roomInfo['base_attr'];
+        $roomInfo['base_other'] = $roomInfo['base_other']?json_decode($roomInfo['base_other'],true):$roomInfo['base_other'];
+
+        $hotelModel = new HotelModel();
+        //获取当前所有的正常运行的hotel
+        $hotel_list = $hotelModel->getList(['status'=>0],'',1000);
+        $hotel_list = $this->toArray($hotel_list);
+        $hotel_list = array_column($hotel_list,'hotel_name','hotel_id');
+
+        $roomInfo['hotel_name'] = $hotel_list[$roomInfo['hotel_id']];
+
+        $this->returnJson($roomInfo);
+    }
+
+    /**
+     * 保存房间信息
+     */
+    public function saveRoom(){
+        $param_list = [
+            'hotel_id'=>'number',
+            'room_name'=>'string',
+            'room_price'=>'number',
+            'total_number'=>'number',
+            'room_imgs'=>'array',
+            'base_info'=>'array',
+            'base_attr'=>'array',
+            'base_other'=>'array',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $data = [
+            'hotel_id'=>$this->post['hotel_id'],
+            'room_name'=>$this->post['room_name'],
+            'room_price'=>$this->post['room_price'],
+            'total_number'=>$this->post['total_number'],
+            'room_imgs'=>json_encode($this->post['room_imgs']),
+            'base_info'=>json_encode($this->post['base_info']),
+            'base_attr'=>json_encode($this->post['base_attr']),
+            'base_other'=>json_encode($this->post['base_other'])
+        ];
+
+        $roomModel = new RoomModel();
+        if(isset($this->post['room_id']) && is_numeric($this->post['room_id'])){
+            //修改
+            $where = [
+                'room_id'=>$this->post['room_id']
+            ];
+
+            $row = $roomModel->upInfo($where,$data);
+            $this->returnJson(['row'=>$row]);
+        }
+
+        //添加
+        $id = $roomModel->addInfo($data);
+        $this->returnJson(['id'=>$id]);
+    }
+
+    /**
+     * 修改房间状态或者修改房间排序字段
+     */
+    public function updateRoomField(){
+        $param_list = [
+            'room_id'=>'number',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $data = [];
+        if(isset($this->post['status']) && is_numeric($this->post['status'])){
+            $data['status'] = $this->post['status'];
+        }
+        if(isset($this->post['sort']) && is_numeric($this->post['sort'])){
+            $data['sort'] = $this->post['sort'];
+        }
+
+        if(empty($data)){
+            $this->returnJson('you must give me status or sort,but you do not',4001,'error');
+        }
+
+        $roomModel = new RoomModel();
+        $row = $roomModel->upInfo(['room_id'=>$this->post['room_id']],$data);
+
+        $this->returnJson(['row'=>$row]);
+    }
+
+    /**
+     * 通过条件获取酒店的列表
+     */
+    public function getHotelPageByCondition(){
+        $param_list = [
+            'page'=>'number',
+            'pageSize'=>'number',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $page = $this->post['page']>1?$this->post['page']:1;
+        $pageSize = $this->post['pageSize']>2?$this->post['pageSize']:2;
+
+        $where = [];
+        if(isset($this->post['name'])){
+            $where['hotel_name'] = ['like',"%{$this->post['name']}%"];
+        }
+
+        $hotelModel = new HotelModel();
+        $hotelPage = $hotelModel->getPage($where,'',$page,$pageSize);
+
+        $this->returnJson($hotelPage);
+    }
+
+    /**
+     * 通过条件获取订单分页信息
+     */
+    public function getOrderPageByCondition(){
+        $param_list = [
+            'page'=>'number',
+            'pageSize'=>'number',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+        $where = [];
+        if(isset($this->post['order_no']) && is_string($this->post['order_no'])){
+            $where['order_no'] = ['like','%'.$this->post['order_no']."%"];
+        }
+
+        if(isset($this->post['start_date']) && is_string($this->post['start_date'])){
+            $where['start_date'] = $this->post['start_date'];
+        }
+
+        if(isset($this->post['end_date']) && is_string($this->post['end_date'])){
+            $where['end_date'] = $this->post['end_date'];
+        }
+
+        if(isset($this->post['add_time']) && is_string($this->post['add_time'])){
+            $where['add_time'] = ['between',$this->post['add_time'],$this->post['add_time']+86400];
+        }
+
+        if(isset($this->post['hotel_id']) && is_string($this->post['hotel_id'])){
+            $where['hotel_id'] = $this->post['hotel_id'];
+        }
+
+        if(isset($this->post['user_id']) && is_numeric($this->post['user_id'])){
+            $where['user_id'] = $this->post['user_id'];
+        }
+
+        if(isset($this->post['room_id']) && is_numeric($this->post['room_id'])){
+            $where['room_id'] = $this->post['room_id'];
+        }
+
+        $where['status'] = ['neq',6];
+        if(isset($this->post['status']) && is_numeric($this->post['status'])){
+            $where['status'] = $this->post['status'];
+        }
+        if(isset($this->post['status_show']) && is_string($this->post['status_show'])){
+            $where['status_show'] = $this->post['status_show'];
+        }
+
+        $page = $this->post['page']>1?$this->post['page']:1;
+        $pageSize = $this->post['pageSize']>2?$this->post['pageSize']:2;
+        if($pageSize>=100){
+            $this->returnJson([],400,'pageSize must lt 100');
+        }
+
+        $orderModel = new OrderModel();
+        $orderPage = $orderModel->getPage($where,"order_id desc",$page,$pageSize);
+
+        $this->returnJson($orderPage);
+    }
+
+
+    /**
+     * 通过条件获取订单信息
+     */
+    public function getUserOrderByType(){
+        $param_list = [
+            'user_id'=>'number',
+            'status'=>'int'
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        if(!in_array($this->post['status'],[0,1,2,3,5,10])){
+            $this->returnJson([],400,'status is error');
+        }
+
+        $params = [];
+        $params['user_id'] = $this->post['user_id'];
+        if($this->post['status']!=10){
+            $params['status'] = $this->post['status'];
+        }
+
+        $OrderModel = new OrderModel();
+        $Order = $OrderModel->getList($params,'start_date desc');
+
+        $roomModel = new RoomModel();
+        foreach($Order as &$orderItem){
+            $room_id = $orderItem['room_id'];
+            $room = $roomModel->getOne(['room_id'=>$room_id]);
+            !empty($room['room_imgs'])?$room['room_imgs'] = json_decode($room['room_imgs']):'';
+            !empty($room['base_info'])?$room['base_info'] = json_decode($room['base_info']):'';
+            !empty($room['base_attr'])?$room['base_attr'] = json_decode($room['base_attr']):'';
+            !empty($room['base_other'])?$room['base_other'] = json_decode($room['base_other']):'';
+            $orderItem['roomInfo'] = $room;
+        }
+
+        $this->returnJson($Order);
+    }
+
+    /**
+     * 添加订单信息
+     */
+    public function addOrder(){
+        $param_list = [
+            'user_id'=>'number',
+            'hotel_id'=>'number',
+            'room_id'=>'number',
+            'total_room_num'=>'number',
+            'arrive_time'=>'string',
+            'start_date'=>'string',
+            'end_date'=>'string'
+        ];
+
+        HelperService::diffParam($param_list,$this->post);
+
+        $roomModel = new RoomModel();
+        $row = $roomModel->getOne(['room_id'=>$this->post['room_id']]);
+        $price_single = $row['room_price'];
+        $diff_date = (strtotime($this->post['end_date']) - strtotime($this->post['start_date']))/86400;
+
+        $order_no = $this->createOrderNum();
+        $data = [
+            'order_no'=>$order_no,
+            'user_id'=>$this->post['user_id'],
+            'hotel_id'=>$this->post['hotel_id'],
+            'room_id'=>$this->post['room_id'],
+            'total_price'=>$price_single*($this->post['total_room_num'])*$diff_date,
+            'total_room_num'=>$this->post['total_room_num'],
+            'status'=>0,
+            'arrive_time'=>$this->post['arrive_time'],
+            'start_date'=>$this->post['start_date'],
+            'end_date'=>$this->post['end_date'],
+            'add_time'=>time(),
+            'note'=>isset($this->post['note'])?$this->post['note']:null,
+            'detail'=>isset($this->post['detail'])?$this->post['detail']:null,
+        ];
+
+        $orderModel = new OrderModel();
+        $order_id=$orderModel->addInfo($data);
+
+        $this->returnJson(['order_no'=>$order_no,'order_id'=>$order_id]);
+    }
+
+    /**
+     * 后台修改订单状态
+     */
+    public function backUpdateOrderStatus(){
+        $param_list = [
+            'status'=>'number',
+            'order_id'=>'number',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $orderModel = new OrderModel();
+        $where = [
+            'order_id'=>$this->post['order_id'],
+        ];
+        $data = [
+            'status'=>$this->post['status'],
+        ];
+
+        if(isset($this->post['back_note'])){
+            $data['back_note'] = $this->post['back_note'];
+        }
+        $row = $orderModel->upInfo($where,$data);
+
+        $this->returnJson(['row'=>$row]);
+    }
+
+    /**
+     * 后台修改订单状态
+     */
+    public function UpdateOrderStatusShow(){
+        $param_list = [
+            'status_show'=>'number',
+            'order_id'=>'number',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $orderModel = new OrderModel();
+        $where = [
+            'order_id'=>$this->post['order_id'],
+        ];
+        $data = [
+            'status_show'=>$this->post['status_show'],
+        ];
+
+        if(isset($this->post['back_note'])){
+            $data['back_note'] = $this->post['back_note'];
+        }
+        $row = $orderModel->upInfo($where,$data);
+
+        $this->returnJson(['row'=>$row]);
+    }
+
+    /**
+     * 前台修改订单状态
+     */
+    public function frontUpdateOrderStatus(){
+        $param_list = [
+            'status'=>'number',
+            'order_no'=>'number',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $orderModel = new OrderModel();
+        $where = [
+            'order_no'=>$this->post['order_no'],
+        ];
+        $data = [
+            'status'=>$this->post['status'],
+        ];
+
+        if(isset($this->post['note'])){
+            $data['note'] = $this->post['note'];
+        }
+        $row = $orderModel->upInfo($where,$data);
+
+        $this->returnJson(['row'=>$row]);
+    }
+
+    /**
+     * 获取酒店信息,根据酒店id
+     */
+    public function getHotelInfoById(){
+        $param_list = [
+            'hotel_id'=>'number',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $hotelModel = new HotelModel();
+        $res = $hotelModel->getOne(['hotel_id'=>$this->post['hotel_id']]);
+
+        $this->returnJson($res);
+    }
+
+    /**
+     * 根据订单id获取订单信息
+     */
+    public function getOrderInfoById(){
+        $param_list = [
+            'order_id'=>'number'
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $orderModel = new OrderModel();
+        $order = $orderModel->getOne(['order_id'=>$this->post['order_id']]);
+        $this->returnJson($order);
+    }
+
+
+    /**
+     * 根据订单id获取订单信息
+     */
+    public function getOrderInfoByOrderNo(){
+        $param_list = [
+            'order_no'=>'string'
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        if(strlen($this->post['order_no']) > 16){
+            $this->returnJson([],400,'order_no is error');
+        }
+
+        $orderModel = new OrderModel();
+        $order = $orderModel->getOne(['order_no'=>$this->post['order_no']]);
+        $this->returnJson($order);
+    }
+
+    /**
+     * 获取房间剩余数量的列表
+     */
+    public function getHotelRemainRoom(){
+        $param_list = [
+            'hotel_id'=>'int',
+            'room_id'=>'int',
+            'start_date'=>'date'
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        //获取当前房间的信息
+        $RoomModel = new RoomModel();
+        $RoomInfo = $RoomModel->getRoomInfo($this->post['hotel_id'],$this->post['room_id']);
+
+        if(empty($RoomInfo)){
+            $this->returnJson([],400,"don't find this room info");
+        }
+
+        unset($RoomInfo['room_imgs'],$RoomInfo['base_info'],
+            $RoomInfo['base_attr'],$RoomInfo['base_other']);
+
+        $start_date = strtotime($this->post['start_date']);
+        $remainNum  = [];
+        $orderModel = new OrderModel();
+        for($date=$start_date;$date<$start_date+10*86400;$date+=86400){
+            $dateYmd = date('Y-m-d',$date);
+            $remain = $RoomInfo['total_number'] - $orderModel->getOrderNumByDate($this->post['hotel_id'],$this->post['room_id'],$dateYmd);
+            $remainNum[] = [
+                'date'=>$dateYmd,
+                'remain'=>$remain<0?0:$remain];
+        }
+
+        $this->returnJson(['roomInfo'=>$RoomInfo,'remainInfo'=>$remainNum]);
+    }
+
+    /**
+     * 获取该酒店可预约的房间列表
+     */
+    public function getReservedRoomList(){
+        $param_list = [
+            'hotel_id'=>'number',
+            'start_date'=>'date',//格式,必须YYYY-mm-dd
+            'end_date'=>'date',
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $start_time = strtotime($this->post['start_date']);//2017-06-25
+        $end_time = strtotime($this->post['end_date']);//2017-06-26
+
+        //判断时间间隔是否超过2个月,让sql调用过于频繁保护机制
+        if($end_time - $start_time > 86400*30){
+            $this->returnJson('Sorry, the time interval should not exceed one months',503,'error');
+        }
+        if($end_time - $start_time < 86400){
+            $this->returnJson('Sorry, the interval is less than one day',503,'error');
+        }
+
+        $roomModel = new RoomModel();
+        //返回的数组
+        $return_arr = [];
+        for($time = $start_time;$time<$end_time; $time+=86400){
+            $date = date('Y-m-d',$time);
+            $roomList = $roomModel->getReservedRoomList($this->post['hotel_id'],$date);
+            //分析这段时间房间的情况
+            $return_arr = $this->_analysis($return_arr,$roomList);
+        }
+
+        $this->returnJson($return_arr);
+    }
+
+
+    /**
+     * 分析房间数据
+     * @param $return_arr
+     * @param $roomList
+     */
+    private function _analysis($return_arr,$roomList){
+        foreach($roomList as $item){
+            //如果房间信息存在,并且房间信息已经于之前发现超限了,那么不再重新赋值 (step1)
+            if(isset($return_arr[$item['room_id']]) &&
+                ($item['sum_num'] <= $return_arr[$item['room_id']]['sum_num'])){
+                continue;
+            }
+            //为了简化程序,不再判断当前情况下,本次的房间信息是否超限的判断,直接赋值,丢给下次循环(step1)判断
+            $item['room_imgs'] = json_decode($item['room_imgs']);
+            $return_arr[$item['room_id']] = $item;
+        }
+
+        return $return_arr;
+    }
+
+    /**
+     * 当前日期前一天的
+     */
+    public function getHotelOrderDayNum(){
+
+        $end_date = isset($this->post['end_date'])?strtotime(intval($this->post['end_date'])):strtotime(date('Y-m-d'));
+        $start_date = isset($this->post['end_date'])?strtotime(intval($this->post['end_date'])):$end_date-7*86400;
+
+        if($start_date > $end_date){
+            $this->returnJson([]);
+        }
+
+        if($end_date - $start_date > 20*86400){
+            $start_date = $end_date - 20*86400;
+        }
+
+        $backData = [];
+        $orderModel = new OrderModel();
+        $hotelModel = new HotelModel();
+        $hotel = $hotelModel->where(['status'=>0])->select();
+        for($date = $start_date;$date<$end_date;$date+=86400){
+            //确保数据完整性,每个补充0
+            foreach($hotel as $hotel_item){
+                $backData[$hotel_item['hotel_id']][date('Y-m-d',$date)] = 0;
+            }
+
+            $orderGroup = $orderModel->field('hotel_id,count(order_id) as num')->where(['pay_time'=>['between',[$date,$date+86399]]])
+                          ->group('hotel_id')->select();
+
+
+            //覆盖上面对等的值
+            foreach($orderGroup as $group){
+                $backData[$group['hotel_id']][date('Y-m-d',$date)] = intval($group['num']);
+            }
+        }
+
+        $this->returnJson($backData);
+    }
+
+
+    /**
+     * 待处理订单数目
+     */
+    public function getToDoOrder(){
+        $orderModel = new OrderModel();
+        $order = $orderModel->field('hotel_id,count(order_id) as num')->where(['status'=>1])->group('hotel_id')->select();
+
+        $this->returnJson($order);
+    }
+}

+ 36 - 0
application/index/controller/Index.php

@@ -0,0 +1,36 @@
+<?php
+namespace app\index\controller;
+use app\index\model\ShortUrlModel;
+use think\Controller;
+use think\Validate;
+
+class Index extends Controller
+{
+    /**
+     * 短链接进入接口
+     */
+    public function index(){
+
+        $params = $this->request->param();
+        $rule = [
+            'to'=>'require'
+        ];
+        $validate = new Validate($rule);
+        if(!$validate->check($params)){
+            header('HTTP/1.1 400 [to]');
+            exit;
+        }
+
+        $shortUrlModel = new ShortUrlModel();
+        $res = $shortUrlModel->where(['url_str'=>"{$params['to']}"])->find();
+        if(empty($res)){
+            header('HTTP/1.1 400 [url_str]');
+            exit;
+        }
+
+        $url = base64_decode($res['old_url']);
+        header("HTTP/1.1 301 Moved Permanently");
+        header("Location: $url");
+        exit;
+    }
+}

+ 185 - 0
application/index/controller/Photo.php

@@ -0,0 +1,185 @@
+<?php
+namespace app\index\controller;
+
+use app\index\service\HelperService;
+use think\Controller;
+use think\Image;
+use think\Validate;
+
+class Photo extends Controller
+{
+    /**
+     * 上传照片
+     */
+    public function index(){
+        $params = $this->request->param();
+        $rule = [
+            "img_content"=>'require'
+        ];
+
+        $validate = new Validate($rule);
+        if(!$validate->check($params)){
+            HelperService::returnJson(['code'=>400,'msg'=>$validate->getError()]);
+        }
+        $params['img_content'] = str_replace('data:image/png;base64,','',$params['img_content']);
+        $img = base64_decode($params['img_content']);
+        $img_path = "./photo2/img/porsche/".time().rand(1000,999).".png";
+        file_put_contents($img_path, $img);
+
+        Image::open($img_path)->save($img_path,null,30);
+        HelperService::returnJson(['img_path'=>substr($img_path,1)]);
+    }
+
+
+    public function getNewsList(){
+        $params = $this->request->param();
+        $rule = [
+            "userNo"=>'require',
+            "token"=>"require",
+        ];
+
+        $validate = new Validate($rule);
+        if(!$validate->check($params)){
+            HelperService::returnJson(['code'=>400,'msg'=>$validate->getError()]);
+        }
+
+        HelperService::returnJson(['code'=>200,'msg'=>'success','data'=>[
+            [
+                'id'=>'1000',
+                'title'=>'上海辰森科技有限公司成立了-新闻',
+                'dateTime'=>"2018-06-25"
+            ],
+            [
+                'id'=>'1001',
+                'title'=>'上海辰森科技有限公司上市了-新闻',
+                'dateTime'=>"2018-06-28"
+            ]
+        ]]);
+    }
+
+    public function getNoticeList(){
+        $params = $this->request->param();
+        $rule = [
+            "userNo"=>'require',
+            "token"=>"require",
+            //"title"=>"require"
+        ];
+
+        $validate = new Validate($rule);
+        if(!$validate->check($params)){
+            HelperService::returnJson(['code'=>400,'msg'=>$validate->getError()]);
+        }
+
+        HelperService::returnJson(['code'=>200,'msg'=>'success','data'=>[
+            [
+                'id'=>'1000',
+                'title'=>'上海辰森科技有限公司成立了-公告',
+                'dateTime'=>"2018-06-25"
+            ],
+            [
+                'id'=>'1001',
+                'title'=>'上海辰森科技有限公司上市了-公告',
+                'dateTime'=>"2018-06-28"
+            ]
+        ]]);
+    }
+
+
+    public function getNoticeDetail(){
+        $params = $this->request->param();
+        $rule = [
+            "userNo"=>'require',
+            "token"=>"require",
+            "id"=>"require"
+        ];
+
+        $validate = new Validate($rule);
+        if(!$validate->check($params)){
+            HelperService::returnJson(['code'=>400,'msg'=>$validate->getError()]);
+        }
+
+        HelperService::returnJson(['code'=>200,'msg'=>'success','data'=>[
+            "id"=>001,
+          "title"=>"辰森成立了-新闻",
+          "dateTime"=>"2018-09-12",
+          "publisher"=>"Leo.xie",
+          "content"=>"商桥总部、各分支机构:
+        根据公司发展需要,经研究决定:
+        调总部商务中心市场部产品总监张四季任上海大区网管总监,负责上海大区的网络拓展及管理工作。其工作直接向网络发展中心副总裁赵华总汇报。
+         以上人事调动自?2018 年 5 月 1 日起正式生效。
+
+        特此通知
+
+                        商桥物流综合管理中心
+                        二〇一八年四月二十七日"
+        ]]);
+    }
+
+    public function getNewsDetail(){
+        $params = $this->request->param();
+        $rule = [
+            "userNo"=>'require',
+            "token"=>"require",
+            "id"=>"require"
+        ];
+
+        $validate = new Validate($rule);
+        if(!$validate->check($params)){
+            HelperService::returnJson(['code'=>400,'msg'=>$validate->getError()]);
+        }
+
+        HelperService::returnJson(['code'=>200,'msg'=>'success','data'=>[
+            "id"=>001,
+            "title"=>"辰森成立了-公告",
+            "dateTime"=>"2018-09-12",
+            "publisher"=>"Leo.xie",
+            "content"=>"商桥总部、各分支机构:
+        根据公司发展需要,经研究决定:
+        调总部商务中心市场部产品总监张四季任上海大区网管总监,负责上海大区的网络拓展及管理工作。其工作直接向网络发展中心副总裁赵华总汇报。
+         以上人事调动自?2018 年 5 月 1 日起正式生效。
+
+        特此通知
+
+                        商桥物流综合管理中心
+                        二〇一八年四月二十七日"
+        ]]);
+    }
+
+    /**
+     * 裁剪图片
+     */
+    public function Cutout(){
+        $params = $this->request->param();
+        $rule = [
+            "img_content"=>'require'
+        ];
+
+        $validate = new Validate($rule);
+        if(!$validate->check($params)){
+            HelperService::returnJson(['code'=>400,'msg'=>$validate->getError()]);
+        }
+
+        $params['img_content'] = str_replace('data:image/png;base64,','',$params['img_content']);
+        $img = base64_decode($params['img_content']);
+        $img_path = "./photo2/img/porsche/".time().rand(1000,999).".png";
+        file_put_contents($img_path, $img);
+
+//        $im = imagecreatefrompng($img_path);
+//        //创建一个2000*2000的大画布
+//        $block = imagecreate(2000,2000);
+//        imagecolorallocatealpha($block,215,215,215,215);
+//        $height = imagesy($im);
+//        $width = imagesx($im);
+//        imagecopyresampled($block,$im,800,500,0,0,$width,$height,$width,$height);
+//        imagepng($block,$img_path);
+//        imagedestroy($block);
+//        imagedestroy($im);
+
+        Image::open($img_path)->save($img_path,null,30);
+        HelperService::returnJson(['img_path'=>substr($img_path,9)]);
+    }
+
+
+
+
+}

Різницю між файлами не показано, бо вона завелика
+ 999 - 0
application/index/controller/Product.php


+ 154 - 0
application/index/controller/ShortUrl.php

@@ -0,0 +1,154 @@
+<?php
+namespace app\index\controller;
+use app\index\model\ShortUrlModel;
+use app\index\service\HelperService;
+use think\Controller;
+use think\Validate;
+
+class ShortUrl extends CmsController
+{
+    public function index(){
+
+        $params = $this->request->param();
+        $rule = [
+            'old_url'=>'require'
+        ];
+        $validate = new Validate($rule);
+        if(!$validate->check($params)){
+            HelperService::returnJson([
+                'code'=>400,
+                'msg'=>$validate->getError(),
+                'data'=>""
+            ]);
+        }
+
+
+
+        $num = 0;
+        $flag = 'NEW';
+        while(true){
+            $shortUrlModel =  new ShortUrlModel();
+            $res = $shortUrlModel->where(['old_url'=>"{$params['old_url']}"])->find();
+            if($res){
+                $url_str = $res['url_str'];
+                $flag = 'OLD';
+                break;
+            }
+            $random = rand(0,9999);
+            $random = str_pad($random,4,'0',STR_PAD_LEFT);
+            $url_str = $this->createShortUrl("{$params['old_url']}",$random);
+            //首先看库里有没有没有插入
+            $res = $shortUrlModel->where(['url_str'=>"{$url_str}"])->find();
+            if(empty($res)){
+                break;
+            }
+            $num++;
+        }
+
+        if('NEW' == $flag){
+            $shortUrlModel =  new ShortUrlModel();
+            $shortUrlModel->insert([
+                'old_url'=>"{$params['old_url']}",
+                'url_str'=>"{$url_str}",
+                'num'=>$num,
+            ]);
+        }
+
+        HelperService::returnJson([
+            'code'=>200,
+            'msg'=>"http://{$_SERVER['HTTP_HOST']}?to={$url_str}",
+            'data'=>$flag
+        ]);
+    }
+
+    private function createShortUrl($or_url,$salt){
+
+        $md5_url   = md5($or_url);
+        //$salt      = '0826';//这里不高于aaaa就不会出现61以上的数字,所以来说,后面的特别符号是不会出现的!
+        $md5_url   = $this->addSalt($md5_url,$salt);
+        $short_url = '';
+
+        for($i=0;$i<6;$i++){
+            $current_str = substr($md5_url,$i*6,6);
+            //处理当前串的值
+            $short_url .= $this->ZChar($current_str);
+        }
+
+        return $short_url;
+    }
+
+    /**
+     * 处理字符串
+     * @param $str
+     * @return int
+     */
+    private function dealStr($str){
+        if(strlen($str) != 6){
+            die("dealStr:{$str}error");
+        }
+        $count = '';
+        for($i=0;$i<6;$i++){
+            //加权,避免不同序列的和一致
+            $number = hexdec($str[$i])*($i+1)%12;
+            $count += $number;
+        }
+
+        return $count % 66;
+    }
+
+    /**
+     * 字码表
+     * @param $char_point
+     * @return mixed
+     */
+    private function char($char_point){
+
+        $char_array = ["0","1","2","3","4","5",
+            "6","7","8","9","a","b","c","d",
+            "e","f","g","h","i","j","k","l",
+            "m","n","o","p","q","r","s","t",
+            "u","v","w","x","y","z","A","B",
+            "C","D","E","F","G","H","I","J",
+            "K","L","M","N","O","P","Q","R",
+            "S","T","U","V","W","X","Y","Z",
+            "$","@",'+',"="];
+        $char_point = intval($char_point);
+        if($char_point < 0 || $char_point > 65){
+            die('char:'.$char_point.' error');
+        }
+
+        return $char_array[$char_point];
+    }
+
+    /**
+     * 添加盐
+     * @param $md5_url
+     * @param $salt
+     * @return string
+     */
+    private function addSalt($md5_url,$salt){
+        if(strlen($md5_url) != 32){
+            die('addSalt:{$md5_url} error');
+        }
+        $len  = strlen($salt);
+        for($i=0;$i<$len;$i++){
+            $position = hexdec($md5_url[$i]);
+            $weight   = ceil($position/8);
+            $position = $position * $weight;
+            $pre      = substr($md5_url,0,$position);
+            $next     = substr($md5_url,$position);
+            $md5_url  = $pre.$salt[$i].$next;
+        }
+        return $md5_url;
+    }
+
+    /**
+     * 加密字节
+     * @param $current_str
+     * @return mixed
+     */
+    private function ZChar($current_str){
+        $Vchar = $this->dealStr($current_str);
+        return $this->char($Vchar);
+    }
+}

+ 92 - 0
application/index/controller/Sms.php

@@ -0,0 +1,92 @@
+<?php
+namespace app\index\controller;
+
+use app\index\service\HelperService;
+use app\index\service\SmsService;
+
+class Sms extends CmsController
+{
+
+    /**
+     * 发送短信接口
+     */
+   public function sendCode(){
+
+       $param_list = [
+           'mobile'=>'mobile',
+           'temp_id'=>'number'
+       ];
+       HelperService::diffParam($param_list,$this->post);
+
+       $smsService = new SmsService();
+       $res = $smsService->sendCode($this->post['mobile'],$this->post['temp_id']);
+       if($res['status'] === false){
+           $this->returnJson($res,400,'sms fail');
+       }
+       $this->returnJson($res);
+   }
+
+   /**
+     * 批量发送短信接口
+     */
+    public function sendBatchCode(){
+
+        $param_list = [
+            'recipients'=>'array',
+            'temp_id'=>'number'
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $smsService = new SmsService();
+        $res = $smsService->sendBatchCode($this->post['recipients'],$this->post['temp_id']);
+        
+        $this->returnJson($res);
+    }
+   
+   /**
+     * 批量发送短信状态
+     */
+    public function sendReportCode(){ 
+        $smsService = new SmsService();
+        $res = $smsService->sendReportCode();
+        if($res['status'] === false){
+            $this->returnJson($res,400,'sms fail');
+        }
+        $this->returnJson($res);
+    }
+   
+    /**
+     * 发送短信模板消息
+     */
+   public function sendMessage(){
+       $param_list = [
+           'mobile'=>'mobile',
+           'temp_id'=>'number'
+       ];
+       HelperService::diffParam($param_list,$this->post);
+
+       $smsService = new SmsService();
+       $res = $smsService->sendMessage($this->post['mobile'],$this->post['temp_id'],$this->post['temp_params']);
+       $this->returnJson($res);
+   }
+
+    /**
+     * 验证短信接口
+     */
+    public function checkCode(){
+        $param_list = [
+            'code'=>'number',
+            'msg_id'=>'string'
+        ];
+        HelperService::diffParam($param_list,$this->post);
+
+        $smsService = new SmsService();
+        $res = $smsService->checkCode($this->post['code'],$this->post['msg_id']);
+
+        if($res) {
+            $this->returnJson($res);
+        }else{
+            $this->returnJson('',400,'error');
+        }
+    }
+}

Різницю між файлами не показано, бо вона завелика
+ 1020 - 0
application/index/controller/Wechat.php


+ 480 - 0
application/index/controller/WechatJs.php

@@ -0,0 +1,480 @@
+<?php
+namespace app\index\controller;
+
+use app\index\model\AuthCompanyModel;
+use app\index\service\HelperService;
+use app\index\service\wechat\WxPayConfig;
+use think\Cache;
+use think\Config;
+use think\Controller;
+use think\Validate;
+
+class WechatJs extends Controller
+{
+    public function getConfigJs(){
+        $param = $this->request->param();
+        $companyCode = $this->_validCompanyCode($param);
+
+        WxPayConfig::$companyCode();
+        //判断有没有当前公司的access_token
+        $this->_getAccessToken($companyCode);
+    }
+
+    public function getApiTicket(){
+        $param = $this->request->param();
+        $companyCode = $this->_validCompanyCode($param);
+
+        if(Cache::has("{$companyCode}_apiTicket")){
+            HelperService::returnJson([
+                'code'=>200,
+                'msg'=>'success',
+                'data'=>Cache::get("{$companyCode}_apiTicket")
+            ]);
+        }
+
+        WxPayConfig::$companyCode();
+        $access_token = $this->_getToken($companyCode);
+        $request_token = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={$access_token}&type=wx_card";
+        $res = HelperService::httpPost($request_token,'',true);
+
+        if($res === false){
+            HelperService::returnJson([
+                'code'=>400,
+                'msg'=>'api_token is error',
+                'data'=>$res
+            ]);
+        }
+
+        $tokenArr = @json_decode($res,true);
+        if($tokenArr['errcode']>0){
+            HelperService::returnJson([
+                'code'=>400,
+                'msg'=>'api_token is error',
+                'data'=>$res
+            ]);
+        }
+
+        Cache::set("{$companyCode}_apiTicket","{$tokenArr['ticket']}",7200);
+        HelperService::returnJson([
+            'code'=>200,
+            'msg'=>'success',
+            'data'=>"{$res['ticket']}"
+        ]);
+    }
+
+    public function getToken(){
+        $param = $this->request->param();
+        $companyCode = $this->_validCompanyCode($param);
+
+        $token = $this->_getToken($companyCode);
+
+        Cache::set('access_token_'.$companyCode,$token,300);
+
+        HelperService::returnJson([
+            'code'=>200,
+            'msg'=>'curl',
+            'data'=>"$token"
+        ]);
+    }
+
+    private function _getToken($companyCode,$is_force=false){
+
+        WxPayConfig::$companyCode();
+
+        $token = Cache::get('access_token_'.$companyCode);
+        if(!empty($token) && $is_force==false){
+            HelperService::returnJson([
+                'code'=>200,
+                'msg'=>'cache',
+                'data'=>"$token"
+            ]);
+        }
+
+        //判断有没有当前公司的access_token
+        $request_token = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".WxPayConfig::$APPID."&secret=".WxPayConfig::$APPSECRET;
+        $token_json = HelperService::httpPost($request_token,'',true);
+        if($token_json === false){
+            HelperService::returnJson([
+                'code'=>400,
+                'msg'=>'token is error',
+                'data'=>"$token_json"
+            ]);
+        }
+        $tokenArr = json_decode($token_json,true);
+        if(!isset($tokenArr['access_token'])){
+            HelperService::returnJson([
+                'code'=>400,
+                'msg'=>'wechat return',
+                'data'=>"$token_json",
+                'url'=>$request_token
+            ]);
+        }
+
+        $token = $tokenArr['access_token'];
+        return $token;
+    }
+
+    public function sendCard(){
+
+        $cardId = $this->request->param('card_id');
+        $code = $this->request->param('code');
+        
+        $companyCode = 'SHYL';
+        $access_token = $this->_getToken($companyCode,true);
+        $url = "https://api.weixin.qq.com/card/qrcode/create?access_token=$access_token";
+        $data = '{
+                    "action_name": "QR_CARD",
+                    "expire_seconds": 1800,
+                    "action_info": {
+                    "card": {
+                        "card_id": "'.$cardId.'",
+                        "code": "'.$code.'",
+                        "is_unique_code": true,
+                        "outer_str":"12b"
+                    }
+                 }
+            }';
+        $res = HelperService::httpPost($url,$data,true);
+        var_dump($res);
+        exit;
+    }
+
+    
+    public function updateCardCode(){
+
+        $code = $this->request->param('code');
+        $companyCode = 'SHYL';
+        $access_token = $this->_getToken($companyCode,true);
+        $url = "https://api.weixin.qq.com/card/code/unavailable?access_token=$access_token";
+        $data = '{"code":"'.$code.'","card_id":"pIa9rt9EyR4IvGsWq7VY6HfKQ39U"}';
+        echo $data;
+        $res = HelperService::httpPost($url,$data,true);
+        var_dump($res);
+        exit;
+    }
+
+
+    /**
+     * 发送白模版接口
+     */
+    public function sendTemplate(){
+
+        $params = $this->request->param();
+        $rule = [
+            'access_token'=>'require',
+            'open_id'=>'require',
+            'template_url'=>'require',
+            'content'=>'require',
+            'template_id'=>'require'
+        ];
+
+        $validate = new Validate($rule);
+        if(!$validate->check($params)){
+            HelperService::returnJson([
+                'code'=>400,
+                'msg'=>$validate->getError(),
+            ]);
+            return false;
+        }
+
+        $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={$params['access_token']}";
+        $data = [
+            "touser"=>$params['open_id'],
+            "template_id"=>$params['template_id'],
+            "url"=>$params['template_url'],
+            "data"=>$params['content']
+        ];
+        $returnJson = HelperService::httpPost($url,json_encode($data));
+        $decodeJson = json_decode($returnJson,true);
+        HelperService::returnJson(['code'=>200,'msg'=>'success','data'=>$decodeJson]);
+    }
+
+
+
+    public function _getAccessToken($companyCode){
+        HelperService::returnJson(HelperService::getWechatToken($companyCode));
+    }
+
+    /**
+     * 创建logo
+     * 待测试
+     */
+    public function cardLogo(){
+
+        $params = $this->request->param();
+        $rule = [
+            'companyCode'=>'require',
+        ];
+
+        $validate = new Validate($rule);
+        if(!$validate->check($params)){
+            HelperService::returnJson(['code'=>400,'msg'=>$validate->getError(),'data'=>$params]);
+        }
+
+        $access_token = $this->_getToken($params['companyCode'],true);
+        $filePath = $this->_upload('media1');
+        $url = "https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token={$access_token}&type=card_logo";
+        $data = [
+            "type"=>"image",
+            "media"=>new \CURLFile($filePath)
+        ];
+        $returnJson = HelperService::httpPost($url,$data,true,[],false);
+        $decodeJson = json_decode($returnJson,true);
+        HelperService::returnJson(['code'=>200,'msg'=>'success','data'=>$decodeJson]);
+    }
+
+    /**
+     * 获取门店信息
+     */
+    public function getStoreList(){
+        $companyCode = 'SHYL';
+        WxPayConfig::$companyCode();
+        $access_token = $this->_getToken($companyCode,true);
+        $url = "https://api.weixin.qq.com/cgi-bin/poi/getpoilist?access_token={$access_token}";
+        
+        $res = HelperService::httpPost($url, json_encode(['begin'=>0,'limit'=>50]), true);
+        $res = @json_decode($res,true);
+        
+        if($res['errcode']!=0){
+            var_dump($res);exit;
+        }
+        
+        echo "\n=====\n";
+        foreach($res['business_list'] as $item){
+            echo $item['base_info']['poi_id'].",";
+        }
+        echo "\n==".count($res['business_list'])."==\n";
+    }
+    
+    /**
+     * 获取门店信息
+     */
+    public function paycell(){
+        
+        $cardId = $this->request->param('card_id');
+        $companyCode = 'SHYL';
+        WxPayConfig::$companyCode();
+        $access_token = $this->_getToken($companyCode,true);
+        $url = "https://api.weixin.qq.com/card/paycell/set?access_token={$access_token}";
+        
+        $res = HelperService::httpPost($url, json_encode(['card_id'=>$cardId,'is_open'=>true]), true);
+        $res = @json_decode($res,true);
+        
+        var_dump($res);
+    }
+
+    /**
+     * 创建卡券
+     * 参考连接https://www.w3cschool.cn/weixinkaifawendang/rkoi1qfa.html
+     */
+    public function createCard(){
+
+        $companyCode = 'SMDD';
+        WxPayConfig::$companyCode();
+        $access_token = $this->_getToken($companyCode,true);
+        $url = "https://api.weixin.qq.com/card/create?access_token={$access_token}";
+
+        $data = '{
+            "card": {
+                "card_type": "MEMBER_CARD",
+                "member_card": {
+                    "background_pic_url": "http://mmbiz.qpic.cn/mmbiz_jpg/LzP9djqouXdfLQNt3n1wdkovicibia49VUEdJbdHw9QRc6L5B1Itib2hKS1ricSFmfeDFegPqTBFpX4MBtnoUyIgmZg/0",
+                    "base_info": {
+                        "logo_url": "http://mmbiz.qpic.cn/mmbiz_jpg/tnZicgdFjqL06BkhRVwqU40BWNKziaz2EzhicuIRLfaJuFbEDoMHMKNjrBibLrRqD2iac3JY4nZzOB1BHSXiasfGrWHg/0",
+                        "brand_name": "客勤八久",
+                        "code_type": "CODE_TYPE_QRCODE",
+                        "title": "会员卡",
+                        "color": "Color010",
+                        "notice": "使用时向服务员出示此券",
+                        "service_phone": "021-51651616",
+                        "description": "会员权益不可与其他优惠同享",
+                        "date_info": {
+                            "type": "DATE_TYPE_FIX_TERM",
+                            "fixed_term":730,
+                            "fixed_begin_term":0
+                        },
+                        "pay_info":{
+                                "swipe_card":{
+                                    "is_swipe_card":true
+                                  }
+                                   
+                       },
+                        "custom_url_name": "会员中心",
+                        "custom_url": "http://member.keqin89.com",
+                        "sku": {
+                            "quantity": 50000000
+                        },
+                        "get_limit": 1,
+                        "use_limit":50000000,
+                        "use_custom_code": true,
+                        "can_share":false,
+                        "can_give_friend": false
+                    },
+                     "advanced_info": {
+                     "abstract": {
+                           "abstract": "即可享有会员专属优惠,会员消费时优惠券、现金券自动抵扣,同时拥有多种优惠券时,自动按可享受最高折扣的优惠券进行抵扣使用",
+                           "icon_url_list": [
+                               "http://mmbiz.qpic.cn/mmbiz_jpg/LzP9djqouXfzLkWajaZfQAKVyZfvsaT00BG9HrZsibOjNm6dfxbjiaYS4BFeNfwAUTv9F7UpAurDCB7ZeUQ7UZiaQ/0"
+                           ]
+                       },
+                       "text_image_list": [
+                           {
+                               "image_url": "http://mmbiz.qpic.cn/mmbiz_jpg/LzP9djqouXfzLkWajaZfQAKVyZfvsaT0Cehn0fUmJQamCmsKwabibrkPtLdDodgZ4AB5k3SNjPV6BiadO6ea9fAg/0",
+                               "text": "  我们一直以顾客的体验为初衷,不断提升门店的舒适度、为让顾客在更舒适、愉悦的心情下美美的用餐。"
+                           },
+                           {
+                               "image_url": "http://mmbiz.qpic.cn/mmbiz_jpg/LzP9djqouXfzLkWajaZfQAKVyZfvsaT0Rsm7nX2zw9dI41It88PQJIicFOUJJsWn0eQ4oNiab5kOTyQp96Z5atFA/0",
+                               "text": "  我们一直坚持品质、一直努力用心,为的就是让顾客更放心、安心、舒心的感受这舌尖上的美味。"
+                           }
+                       ],
+                       "time_limit": [
+                       ],
+                       "business_service": [
+                           "BIZ_SERVICE_DELIVER"
+                       ]
+                   },
+                   "auto_activate": true,
+                   "supply_bonus": false,
+                   "supply_balance": false,
+                   "prerogative":"注册会员"
+                }
+            }
+        }';
+        echo "1url:$url\n";
+        $res = HelperService::httpPost($url, $data, true);
+        $res = @json_decode($res,true);
+
+        var_dump($res);exit;
+    }
+
+
+    public function updateCard(){
+        $companyCode = 'SHYL';
+        WxPayConfig::$companyCode();
+        $access_token = $this->_getToken($companyCode,true);
+        $url = "https://api.weixin.qq.com/card/update?access_token={$access_token}";
+//pIa9rt9EyR4IvGsWq7VY6HfKQ39U
+        //pIa9rt417yEFidbNitU1wmcuqn_I
+		//"location_id_list":[491473572,491470160,491470156,491470125,491367847,491367829,491367826,491367819,491367814,491215505,491215496,491205223,489947656,489933482,489933422,489933375,489933309,489933238,489933051,489932984,489932971,489932923,489932888,489932845,489932819,480178208,477741160,403959458]
+                    
+        //$data ='{
+        //  "card_id":"pIa9rt9EyR4IvGsWq7VY6HfKQ39U",
+         // "member_card": {
+          //          "base_info": {
+            //            "can_give_friend": true,
+			//			"type":"DATE_TYPE_FIX_TIME_RANGE",
+			//			"begin_timestamp":1539792000,
+			//			"end_timestamp":1640966400
+             //          }
+            //}
+        //}';
+
+		$data = [
+		   "card_id"=>"pIa9rt9EyR4IvGsWq7VY6HfKQ39U",
+		   "member_card"=>[
+		      "base_info"=>[
+			      "can_give_friend"=>true,
+				  "date_info"=>[
+					  "type"=>"DATE_TYPE_FIX_TIME_RANGE",
+					   "begin_timestamp"=>1514736000,
+					   "end_timestamp"=>1640966400
+				  ]
+			  ]
+		   ]
+		];
+		echo json_encode($data);
+        echo "1url:$url\n";
+        $res = HelperService::httpPost($url, json_encode($data), true);
+        $res = @json_decode($res,true);
+
+        var_dump($res);exit;
+    }
+
+
+    /**
+     * 返回保存路径
+     * @param $key
+     * @return type
+     */
+    private function _upload($key){
+        // 获取表单上传文件 例如上传了001.jpg
+        $file = $this->request->file($key);
+
+        // 移动到框架应用根目录/public/uploads/ 目录下
+        if($file){
+            $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');
+            if($info){
+                // 成功上传后 获取上传信息
+                // 输出 20160820/42a79759f284b767dfcb2a0197904287.jpg
+                return $info->getPath().DS.$info->getFilename();
+            }else{
+                // 上传失败获取错误信息
+                HelperService::returnJson(['code'=>400,'msg'=>$file->getError(),'data'=>[]]);
+            }
+        }
+
+        HelperService::returnJson(['code'=>400,'msg'=>'没有上传图片','data'=>[]]);
+    }
+
+
+    /**
+     * 验证公司是否正确
+     * @param $param
+     * @return mixed
+     */
+    private function _validCompanyCode($param){
+
+        if(isset($param['companyCode'])){
+            $AuthCompanyModel = new AuthCompanyModel();
+            $companyCode = $param['companyCode'];
+            $company = $AuthCompanyModel->getInfo(['company_code'=>$companyCode]);
+            if(empty($company)){
+                die("I don't have this companyCode.");
+            }
+            session('company_db_json',$company['db_json']);
+            session('SmsConfig',json_decode($company['sms_json'],true));
+            session('companyCode',$param['companyCode']);
+        }
+
+        if(!session('companyCode')){
+            die("I don't know companyCode.");
+        }
+
+        $companyCode = session('companyCode');
+
+        $this->_loadConfig();
+
+        return $companyCode;
+    }
+
+    private function _loadConfig(){
+
+        $db_json = session('company_db_json');
+
+        $db_arr = json_decode($db_json,true);
+
+        if(empty($db_arr)){
+            return true;
+        }
+
+        foreach($db_arr as $k=>$v){
+            $data =  [
+                'type'        => 'mysql',
+                'hostname'    => '127.0.0.1',
+                'database'    => 'test',
+                'username'    => 'root',
+                'password'    => '',
+                'hostport'    => '3306',
+                'params'      => [],
+                'charset'     => 'utf8',
+                'prefix'      => '',
+            ];
+            $data['type'] = $v['type'];
+            $data['hostname'] = $v['hostname'];
+            $data['database'] = $v['database'];
+            $data['username'] = $v['username'];
+            $data['password'] = $v['password'];
+            Config::set($v['config_name'],$data);
+        }
+    }
+}

+ 8 - 0
application/index/model/AliPayRecordModel.php

@@ -0,0 +1,8 @@
+<?php
+namespace app\index\model;
+use think\Model;
+
+class AliPayRecordModel extends Model
+{
+    protected $table='alipay_record';
+}

+ 11 - 0
application/index/model/AuthCompanyModel.php

@@ -0,0 +1,11 @@
+<?php
+namespace app\index\model;
+use think\Model;
+class AuthCompanyModel extends Model
+{
+    protected $table='auth_company';
+    public function getInfo($where){
+        $info = $this->where($where)->find();
+        return $info;
+    }
+}

+ 12 - 0
application/index/model/AuthModel.php

@@ -0,0 +1,12 @@
+<?php
+namespace app\index\model;
+use think\Model;
+class AuthModel extends Model
+{
+    protected $table='auth';
+    public function getInfo($where){
+        $info = $this->where($where)->find();
+        return $info;
+    }
+
+}

+ 113 - 0
application/index/model/BaseModel.php

@@ -0,0 +1,113 @@
+<?php
+namespace app\index\model;
+use think\Model;
+class BaseModel extends Model
+{
+
+    /**
+     * 添加一条的操作
+     * @param $data
+     * @return int|string
+     */
+    public function addInfo($data){
+        $id = $this->insertGetId($data);
+        return $id;
+    }
+
+    /**
+     * 添加多条的操作
+     * @param $data
+     * @return int|string
+     */
+    public function addAllInfo($data){
+        $id = $this->insertAll($data);
+        return $id;
+    }
+
+    /**
+     * 更新操作
+     * @param $where
+     * @param $data
+     * @return $this
+     */
+    public function upInfo($where,$data){
+        $bool = $this->where($where)->update($data);
+        return $bool;
+    }
+
+    /**
+     * 通过条件获取列表
+     * @param $where
+     * @param $order
+     * @param $limit
+     * @return false|\PDOStatement|string|\think\Collection
+     */
+    public function getList($where=[],$order="",$limit=50){
+        $list = $this->where($where);
+        if(!empty($order)){
+            $list = $list->order($order);
+        }
+        $list = $list->limit($limit)->select();
+        return $list;
+    }
+
+
+    /**
+     * 通过条件获取分页列表
+     * @param array $where
+     * @param string $order
+     * @param int $page
+     * @param int $pageSize
+     * @return array
+     */
+    public function getPage($where=[],$order="",$page=1,$pageSize=2){
+        $data = [
+            'count'=> $this->_getPage($where,$order),
+            'list'=>$this->_getPage($where,$order,$page,$pageSize,'list')
+        ];
+
+        return $data;
+    }
+
+    /**
+     * 针对于分页的基方法
+     * @param $where
+     * @param $order
+     * @param int $page
+     * @param int $pageSize
+     * @param string $type
+     * @return false|int|\PDOStatement|string|\think\Collection
+     */
+    private function _getPage($where,$order,$page=1,$pageSize=2,$type='count'){
+        $list = $this;
+        if($where) {
+            $list = $this->where($where);
+        }
+        if($order){
+            $list = $this->order($order);
+        }
+
+        if($type == 'count') {
+            return $list->count();
+        }else{
+            if(intval($pageSize) > 100){
+                $pageSize = 100;
+            }
+            return $list->page(intval($page),intval($pageSize))->select();
+        }
+    }
+
+    /**
+     * 根据条件获取一条记录
+     * @param $where
+     * @return array|false|\PDOStatement|string|Model
+     */
+    public function getOne($where=[]){
+        if($where){
+            $list = $this->where($where)->find();
+        }else{
+            $list = $this->find();
+        }
+        return $list;
+    }
+}

+ 22 - 0
application/index/model/BuyCarModel.php

@@ -0,0 +1,22 @@
+<?php
+namespace app\index\model;
+class BuyCarModel extends BaseModel
+{
+    protected $table='buy_car';
+    protected $connection = 'db_mall';
+
+    /**
+     * 购物车表联合产品表
+     * @param $condition
+     * @param $order
+     * @return false|\PDOStatement|string|\think\Collection
+     */
+    public function getCarAndProductInfo($condition,$order='pro.category_id asc'){
+
+        $list = $this->join('product pro','pro.product_id = buy_car.product_id','LEFT')
+            ->field("buy_car.num as num,buy_car.id as buy_car_id,pro.*")
+            ->where($condition)->order($order)->select();
+
+        return $list;
+    }
+}

+ 21 - 0
application/index/model/LogApiModel.php

@@ -0,0 +1,21 @@
+<?php
+namespace app\index\model;
+use think\Model;
+use think\Db;
+class LogApiModel extends Model
+{
+
+    public function __construct()
+    {
+        $date = date('Ymd',time());
+        $this->table = 'log_api'.'_'.$date;
+        $exist = Db::query('show tables like "'.$this->table.'"');
+        if(empty($exist)){
+            $sql = "CREATE TABLE IF NOT EXISTS {$this->table} LIKE log_api";
+            Db::execute($sql);
+        }
+        parent::__construct();
+    }
+
+
+}

+ 8 - 0
application/index/model/ProductAttrModel.php

@@ -0,0 +1,8 @@
+<?php
+namespace app\index\model;
+class ProductAttrModel extends BaseModel
+{
+    protected $table='product_attr';
+    protected $connection = 'db_mall';
+
+}

+ 7 - 0
application/index/model/ProductAttrValueModel.php

@@ -0,0 +1,7 @@
+<?php
+namespace app\index\model;
+class ProductAttrValueModel extends BaseModel
+{
+    protected $table='product_attr_value';
+    protected $connection = 'db_mall';
+}

+ 8 - 0
application/index/model/ProductCategoryModel.php

@@ -0,0 +1,8 @@
+<?php
+namespace app\index\model;
+class ProductCategoryModel extends BaseModel
+{
+    protected $table='product_category';
+    protected $connection = 'db_mall';
+
+}

+ 7 - 0
application/index/model/ProductImgModel.php

@@ -0,0 +1,7 @@
+<?php
+namespace app\index\model;
+class ProductImgModel extends BaseModel
+{
+    protected $table='product_img';
+    protected $connection = 'db_mall';
+}

+ 8 - 0
application/index/model/ProductModel.php

@@ -0,0 +1,8 @@
+<?php
+namespace app\index\model;
+class ProductModel extends BaseModel
+{
+    protected $table='product';
+    protected $connection = 'db_mall';
+
+}

+ 8 - 0
application/index/model/ProductOrderDetailModel.php

@@ -0,0 +1,8 @@
+<?php
+namespace app\index\model;
+
+class ProductOrderDetailModel extends BaseModel
+{
+    protected $table='order_detail';
+    protected $connection = 'db_mall';
+}

+ 31 - 0
application/index/model/ProductOrderModel.php

@@ -0,0 +1,31 @@
+<?php
+namespace app\index\model;
+class ProductOrderModel extends BaseModel
+{
+    protected $table='order';
+    protected $connection = 'db_mall';
+
+    public function getProductOrder($where){
+
+        $list = $this->where($where)->select();
+        if(!$list){
+            return [];
+        }
+        foreach($list as &$item){
+            $productOrderDetailModel = new ProductOrderDetailModel();
+            $productOrderDetail = $productOrderDetailModel->field('order_detail.*,product.product_name')->join("product","product.product_id = order_detail.product_id",'left')->where(['order_no'=>$item['order_no']])->select();
+            $item['detail'] = $productOrderDetail;
+        }
+
+        return $list;
+    }
+
+    /**
+     * 求条件下的订单数量
+     * @param $where
+     * @return int|string
+     */
+    public function getProductOrderCount($where){
+        return $this->where($where)->count();
+    }
+}

+ 8 - 0
application/index/model/RelProductAttrModel.php

@@ -0,0 +1,8 @@
+<?php
+namespace app\index\model;
+class RelProductAttrModel extends BaseModel
+{
+    protected $table='rel_product_attr';
+    protected $connection = 'db_mall';
+
+}

+ 7 - 0
application/index/model/ShortUrlModel.php

@@ -0,0 +1,7 @@
+<?php
+namespace app\index\model;
+use think\Model;
+class ShortUrlModel extends Model
+{
+    protected $table='short_url';
+}

+ 17 - 0
application/index/model/TokenModel.php

@@ -0,0 +1,17 @@
+<?php
+namespace app\index\model;
+use think\Model;
+class TokenModel extends Model
+{
+    protected $table='token';
+
+    public function getInfo($token,$company_code=''){
+        $where['start_time'] = ['elt',time()];
+        $where['end_time'] = ['egt',time()];
+        $where['status'] = 1;
+        $where['token'] = $token;
+        $where['company_code'] = $company_code;
+        $info = $this->where($where)->cache(30)->find();
+        return $info;
+    }
+}

+ 8 - 0
application/index/model/UserAddressModel.php

@@ -0,0 +1,8 @@
+<?php
+namespace app\index\model;
+class UserAddressModel extends BaseModel
+{
+    protected $table='user_address';
+    protected $connection = 'db_mall';
+
+}

+ 8 - 0
application/index/model/WxPayRecordModel.php

@@ -0,0 +1,8 @@
+<?php
+namespace app\index\model;
+use think\Model;
+
+class WxPayRecordModel extends Model
+{
+    protected $table='wx_pay_record';
+}

+ 69 - 0
application/index/model/activity/ActivityModel.php

@@ -0,0 +1,69 @@
+<?php
+namespace app\index\model\activity;
+use app\index\model\BaseModel;
+
+class ActivityModel extends BaseModel
+{
+    protected $table='activity';
+    protected $connection = 'db_activity';
+
+    /**
+     * 给前端页面显示所用 主要是活动列表+活动所收藏的人
+     * @param $where
+     * @param $order
+     * @param int $limit
+     * @return false|\PDOStatement|string|\think\Collection
+     */
+    public function getListAndCollection($where,$order='sort desc,activity_id desc',$limit=100){
+        return $this->field('activity.*,count(collection.id) as collection_num')
+            ->join("collection","activity.activity_id = collection.activity_id","LEFT")
+            ->where($where)->order($order)->limit($limit)->group('activity.activity_id')->select();
+    }
+
+    /**
+     * 获取当前用户所关注的收藏列表
+     * @param $user_id
+     * @return array
+     */
+    public function getCurrentUserCollectionList($user_id){
+        $collectionModel = new CollectionModel();
+        $collectList = $collectionModel->getList(['user_id'=>$user_id,'status'=>0],"",1000);
+        $collectionActivityIds = [];
+        foreach($collectList as $item){
+            $collectionActivityIds[$item['activity_id']] = 0;
+        }
+        return $collectionActivityIds;
+    }
+
+    /**
+     * 获取当前用户是否收藏了该活动
+     * @param $user_id
+     * @param $activity_id
+     * @return array
+     */
+    public function getCurrentUserIsCollection($user_id,$activity_id){
+        $collectionModel = new CollectionModel();
+        $collect = $collectionModel->getOne([
+            'user_id'=>$user_id,
+            'activity_id'=>$activity_id,
+            'status'=>0
+        ]);
+        return $collect;
+    }
+
+    /**
+     * 获取该活动收藏数目
+     * @param $activity_id
+     * @return array
+     */
+    public function getCollectionCount($activity_id){
+        $collectionModel = new CollectionModel();
+        $collect_count = $collectionModel->where([
+            'activity_id'=>$activity_id,
+            'status'=>0
+        ])->count();
+
+        return $collect_count;
+    }
+
+}

+ 9 - 0
application/index/model/activity/ActivityOrderDetailModel.php

@@ -0,0 +1,9 @@
+<?php
+namespace app\index\model\activity;
+use app\index\model\BaseModel;
+
+class ActivityOrderDetailModel extends BaseModel
+{
+    protected $table='activity_order_detail';
+    protected $connection = 'db_activity';
+}

+ 25 - 0
application/index/model/activity/ActivityOrderModel.php

@@ -0,0 +1,25 @@
+<?php
+namespace app\index\model\activity;
+use app\index\model\BaseModel;
+
+class ActivityOrderModel extends BaseModel
+{
+    protected $table='activity_order';
+    protected $connection = 'db_activity';
+
+    /**
+     * 获取该活动订单
+     * @param $activity_id
+     * @param $limit
+     * @param $field
+     * @return array
+     */
+    public function getOrderListByActivityId($activity_id,$limit=10,$field="*"){
+        $list = $this->field($field)->where([
+            'activity_id'=>$activity_id,
+            'status'=>0
+        ])->order('activity_order_id desc')->limit($limit)->select();
+
+        return $list;
+    }
+}

+ 10 - 0
application/index/model/activity/ActivityPriceModel.php

@@ -0,0 +1,10 @@
+<?php
+namespace app\index\model\activity;
+use app\index\model\BaseModel;
+
+class ActivityPriceModel extends BaseModel
+{
+    protected $table='activity_price';
+    protected $connection = 'db_activity';
+
+}

+ 10 - 0
application/index/model/activity/ActivityTimeModel.php

@@ -0,0 +1,10 @@
+<?php
+namespace app\index\model\activity;
+use app\index\model\BaseModel;
+
+class ActivityTimeModel extends BaseModel
+{
+    protected $table='activity_time';
+    protected $connection = 'db_activity';
+
+}

+ 25 - 0
application/index/model/activity/CollectionModel.php

@@ -0,0 +1,25 @@
+<?php
+namespace app\index\model\activity;
+use app\index\model\BaseModel;
+
+class CollectionModel extends BaseModel
+{
+    protected $table='collection';
+    protected $connection = 'db_activity';
+
+
+    /**
+     * 用户活动收藏
+     * @param $where
+     * @param string $order
+     * @param int $limit
+     * @return array|false|\PDOStatement|string|\think\Model
+     */
+    public function getActivityCollection($where,$order='add_time desc',$limit=50){
+        return $this->field('collection.*,activity.activity_img,activity.title,activity.show_param')
+            ->join('activity','activity.activity_id=collection.activity_id','LEFT')
+            ->where($where)
+            ->order($order)
+            ->limit($limit)->select();
+    }
+}

+ 10 - 0
application/index/model/activity/WxPayRecordModel.php

@@ -0,0 +1,10 @@
+<?php
+namespace app\index\model\activity;
+use think\Model;
+
+class WxPayRecordModel extends Model
+{
+    protected $table='wx_pay_record';
+    protected $connection = 'db_activity';
+
+}

+ 10 - 0
application/index/model/hotel/HotelModel.php

@@ -0,0 +1,10 @@
+<?php
+namespace app\index\model\hotel;
+use app\index\model\BaseModel;
+
+class HotelModel extends BaseModel
+{
+    protected $table='hotel';
+    protected $connection = 'db_hotel';
+
+}

+ 14 - 0
application/index/model/hotel/OrderModel.php

@@ -0,0 +1,14 @@
+<?php
+namespace app\index\model\hotel;
+use app\index\model\BaseModel;
+
+class OrderModel extends BaseModel
+{
+    protected $table='order';
+    protected $connection = 'db_hotel';
+
+    public function getOrderNumByDate($hotel_id,$room_id,$date){
+        $res = $this->where("hotel_id = $hotel_id and room_id = $room_id and start_date <= '$date' and end_date > '$date' and (status=1 or status=6) ")->sum('total_room_num');
+        return intval($res);
+    }
+}

+ 37 - 0
application/index/model/hotel/RoomModel.php

@@ -0,0 +1,37 @@
+<?php
+namespace app\index\model\hotel;
+use app\index\model\BaseModel;
+
+class RoomModel extends BaseModel
+{
+    protected $table='room';
+    protected $connection = 'db_hotel';
+
+    /**
+     * 获取当前日期可预约的房间列表
+     * @param $hotel_id
+     * @param $date
+     * @return false|\PDOStatement|string|\think\Collection
+     */
+    public function getReservedRoomList($hotel_id,$date){
+        $roomList = $this->field('room.room_id,room.room_name,room_imgs,room_price,room.total_number,COALESCE(sum(total_room_num),0) as sum_num')
+            ->join('order',"(room.hotel_id = order.hotel_id and room.room_id = order.room_id and (order.status =1 or order.status =6) and start_date <= '{$date}' and end_date > '{$date}')",'LEFT')
+            ->where([
+                'room.hotel_id'=>$hotel_id,
+                'room.status'=>0
+            ])->group('room.room_id')->select();
+
+        return $roomList;
+    }
+
+
+    /**
+     * 获取当前房间的信息
+     * @param $hotel_id
+     * @param $room_id
+     * @return mixed
+     */
+    public function getRoomInfo($hotel_id,$room_id){
+        return $this->where(['hotel_id'=>$hotel_id,'room_id'=>$room_id])->find();
+    }
+}

+ 10 - 0
application/index/model/hotel/WxPayRecordModel.php

@@ -0,0 +1,10 @@
+<?php
+namespace app\index\model\hotel;
+use think\Model;
+
+class WxPayRecordModel extends Model
+{
+    protected $table='wx_pay_record';
+    protected $connection = 'db_hotel';
+
+}

+ 35 - 0
application/index/service/ActivityService.php

@@ -0,0 +1,35 @@
+<?php
+namespace app\index\service;
+use app\index\model\activity\ActivityOrderModel;
+use think\Db;
+
+class ActivityService extends BaseService
+{
+    /**
+     * 根据条件获取活动列表
+     * @param $params
+     * @return false|\PDOStatement|string|\think\Collection
+     */
+   public function getActivityOrderListByCondition($params){
+       $activityOrderModel = new ActivityOrderModel();
+       $activityOrderList = $activityOrderModel->getList($params);
+
+       return $activityOrderList;
+   }
+
+
+    /**
+     * 根据条件获取活动列表
+     * @param $params
+     * @param $order
+     * @param $page
+     * @param $pageSize
+     * @return false|\PDOStatement|string|\think\Collection
+     */
+    public function getActivityOrderPageByCondition($params,$order,$page,$pageSize){
+        $activityOrderModel = new ActivityOrderModel();
+        $activityOrderList = $activityOrderModel->getPage($params,$order,$page,$pageSize);
+
+        return $activityOrderList;
+    }
+}

+ 64 - 0
application/index/service/AuthService.php

@@ -0,0 +1,64 @@
+<?php
+namespace app\index\service;
+use app\index\model\AuthCompanyModel;
+use app\index\model\AuthModel;
+use app\index\model\TokenModel;
+
+class AuthService extends BaseService
+{
+    public function checkAuth($data)
+    {
+        $AuthModel = new AuthModel();
+        $TokenModel = new TokenModel();
+        $AuthCompanyModel = new AuthCompanyModel();
+        $info = $AuthModel->getInfo(['account' => $data['account'], 'password' => $data['password']]);
+        if (empty($info)) {
+            return $this->return_code[20001];
+        } else {
+            if ($info['start_time'] > time() || $info['end_time'] < time()) {
+                return $this->return_code[20002];
+            } elseif ($info['status'] == 2) {
+                return $this->return_code[20003];
+            } else {
+                $res = $this->return_code[200];
+                $res['data'] = [];
+                $res['data']['access_token'] = $this->_randVar(64,6);
+                $res['data']['expires_in'] = 7200;
+                $company_info = $AuthCompanyModel->getInfo(['company_code'=>$info['company_code']]);
+                $insert['token'] = $res['data']['access_token'];
+                $insert['start_time'] = time();
+                $insert['end_time'] = time()+7200;
+                $insert['company_code'] = $info['company_code'];
+                $insert['status'] = 1;
+                $insert['db_json'] = $company_info['db_json'];
+                $insert['sms_json'] = $company_info['sms_json'];
+
+                //$TokenModel->save(['status'=>2],['company_code'=>$info['company_code']]);
+                $TokenModel->insert($insert);
+                return $res;
+            }
+        }
+    }
+
+    private function _randVar($length = 0, $type = 0)
+    {
+        $range = array(
+            0 => '0123456789',
+            1 => 'abcdefghijklmnopqrstuvwxyz',
+            2 => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
+            3 => '0123456789abcdefghijklmnopqrstuvwxyz',
+            4 => '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
+            5 => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
+            6 => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
+            7 => '3456789abcdefghijkmnpqrstuvwxyABCDEFGHJKLMNPQRSTUVWXY');
+        if (false === array_key_exists($type, $range)) {
+            $type = 6;
+        }
+        $character = '';
+        $maxLength = strlen($range[$type]) - 1;
+        for ($i = 0; $i < $length; ++$i) {
+            $character .= $range[$type][mt_rand(0, $maxLength)];
+        }
+        return $character;
+    }
+}

+ 26 - 0
application/index/service/BaseService.php

@@ -0,0 +1,26 @@
+<?php
+namespace app\index\service;
+class BaseService
+{
+    public $return_code = [
+        //唯一成功标志
+        200=>['code'=>200,'msg'=>'请求成功'],
+
+
+        //基础配置
+        20001=>['code'=>20001,'msg'=>'用户名或密码错误'],
+        20002=>['code'=>20002,'msg'=>'不在授权时间段'],
+        20003=>['code'=>20003,'msg'=>'账户异常'],
+        20004=>['code'=>20004,'msg'=>'签名失败'],
+
+        40000=>['code'=>40000,'msg'=>'请求异常'],
+        40003=>['code'=>40003,'nsg'=>'异常抛出'],
+        40044=>['code'=>40044,'msg'=>'token无效'],
+        40400=>['code'=>40400,'msg'=>'修改失败'],
+
+
+        //产品相关
+        40001=>['code'=>40001,'msg'=>'插入产品表失败','data'=>''],
+        40002=>['code'=>40002,'msg'=>'插入产品属性关系表失败','data'=>''],
+    ];
+}

+ 486 - 0
application/index/service/HelperService.php

@@ -0,0 +1,486 @@
+<?php
+namespace app\index\service;
+
+use app\index\model\LogApiModel;
+use app\index\service\wechat\WxPayConfig;
+use think\Cache;
+use think\Request;
+
+class HelperService extends BaseService
+{
+
+    public static $_startExecTime = 0.0000;
+    public static $_inputParams = [];
+    public static $_httpErr = null;//httpPost错误信息
+    public static $_httpStatus = null;//httpPost返回的状态码
+    public static $_httpReturn = null;//httpPost返回值
+    /*
+     * 返回参数,并且书写日志
+     */
+    public static function returnParam($data,$params=[]){
+        self::addLog($data,$params);
+        return json_encode($data,JSON_UNESCAPED_UNICODE);
+    }
+
+    /*
+     * 返回参数,并且书写日志
+     */
+    public static function addLog($data,$params=[]){
+        if(empty($params)){
+            $params = file_get_contents("php://input");
+            $params = json_decode($params,true);
+        }
+        $request = Request::instance();
+        $params['_client_ip_'] = $request->ip(0,true);
+
+        $LogApiModel = new LogApiModel();
+        $log_data['request_param'] = json_encode($params);
+        $log_data['request_url'] = isset($_SERVER["REQUEST_URI"])?$_SERVER["REQUEST_URI"]:'';
+        $log_data['return_param'] = json_encode($data);
+        $log_data['add_time'] = time();
+        $log_data['exec_time'] = microtime(true)-HelperService::$_startExecTime;
+        $LogApiModel->insert($log_data);
+
+        self::pushRedis($log_data,$data,$params);
+    }
+
+    public static function pushRedis($log_data,$data,$params){
+
+        //return true;
+        try {
+            $data = [
+                "companyCode" => "CHENSEN",
+                "projectCode" => "Vapi",
+                "requestParam" => $params,
+                "requestTime" => microtime(true),
+                "requestUrl" => $log_data['request_url'],
+                "responseTime" => $log_data['exec_time'],
+                "returnCode" => isset($data['code']) ? $data['code'] : "==",
+                "returnData" => $data,
+                "returnMsg" => isset($data['msg']) ? $data['msg'] : "==",
+            ];
+
+            //$redis = new \Redis();
+            //$redis->connect('47.97.187.118', 6379);
+            //$redis->auth('gudong-hz');
+            //$redis->rpush('request_list', json_encode($data));
+        }catch (\Exception $ex){
+            return true;
+        }
+    }
+
+
+    public static function getWechatToken($companyCode,$is_force=false){
+        $ticket = Cache::get('jsapi_'.$companyCode);
+        if(!empty($ticket) && $is_force==false){
+            $data = [
+                'code'=>200,
+                'msg'=>'cache',
+                'data'=>"$ticket"
+            ];
+            self::pushRedis([
+                'request_url'=>"HelperService-getWechatToken",
+                'exec_time'=>0.000,
+            ],$data,[]);
+
+            return $data;
+        }
+        $request_token = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".WxPayConfig::$APPID."&secret=".WxPayConfig::$APPSECRET;
+        $token_json = HelperService::httpPost($request_token,'',true);
+        if($token_json === false){
+            $data = [
+                'code'=>'400',
+                'msg'=>'companyCode is error',
+                'data'=>$token_json
+            ];
+            self::pushRedis([
+                'request_url'=>"HelperService-getWechatToken",
+                'exec_time'=>0.000,
+            ],$data,[]);
+            return $data;
+        }
+        $tokenArr = json_decode($token_json,true);
+        if(!isset($tokenArr['access_token'])){
+            $data = [
+                'code'=>'400',
+                'msg'=>'access_token error',
+                'data'=>$token_json
+            ];
+            self::pushRedis([
+                'request_url'=>"HelperService-getWechatToken",
+                'exec_time'=>0.000,
+            ],$data,[]);
+            return $data;
+        }
+        $token = $tokenArr['access_token'];
+
+        $request_ticket = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=$token&type=jsapi";
+        $ticket_json = HelperService::httpPost($request_ticket,'',true);
+        if($token_json === false){
+            $data = [
+                'code'=>'400',
+                'msg'=>'ticket json is error',
+                'data'=>$token_json
+            ];
+            self::pushRedis([
+                'request_url'=>"HelperService-getWechatToken",
+                'exec_time'=>0.000,
+            ],$data,[]);
+
+            return $data;
+        }
+        $ticketArr = json_decode($ticket_json,true);
+        $ticket = $ticketArr['ticket'];
+
+        Cache::set('jsapi_'.$companyCode,$ticket,300);
+
+        $data = [
+            'code'=>200,
+            'msg'=>'curl',
+            'data'=>"$ticket"
+        ];
+        self::pushRedis([
+            'request_url'=>"HelperService-getWechatToken",
+            'exec_time'=>0.000,
+        ],$data,[]);
+
+        return $data;
+    }
+
+    /**
+     * 重构returnParam的意思
+     * @param $data
+     * @param $params
+     */
+    public static function returnJson($data,$params=[]){
+        die(HelperService::returnParam($data,$params));
+    }
+
+    /**
+     * 接口验证参数的方法
+     * @param $param_list
+     * @param $post
+     * @return bool
+     */
+    public static function diffParam($param_list,$post){
+
+        $must_params = array_filter($param_list);
+        $diff_array = array_diff_key($must_params,$post);
+        if(!empty($diff_array)){
+            $warn = key($diff_array);
+            HelperService::returnJson(['code'=>4001,'msg'=>"$warn don't find ",'data'=>null]);
+        }
+
+        //$format上面的0、不必须,1、必须有string;2、必须有number;3、必须有数组
+        foreach($param_list as $key=>$format){
+            switch($format){
+                case 'string':
+                    if(empty($post[$key])){
+                        HelperService::returnJson(['code'=>4001,'msg'=>"$key format is empty",'data'=>null]);
+                    }
+                    break;
+                case 'number':
+                    if(empty($post[$key]) || !is_numeric($post[$key])){
+                        HelperService::returnJson(['code'=>4001,'msg'=>"$key format must number",'data'=>null]);
+                    }
+                    break;
+                case 'array':
+                    if(empty($post[$key]) || !is_array($post[$key])){
+                        HelperService::returnJson(['code'=>4001,'msg'=>"$key format must array",'data'=>null]);
+                    }
+                    break;
+                case 'mobile':
+                    if(empty($post[$key]) || !preg_match('/^1\d{10}$/',$post[$key])){
+                        HelperService::returnJson(['code'=>4001,'msg'=>"$key format is error",'data'=>null]);
+                    }
+                case 'int':
+                    $post[$key] = intval($post[$key]);
+                    break;
+                case 'date':
+                    if($post[$key] != date('Y-m-d',strtotime($post[$key]))){
+                        HelperService::returnJson(['code'=>4001,'msg'=>"$key format is error",'data'=>null]);
+                    }
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        return true;
+    }
+
+    public static function httpPost($url, $param='',$is_ssl=false,$header=[],$isJson=true) {
+        $url = str_replace(' ', '', $url);
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
+        curl_setopt($ch, CURLOPT_TIMEOUT, 60);
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($ch, CURLOPT_HEADER, 0);
+		if($is_ssl){
+            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+        }
+
+        if($isJson == false){
+            $requestHeader = [];
+        }else{
+            $requestHeader = [
+                'Content-Type: application/json; charset=utf-8',
+                'Content-Length:' . strlen($param)
+            ];
+        }
+
+        $requestHeader = array_merge($requestHeader,$header);
+        curl_setopt($ch, CURLOPT_HTTPHEADER,$requestHeader);
+        $tmpInfo = curl_exec($ch);
+        self::$_httpReturn = $tmpInfo;
+        self::$_httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+        if (curl_errno($ch)) {
+            self::$_httpErr = "url:$url--Errno:".curl_error($ch);
+            \think\Log::record('HTTPPOST:'.self::$_httpErr);
+            return false; // 不输出这个错误,耽误事,
+        }
+        curl_close($ch);
+         \think\Log::record('HTTPPOST:'.$tmpInfo);
+        return $tmpInfo;
+    }
+
+
+    public static function BankList($key){
+        $data = [
+            'ICBC_DEBIT'=>'工商银行(借记卡)',
+            'ICBC_CREDIT'=>'工商银行(信用卡)',
+            'ABC_DEBIT'=>'农业银行(借记卡)',
+            'ABC_CREDIT'=>'农业银行(信用卡)',
+            'PSBC_DEBIT'=>'邮政储蓄银行(借记卡)',
+            'PSBC_CREDIT'=>'邮政储蓄银行(信用卡)',
+            'CCB_DEBIT'=>'建设银行(借记卡)',
+            'CCB_CREDIT'=>'建设银行(信用卡)',
+            'CMB_DEBIT'=>'招商银行(借记卡)',
+            'CMB_CREDIT'=>'招商银行(信用卡)',
+            'BOC_DEBIT'=>'中国银行(借记卡)',
+            'BOC_CREDIT'=>'中国银行(信用卡)',
+            'COMM_DEBIT'=>'交通银行(借记卡)',
+            'COMM_CREDIT'=>'交通银行(信用卡)',
+            'SPDB_DEBIT'=>'浦发银行(借记卡)',
+            'SPDB_CREDIT'=>'浦发银行(信用卡)',
+            'GDB_DEBIT'=>'广发银行(借记卡)',
+            'GDB_CREDIT'=>'广发银行(信用卡)',
+            'CMBC_DEBIT'=>'民生银行(借记卡)',
+            'CMBC_CREDIT'=>'民生银行(信用卡)',
+            'PAB_DEBIT'=>'平安银行(借记卡)',
+            'PAB_CREDIT'=>'平安银行(信用卡)',
+            'CEB_DEBIT'=>'光大银行(借记卡)',
+            'CEB_CREDIT'=>'光大银行(信用卡)',
+            'CIB_DEBIT'=>'兴业银行(借记卡)',
+            'CIB_CREDIT'=>'兴业银行(信用卡)',
+            'CITIC_DEBIT'=>'中信银行(借记卡)',
+            'CITIC_CREDIT'=>'中信银行(信用卡)',
+            'BOSH_DEBIT'=>'上海银行(借记卡)',
+            'BOSH_CREDIT'=>'上海银行(信用卡)',
+            'CRB_DEBIT'=>'华润银行(借记卡)',
+            'HZB_DEBIT'=>'杭州银行(借记卡)',
+            'HZB_CREDIT'=>'杭州银行(信用卡)',
+            'BSB_DEBIT'=>'包商银行(借记卡)',
+            'BSB_CREDIT'=>'包商银行(信用卡)',
+            'CQB_DEBIT'=>'重庆银行(借记卡)',
+            'SDEB_DEBIT'=>'顺德农商行(借记卡)',
+            'SZRCB_DEBIT'=>'深圳农商银行(借记卡)',
+            'SZRCB_CREDIT'=>'深圳农商银行(信用卡)',
+            'HRBB_DEBIT'=>'哈尔滨银行(借记卡)',
+            'BOCD_DEBIT'=>'成都银行(借记卡)',
+            'GDNYB_DEBIT'=>'南粤银行(借记卡)',
+            'GDNYB_CREDIT'=>'南粤银行(信用卡)',
+            'GZCB_DEBIT'=>'广州银行(借记卡)',
+            'GZCB_CREDIT'=>'广州银行(信用卡)',
+            'JSB_DEBIT'=>'江苏银行(借记卡)',
+            'JSB_CREDIT'=>'江苏银行(信用卡)',
+            'NBCB_DEBIT'=>'宁波银行(借记卡)',
+            'NBCB_CREDIT'=>'宁波银行(信用卡)',
+            'NJCB_DEBIT'=>'南京银行(借记卡)',
+            'QHNX_DEBIT'=>'青海农信(借记卡)',
+            'ORDOSB_CREDIT'=>'鄂尔多斯银行(信用卡)',
+            'ORDOSB_DEBIT'=>'鄂尔多斯银行(借记卡)',
+            'BJRCB_CREDIT'=>'北京农商(信用卡)',
+            'BHB_DEBIT'=>'河北银行(借记卡)',
+            'BGZB_DEBIT'=>'贵州银行(借记卡)',
+            'BEEB_DEBIT'=>'鄞州银行(借记卡)',
+            'PZHCCB_DEBIT'=>'攀枝花银行(借记卡)',
+            'QDCCB_CREDIT'=>'青岛银行(信用卡)',
+            'QDCCB_DEBIT'=>'青岛银行(借记卡)',
+            'SHINHAN_DEBIT'=>'新韩银行(借记卡)',
+            'QLB_DEBIT'=>'齐鲁银行(借记卡)',
+            'QSB_DEBIT'=>'齐商银行(借记卡)',
+            'ZZB_DEBIT'=>'郑州银行(借记卡)',
+            'CCAB_DEBIT'=>'长安银行(借记卡)',
+            'RZB_DEBIT'=>'日照银行(借记卡)',
+            'SCNX_DEBIT'=>'四川农信(借记卡)',
+            'BEEB_CREDIT'=>'鄞州银行(信用卡)',
+            'SDRCU_DEBIT'=>'山东农信(借记卡)',
+            'BCZ_DEBIT'=>'沧州银行(借记卡)',
+            'SJB_DEBIT'=>'盛京银行(借记卡)',
+            'LNNX_DEBIT'=>'辽宁农信(借记卡)',
+            'JUFENGB_DEBIT'=>'临朐聚丰村镇银行(借记卡)',
+            'ZZB_CREDIT'=>'郑州银行(信用卡)',
+            'JXNXB_DEBIT'=>'江西农信(借记卡)',
+            'JZB_DEBIT'=>'晋中银行(借记卡)',
+            'JZCB_CREDIT'=>'锦州银行(信用卡)',
+            'JZCB_DEBIT'=>'锦州银行(借记卡)',
+            'KLB_DEBIT'=>'昆仑银行(借记卡)',
+            'KRCB_DEBIT'=>'昆山农商(借记卡)',
+            'KUERLECB_DEBIT'=>'库尔勒市商业银行(借记卡)',
+            'LJB_DEBIT'=>'龙江银行(借记卡)',
+            'NYCCB_DEBIT'=>'南阳村镇银行(借记卡)',
+            'LSCCB_DEBIT'=>'乐山市商业银行(借记卡)',
+            'LUZB_DEBIT'=>'柳州银行(借记卡)',
+            'LWB_DEBIT'=>'莱商银行(借记卡)',
+            'LYYHB_DEBIT'=>'辽阳银行(借记卡)',
+            'LZB_DEBIT'=>'兰州银行(借记卡)',
+            'MINTAIB_CREDIT'=>'民泰银行(信用卡)',
+            'MINTAIB_DEBIT'=>'民泰银行(借记卡)',
+            'NCB_DEBIT'=>'宁波通商银行(借记卡)',
+            'NMGNX_DEBIT'=>'内蒙古农信(借记卡)',
+            'XAB_DEBIT'=>'西安银行(借记卡)',
+            'WFB_CREDIT'=>'潍坊银行(信用卡)',
+            'WFB_DEBIT'=>'潍坊银行(借记卡)',
+            'WHB_CREDIT'=>'威海商业银行(信用卡)',
+            'WHB_DEBIT'=>'威海市商业银行(借记卡)',
+            'WHRC_CREDIT'=>'武汉农商(信用卡)',
+            'WHRC_DEBIT'=>'武汉农商行(借记卡)',
+            'WJRCB_DEBIT'=>'吴江农商行(借记卡)',
+            'WLMQB_DEBIT'=>'乌鲁木齐银行(借记卡)',
+            'WRCB_DEBIT'=>'无锡农商(借记卡)',
+            'WZB_DEBIT'=>'温州银行(借记卡)',
+            'XAB_CREDIT'=>'西安银行(信用卡)',
+            'WEB_DEBIT'=>'微众银行(借记卡)',
+            'XIB_DEBIT'=>'厦门国际银行(借记卡)',
+            'XJRCCB_DEBIT'=>'新疆农信银行(借记卡)',
+            'XMCCB_DEBIT'=>'厦门银行(借记卡)',
+            'YNRCCB_DEBIT'=>'云南农信(借记卡)',
+            'YRRCB_CREDIT'=>'黄河农商银行(信用卡)',
+            'YRRCB_DEBIT'=>'黄河农商银行(借记卡)',
+            'YTB_DEBIT'=>'烟台银行(借记卡)',
+            'ZJB_DEBIT'=>'紫金农商银行(借记卡)',
+            'ZJLXRB_DEBIT'=>'兰溪越商银行(借记卡)',
+            'ZJRCUB_CREDIT'=>'浙江农信(信用卡)',
+            'AHRCUB_DEBIT'=>'安徽省农村信用社联合社(借记卡)',
+            'BCZ_CREDIT'=>'沧州银行(信用卡)',
+            'SRB_DEBIT'=>'上饶银行(借记卡)',
+            'ZYB_DEBIT'=>'中原银行(借记卡)',
+            'ZRCB_DEBIT'=>'张家港农商行(借记卡)',
+            'SRCB_CREDIT'=>'上海农商银行(信用卡)',
+            'SRCB_DEBIT'=>'上海农商银行(借记卡)',
+            'ZJTLCB_DEBIT'=>'浙江泰隆银行(借记卡)',
+            'SUZB_DEBIT'=>'苏州银行(借记卡)',
+            'SXNX_DEBIT'=>'山西农信(借记卡)',
+            'SXXH_DEBIT'=>'陕西信合(借记卡)',
+            'ZJRCUB_DEBIT'=>'浙江农信(借记卡)',
+            'AE_CREDIT'=>'AE(信用卡)',
+            'TACCB_CREDIT'=>'泰安银行(信用卡)',
+            'TACCB_DEBIT'=>'泰安银行(借记卡)',
+            'TCRCB_DEBIT'=>'太仓农商行(借记卡)',
+            'TJBHB_CREDIT'=>'天津滨海农商行(信用卡)',
+            'TJBHB_DEBIT'=>'天津滨海农商行(借记卡)',
+            'TJB_DEBIT'=>'天津银行(借记卡)',
+            'TRCB_DEBIT'=>'天津农商(借记卡)',
+            'TZB_DEBIT'=>'台州银行(借记卡)',
+            'URB_DEBIT'=>'联合村镇银行(借记卡)',
+            'DYB_CREDIT'=>'东营银行(信用卡)',
+            'CSRCB_DEBIT'=>'常熟农商银行(借记卡)',
+            'CZB_CREDIT'=>'浙商银行(信用卡)',
+            'CZB_DEBIT'=>'浙商银行(借记卡)',
+            'CZCB_CREDIT'=>'稠州银行(信用卡)',
+            'CZCB_DEBIT'=>'稠州银行(借记卡)',
+            'DANDONGB_CREDIT'=>'丹东银行(信用卡)',
+            'DANDONGB_DEBIT'=>'丹东银行(借记卡)',
+            'DLB_CREDIT'=>'大连银行(信用卡)',
+            'DLB_DEBIT'=>'大连银行(借记卡)',
+            'DRCB_CREDIT'=>'东莞农商银行(信用卡)',
+            'DRCB_DEBIT'=>'东莞农商银行(借记卡)',
+            'CSRCB_CREDIT'=>'常熟农商银行(信用卡)',
+            'DYB_DEBIT'=>'东营银行(借记卡)',
+            'DYCCB_DEBIT'=>'德阳银行(借记卡)',
+            'FBB_DEBIT'=>'富邦华一银行(借记卡)',
+            'FDB_DEBIT'=>'富滇银行(借记卡)',
+            'FJHXB_CREDIT'=>'福建海峡银行(信用卡)',
+            'FJHXB_DEBIT'=>'福建海峡银行(借记卡)',
+            'FJNX_DEBIT'=>'福建农信银行(借记卡)',
+            'FUXINB_DEBIT'=>'阜新银行(借记卡)',
+            'BOCDB_DEBIT'=>'承德银行(借记卡)',
+            'JSNX_DEBIT'=>'江苏农商行(借记卡)',
+            'BOLFB_DEBIT'=>'廊坊银行(借记卡)',
+            'CCAB_CREDIT'=>'长安银行(信用卡)',
+            'CBHB_DEBIT'=>'渤海银行(借记卡)',
+            'CDRCB_DEBIT'=>'成都农商银行(借记卡)',
+            'BYK_DEBIT'=>'营口银行(借记卡)',
+            'BOZ_DEBIT'=>'张家口市商业银行(借记卡)',
+            'CFT'=>'零钱',
+            'BOTSB_DEBIT'=>'唐山银行(借记卡)',
+            'BOSZS_DEBIT'=>'石嘴山银行(借记卡)',
+            'BOSXB_DEBIT'=>'绍兴银行(借记卡)',
+            'BONX_DEBIT'=>'宁夏银行(借记卡)',
+            'BONX_CREDIT'=>'宁夏银行(信用卡)',
+            'GDHX_DEBIT'=>'广东华兴银行(借记卡)',
+            'BOLB_DEBIT'=>'洛阳银行(借记卡)',
+            'BOJX_DEBIT'=>'嘉兴银行(借记卡)',
+            'BOIMCB_DEBIT'=>'内蒙古银行(借记卡)',
+            'BOHN_DEBIT'=>'海南银行(借记卡)',
+            'BOD_DEBIT'=>'东莞银行(借记卡)',
+            'CQRCB_CREDIT'=>'重庆农商银行(信用卡)',
+            'CQRCB_DEBIT'=>'重庆农商银行(借记卡)',
+            'CQTGB_DEBIT'=>'重庆三峡银行(借记卡)',
+            'BOD_CREDIT'=>'东莞银行(信用卡)',
+            'CSCB_DEBIT'=>'长沙银行(借记卡)',
+            'BOB_CREDIT'=>'北京银行(信用卡)',
+            'GDRCU_DEBIT'=>'广东农信银行(借记卡)',
+            'BOB_DEBIT'=>'北京银行(借记卡)',
+            'HRXJB_DEBIT'=>'华融湘江银行(借记卡)',
+            'HSBC_DEBIT'=>'恒生银行(借记卡)',
+            'HSB_CREDIT'=>'徽商银行(信用卡)',
+            'HSB_DEBIT'=>'徽商银行(借记卡)',
+            'HUNNX_DEBIT'=>'湖南农信(借记卡)',
+            'HUSRB_DEBIT'=>'湖商村镇银行(借记卡)',
+            'HXB_CREDIT'=>'华夏银行(信用卡)',
+            'HXB_DEBIT'=>'华夏银行(借记卡)',
+            'HNNX_DEBIT'=>'河南农信(借记卡)',
+            'BNC_DEBIT'=>'江西银行(借记卡)',
+            'BNC_CREDIT'=>'江西银行(信用卡)',
+            'BJRCB_DEBIT'=>'北京农商行(借记卡)',
+            'JCB_DEBIT'=>'晋城银行(借记卡)',
+            'JJCCB_DEBIT'=>'九江银行(借记卡)',
+            'JLB_DEBIT'=>'吉林银行(借记卡)',
+            'JLNX_DEBIT'=>'吉林农信(借记卡)',
+            'JNRCB_DEBIT'=>'江南农商(借记卡)',
+            'JRCB_DEBIT'=>'江阴农商行(借记卡)',
+            'JSHB_DEBIT'=>'晋商银行(借记卡)',
+            'HAINNX_DEBIT'=>'海南农信(借记卡)',
+            'GLB_DEBIT'=>'桂林银行(借记卡)',
+            'GRCB_CREDIT'=>'广州农商银行(信用卡)',
+            'GRCB_DEBIT'=>'广州农商银行(借记卡)',
+            'GSB_DEBIT'=>'甘肃银行(借记卡)',
+            'GSNX_DEBIT'=>'甘肃农信(借记卡)',
+            'GXNX_DEBIT'=>'广西农信(借记卡)',
+            'GYCB_CREDIT'=>'贵阳银行(信用卡)',
+            'GYCB_DEBIT'=>'贵阳银行(借记卡)',
+            'GZNX_DEBIT'=>'贵州农信(借记卡)',
+            'HAINNX_CREDIT'=>'海南农信(信用卡)',
+            'HKB_DEBIT'=>'汉口银行(借记卡)',
+            'HANAB_DEBIT'=>'韩亚银行(借记卡)',
+            'HBCB_CREDIT'=>'湖北银行(信用卡)',
+            'HBCB_DEBIT'=>'湖北银行(借记卡)',
+            'HBNX_CREDIT'=>'湖北农信(信用卡)',
+            'HBNX_DEBIT'=>'湖北农信(借记卡)',
+            'HDCB_DEBIT'=>'邯郸银行(借记卡)',
+            'HEBNX_DEBIT'=>'河北农信(借记卡)',
+            'HFB_DEBIT'=>'恒丰银行(借记卡)',
+            'HKBEA_DEBIT'=>'东亚银行(借记卡)',
+            'JCB_CREDIT'=>'JCB(信用卡)',
+            'MASTERCARD_CREDIT'=>'MASTERCARD(信用卡)',
+            'VISA_CREDIT'=>'VISA(信用卡)',
+            'LQT'=>'零钱通'
+        ];
+
+        return isset($data[$key])?$data[$key]:'未知';
+    }
+}

+ 182 - 0
application/index/service/ProductService.php

@@ -0,0 +1,182 @@
+<?php
+namespace app\index\service;
+use app\index\model\BuyCarModel;
+use app\index\model\ProductAttrModel;
+use app\index\model\ProductAttrValueModel;
+use app\index\model\ProductImgModel;
+use app\index\model\ProductModel;
+use app\index\model\ProductCategoryModel;
+use app\index\model\ProductOrderDetailModel;
+use app\index\model\RelProductAttrModel;
+use think\Db;
+class ProductService extends BaseService
+{
+    /**
+     * @param $data
+     * @return mixed
+     * 修改产品
+     */
+    public function upProductInfo($data)
+    {
+        $where['product_id'] = $data['product_id'];
+        $ProductModel = new ProductModel();
+        $ProductModel->upInfo($where,$data);
+        return $this->return_code[200];
+    }
+
+    /**
+     * @param $data
+     * @return mixed
+     * 添加产品
+     */
+    public function addProduct($data){
+
+        $product_value_id = $data['product_value_id'];
+        unset($data['product_value_id']);
+
+        $db_logistic = Db::connect('db_mall');
+        $db_logistic->startTrans();
+
+        $ProductModel = new ProductModel();
+        $id = $ProductModel->addInfo($data);
+        if(!$id){
+            $db_logistic->rollback();
+            return $this->return_code[40001];
+        }
+
+        $arr = [];
+        foreach($product_value_id as $k=>$v){
+            $arr[$k]['product_id'] = $id;
+            $arr[$k]['product_value_id'] = $v;
+        }
+        $RelProductAttrModel = new RelProductAttrModel();
+        $rows = $RelProductAttrModel->addAllInfo($arr);
+        if(!$rows){
+            $db_logistic->rollback();
+            return $this->return_code[40002];
+        }
+
+        $db_logistic->commit();
+        return $this->return_code[200];
+    }
+
+    public function addProductCategory($data){
+
+        $ProductCategoryModel = new ProductCategoryModel();
+        $id = $ProductCategoryModel->addInfo($data);
+        return $id;
+    }
+
+    public function upProductCategory($data){
+        $where['category_id'] = $data['category_id'];
+        $ProductCategoryModel = new ProductCategoryModel();
+        $res = $ProductCategoryModel->upInfo($where,$data);
+        return $res;
+    }
+
+    public function addProductAttr($data){
+        $ProductAttrModel = new ProductAttrModel();
+        $ProductAttrModel->addInfo($data);
+        return $this->return_code[200];
+
+    }
+
+    public function upProductAttr($data){
+        $where['attr_id'] = $data['attr_id'];
+        $ProductTypeModel = new ProductAttrModel();
+        $ProductTypeModel->upInfo($where,$data);
+        return $this->return_code[200];
+    }
+    //添加产品属性值
+    public function addProductAttrValue($data){
+        $arr = [];
+        foreach($data['value_name'] as $k=>$v){
+            $arr[$k]['attr_id'] = $data['attr_id'];
+            $arr[$k]['value_name'] = $v;
+        }
+        $ProductAttrValueModel = new ProductAttrValueModel();
+        $ProductAttrValueModel->addAllInfo($arr);
+        return $this->return_code[200];
+    }
+    //修改产品属性值
+    public function upProductAttrValue($data){
+        $where['product_value_id'] = $data['product_value_id'];
+        $ProductTypeValueModel = new ProductAttrValueModel();
+        $ProductTypeValueModel->upInfo($where,$data);
+        return $this->return_code[200];
+    }
+    //添加图片
+    public function addProductImg($data){
+        $arr = [];
+        foreach($data['img'] as $k=>$v){
+            $arr[$k]['product_id'] = $data['product_id'];
+            $arr[$k]['img'] = $v;
+        }
+        $ProductImgModel = new ProductImgModel();
+        $ProductImgModel->addAllInfo($arr);
+        return $this->return_code[200];
+    }
+    //修改图片
+    public function upProductImg($data){
+        $where['id'] = $data['id'];
+        $ProductImgModel = new ProductImgModel();
+        $ProductImgModel->upInfo($where,$data);
+        return $this->return_code[200];
+    }
+
+    /**
+     * 获取分类通过条件
+     * @param $condition
+     * @return array|false|\PDOStatement|string|\think\Model
+     */
+    public function getProductCategoryByCondition($condition){
+        $productCategory = new ProductCategoryModel();
+        return $productCategory->where($condition)->find();
+    }
+
+    /**
+     * 获取购物车里面的产品数量和价格
+     * @param $order_no
+     * @param $productIds
+     * @param $user_id
+     * @return int
+     */
+    public function getOrderPriceByProductIds($order_no,$productIds,$user_id){
+        $buyCarModel = new BuyCarModel();
+        $orderDetailModel = new ProductOrderDetailModel();
+        $buyCar = $buyCarModel->getCarAndProductInfo(['buy_car.product_id'=>['in',$productIds],'user_id'=>$user_id]);
+        $totalPrice = 0;
+        foreach($buyCar as $buyItem){
+            $totalPrice += $buyItem['num']*$buyItem['sales_price'];
+            $orderDetailModel->insertGetId([
+                'order_no'=>$order_no,
+                'product_id'=>$buyItem['product_id'],
+                'price'=>$buyItem['sales_price'],
+                'num'=>$buyItem['num'],
+            ]);
+            $buyCarModel->where(['id'=>$buyItem['buy_car_id']])->delete();
+        }
+
+        return $totalPrice;
+    }
+
+    /**
+     * 减少商品的库存
+     * @param $product_id
+     * @param $num
+     * @return bool
+     */
+    public function reduceStock($product_id,$num){
+        $productModel = new ProductModel();
+        $oneProduct = $productModel->getOne(['product_id'=>$product_id]);
+        if(empty($oneProduct) || $oneProduct['remain_num'] < $num){
+            HelperService::returnJson(['code'=>'400','msg'=>"product($product_id) remain num is less $num"]);
+        }
+
+        return $productModel->upInfo([
+            'product_id'=>$product_id,
+            'remain_num'=>$oneProduct['remain_num']
+        ],['remain_num'=>$oneProduct['remain_num'] - $num]);
+    }
+
+}

+ 119 - 0
application/index/service/SmsService.php

@@ -0,0 +1,119 @@
+<?php
+namespace app\index\service;
+
+use think\Config;
+
+class SmsService extends BaseService
+{
+
+    const code_url = 'https://api.sms.jpush.cn/v1';
+
+    private $appKey = '7ec8cf35b83d1f5fa23b9e4e';
+    private $masterSecret = '237e321c3b7067e2a634470c';
+    private $options;
+
+    public function __construct(array $options = array()) {
+        $this->options = array_merge(array(
+            'ssl_verify'=> false
+        ), $options);
+
+        $this->appKey = Config::get('SmsConfig')['user'];
+        $this->masterSecret = Config::get('SmsConfig')['password'];
+    }
+
+    public function sendCode($mobile, $temp_id = 1) {
+        $url = self::code_url . '/codes';
+        $body = array('mobile' => $mobile, 'temp_id' => $temp_id);
+        $res = $this->sendPost($url, $body);
+        if(!empty($res['http_code']) && $res['http_code'] == 200){
+            $body = json_decode($res['body'], true);
+            if(isset($body['error'])){
+                HelperService::returnJson(['code'=>400,'msg'=>'send fail','data'=>null]);
+            }
+            //1.添加一个短信记录  $mobile手机号  $body['msg_id']返回得内容  $temp_id传得数据
+            $res['msg_id']=$body['msg_id'];
+            $res['status']=true;
+            return $res;
+        }
+        $res['status'] =false;
+        return $res;
+    }
+	
+	public function sendBatchCode($recipients, $temp_id = 1) {
+        $url = self::code_url . '/messages/batch';
+        $body = array('recipients' => $recipients, 'temp_id' => $temp_id);
+        $res = $this->sendPost($url, $body);
+		file_put_contents('sendmobile.jg',json_encode($res)."\n",FILE_APPEND);
+        return $res;
+    }
+	
+
+    public function sendMessage($mobile, $temp_id = 1,$temp_para=[]) {
+        $url = self::code_url . '/messages';
+        $body = array('mobile' => $mobile, 'temp_id' => $temp_id,'temp_para'=>$temp_para);
+        $res = $this->sendPost($url, $body);
+        if(!empty($res['http_code']) && $res['http_code'] == 200){
+            $body = json_decode($res['body'], true);
+            if(isset($body['error'])){
+                HelperService::returnJson(['code'=>400,'msg'=>'send fail','data'=>null]);
+            }
+            //添加一个短信记录
+            return $res;
+
+        }
+        HelperService::returnJson(['code'=>400,'msg'=>'send fail','data'=>$res]);
+    }
+
+    public function checkCode($code,$msg_id) {
+        if(empty($msg_id)){
+            return false;
+        }
+        $url = self::code_url . '/codes/' . $msg_id . "/valid";
+        $body = array('code' => $code);
+        $res = $this->sendPost($url, $body);
+        $arrRes = json_decode($res['body'], true);
+        return $arrRes['is_valid'];
+    }
+
+    private function sendPost($url, $body) {
+        $ch = curl_init();
+        $options = array(
+            CURLOPT_RETURNTRANSFER => true,
+            CURLOPT_HEADER => true,
+            CURLOPT_HTTPHEADER => array(
+                'Content-Type: application/json',
+                'Connection: Keep-Alive'
+            ),
+            CURLOPT_USERAGENT => 'JSMS-API-PHP-CLIENT',
+            CURLOPT_CONNECTTIMEOUT => 20,
+            CURLOPT_TIMEOUT => 120,
+
+            CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
+            CURLOPT_USERPWD => $this->appKey . ":" . $this->masterSecret,
+
+            CURLOPT_URL => $url,
+            CURLOPT_POST => true,
+            CURLOPT_POSTFIELDS => json_encode($body)
+        );
+        if (!$this->options['ssl_verify']) {
+            $options[CURLOPT_SSL_VERIFYPEER] = false;
+            $options[CURLOPT_SSL_VERIFYHOST] = 0;
+        }
+        curl_setopt_array($ch, $options);
+        $output = curl_exec($ch);
+
+        if($output === false) {
+            return "Error Code:" . curl_errno($ch) . ", Error Message:".curl_error($ch);
+        } else {
+            $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+            $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
+            $header_text = substr($output, 0, $header_size);
+            $body = substr($output, $header_size);
+
+            $response['body'] = $body;
+            $response['http_code'] = $httpCode;
+        }
+        curl_close($ch);
+        return $response;
+    }
+}

+ 51 - 0
application/index/service/TokenService.php

@@ -0,0 +1,51 @@
+<?php
+namespace app\index\service;
+use app\index\model\TokenModel;
+use think\Config;
+class TokenService extends BaseService
+{
+    public function checkToken($data)
+    {
+        $TokenModel = new TokenModel();
+        $info = $TokenModel->getInfo($data['token'],$data['companyCode']);
+        if(empty($info)){
+            $TokenModel->where(['token'=>$data['token']])->update(['status'=>2]);
+            return $this->return_code[40044];
+        }else{
+            if(!empty($info['db_json'])) {
+                $db_arr = json_decode($info['db_json'], true);
+                foreach ($db_arr as $k => $v) {
+                    $data = [
+                        'type' => 'mysql',
+                        'hostname' => '127.0.0.1',
+                        'database' => 'test',
+                        'username' => 'root',
+                        'password' => '',
+                        'hostport' => '3306',
+                        'params' => [],
+                        'charset' => 'utf8',
+                        'prefix' => '',
+                        //'debug'       => true,
+                    ];
+                    $data['type'] = $v['type'];
+                    $data['hostname'] = $v['hostname'];
+                    $data['database'] = $v['database'];
+                    $data['username'] = $v['username'];
+                    $data['password'] = $v['password'];
+                    Config::set($v['config_name'], $data);
+                }
+            }
+
+            if(!empty($info['sms_json'])){
+                Config::set('SmsConfig',json_decode($info['sms_json'],true));
+            }
+            return true;
+        }
+
+    }
+
+    protected function checkSign(){
+
+    }
+
+}

+ 13 - 0
application/index/service/alipay/AliPayConfig.php

@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * 	配置账号信息
+ */
+namespace app\index\service\alipay;
+
+class AliPayConfig{
+
+
+}
+
+

+ 34 - 0
application/index/view/alipay/pay.html

@@ -0,0 +1,34 @@
+<!doctype html>
+<html>
+    <head>
+        <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
+        <meta http-equiv="Expires" CONTENT="0">
+        <meta http-equiv="Cache-Control" CONTENT="no-cache">
+        <meta http-equiv="Pragma" CONTENT="no-cache">
+        <title>支付宝支付</title>
+        <!--script type="text/javascript" charset="UTF-8" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script-->
+    </head>
+    <style>
+        body iframe{
+            display: none;
+            opacity: 0;
+        }
+    </style>
+    <body style="width:100%;height:100%;text-align: center;">
+    <script type="text/javascript">
+
+        window.alert = function(name){
+            var iframe = document.createElement("IFRAME");
+            iframe.style.display="none";
+            iframe.setAttribute("src", 'data:text/plain,');
+            document.documentElement.appendChild(iframe);
+            window.frames[0].window.alert(name);
+            iframe.parentNode.removeChild(iframe);
+        }
+    </script>
+    <div>
+        {$submitForm}
+    </div>
+    </body>
+</html>
+

+ 15 - 0
application/index/view/common/error.html

@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html style="height: 100%;">
+<head lang="en">
+    <meta charset="UTF-8">
+    <title>{$err_msg}</title>
+</head>
+<body style="height: 100%;overflow: hidden;background:#fff;">
+   <div style="background: url('/static/error.png') no-repeat;height: 30%;width:40%;background-size: contain;padding: 70% 30% 0 30%;">
+       <font style="font-size:3em;">{$err_msg}</font>
+       <p style="font-size: 2em;">
+           {$err_detail}
+       </p>
+   </div>
+</body>
+</html>

+ 7 - 0
application/index/view/wechat/oauth2.php

@@ -0,0 +1,7 @@
+<?php
+if (isset($_GET['code'])){
+    echo $_GET['code'];
+}else{
+    echo "NO CODE";
+}
+?>

+ 85 - 0
application/index/view/wechat/wxPay.php

@@ -0,0 +1,85 @@
+<!doctype html>
+<html>
+    <head>
+        <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
+        <meta http-equiv="Expires" CONTENT="0">
+        <meta http-equiv="Cache-Control" CONTENT="no-cache">
+        <meta http-equiv="Pragma" CONTENT="no-cache">
+        <title>微信支付</title>
+    </head>
+    <style>
+        body iframe{
+            display: none;
+            opacity: 0;
+        }
+    </style>
+    <body style="width:100%;height:100%;text-align: center;">
+
+    <div style="color:#FFF;margin-top:40px;">
+    </div>
+    <script type="text/javascript">
+
+        window.alert = function(name){
+            var iframe = document.createElement("IFRAME");
+            iframe.style.display="none";
+            iframe.setAttribute("src", 'data:text/plain,');
+            document.documentElement.appendChild(iframe);
+            window.frames[0].window.alert(name);
+            iframe.parentNode.removeChild(iframe);
+        };
+
+        //调用微信JS api 支付
+        function jsApiCall()
+        {
+            WeixinJSBridge.invoke(
+                'getBrandWCPayRequest',<?php echo $jsApiParameters; ?>,
+                function(res){
+                    if (res.err_msg == 'get_brand_wcpay_request:ok') {//支付成功
+                        goNotice();
+                    } else if (res.err_msg == 'get_brand_wcpay_request:cancel') {//支付过程中用户取消
+                        alert('取消支付/(ㄒoㄒ)/~~');
+                        goNotice();
+                    } else if (res.err_msg == 'get_brand_wcpay_request:fail') {//支付失败
+                        alert('支付失败/(ㄒoㄒ)/~~');
+                        goNotice();
+                    }
+                }
+            );
+        }
+
+
+        function goNotice(){
+            window.location.href = '<?php echo $notify_url; ?>';
+            return true;
+        }
+
+        function callpay()
+        {
+            if (typeof WeixinJSBridge == "undefined"){
+                if( document.addEventListener ){
+                    document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
+                }else if (document.attachEvent){
+                    document.attachEvent('WeixinJSBridgeReady', jsApiCall);
+                    document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
+                }
+            }else{
+                jsApiCall();
+            }
+        }
+
+
+
+        function writeObj(obj){
+            var description = "";
+            for(var i in obj){
+                var property=obj[i];
+                description+=i+" = "+property+"\n";
+            }
+            alert(description);
+        }
+        callpay();
+    </script>
+    </body>
+</html>
+<?php exit;?>
+

+ 98 - 0
application/index/view/wechat/wxPlatformPay.php

@@ -0,0 +1,98 @@
+<!doctype html>
+<html>
+    <head>
+        <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
+        <meta http-equiv="Expires" CONTENT="0">
+        <meta http-equiv="Cache-Control" CONTENT="no-cache">
+        <meta http-equiv="Pragma" CONTENT="no-cache">
+        <title>微信支付</title>
+    </head>
+    <style>
+        body iframe{
+            display: none;
+            opacity: 0;
+        }
+    </style>
+    <body style="width:100%;height:100%;text-align: center;">
+
+    <div style="color:#FFF;margin-top:40px;">
+    </div>
+    <script type="text/javascript">
+        
+        //删除所有非法url
+        
+        window.alert = function(name){
+            var iframe = document.createElement("IFRAME");
+            iframe.style.display="none";
+            iframe.setAttribute("src", 'data:text/plain,');
+            document.documentElement.appendChild(iframe);
+            window.frames[0].window.alert(name);
+            iframe.parentNode.removeChild(iframe);
+        };
+
+
+        var is_pay = false;
+
+        //调用微信JS api 支付
+        function jsApiCall()
+        {
+            WeixinJSBridge.invoke(
+                'getBrandWCPayRequest',<?php echo $jsApiParameters; ?>,
+                function(res){
+                    if (res.err_msg == 'get_brand_wcpay_request:ok') {//支付成功
+                        goNotice('success');
+                    } else if (res.err_msg == 'get_brand_wcpay_request:cancel') {//支付过程中用户取消
+                        alert('取消支付/(ㄒoㄒ)/~~');
+                        goNotice('cancel');
+                    } else if (res.err_msg == 'get_brand_wcpay_request:fail') {//支付失败
+                        alert('支付失败/(ㄒoㄒ)/~~');
+                        goNotice('fail');
+                    }else{
+                        alert('支付失败/(ㄒoㄒ)/~~');
+                        goNotice('fail');
+                    }
+                }
+            );
+        }
+
+
+        function goNotice(status){
+            var notifyUrl =  '<?php echo $notify_url; ?>';
+            if(notifyUrl.indexOf('?')==-1){
+                //不存在的话
+                notifyUrl += ('?_wxPay_='+status+"&_time_="+Math.random());
+            }else{
+                notifyUrl += ('&_wxPay_='+status+"&_time_="+Math.random());
+            }
+            window.location.href = notifyUrl;
+            return false;
+        }
+
+        function callpay()
+        {
+            if (typeof WeixinJSBridge == "undefined"){
+                if( document.addEventListener ){
+                    document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
+                }else if (document.attachEvent){
+                    document.attachEvent('WeixinJSBridgeReady', jsApiCall);
+                    document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
+                }
+            }else{
+                jsApiCall();
+            }
+        }
+
+        function writeObj(obj){
+            var description = "";
+            for(var i in obj){
+                var property=obj[i];
+                description+=i+" = "+property+"\n";
+            }
+            alert(description);
+        }
+        callpay();
+    </script>
+    </body>
+</html>
+<?php exit;?>
+