Browse Source

Merge branch 'master' of http://git.huxiukeji.com/lizhen/lanjingling

lizhen_gitee 1 year ago
parent
commit
75526ff4d2

+ 5 - 5
addons/epay/config.php

@@ -8,11 +8,11 @@ return [
         'content' => [],
         'value' => [
             'appid' => '',
-            'app_id' => 'wx1bc47f317884cb40',
-            'app_secret' => '9d382a035255f7901b8a0f76ce129f29',
-            'miniapp_id' => 'wx1bc47f317884cb40',
-            'mch_id' => '1625774482',
-            'key' => 'DRs2yi80exLRn6tI4cBhISMfj7SPYMQG',
+            'app_id' => 'wxcdb15751a5a2b878',
+            'app_secret' => '5d69ab5688e4b645a146d0cc0814e6f9',
+            'miniapp_id' => 'wxcdb15751a5a2b878',
+            'mch_id' => '1646457593',
+            'key' => 'wLm7O3lx8kBH13iDBTz22lnbXv2yxZMf',
             'mode' => 'normal',
             'sub_mch_id' => '',
             'sub_appid' => '',

+ 2 - 2
application/admin/view/platform_article/index.html

@@ -18,7 +18,7 @@
                     <div id="toolbar" class="toolbar">
                         <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
                         <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('platform_article/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
-                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('platform_article/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <!--<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('platform_article/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
                         <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('platform_article/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
                         
 
@@ -28,7 +28,7 @@
                                 <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
                                 <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
                             </ul>
-                        </div>
+                        </div>-->
 
                         
                     </div>

+ 2 - 2
application/admin/view/platform_article_type/index.html

@@ -18,7 +18,7 @@
                     <div id="toolbar" class="toolbar">
                         <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
                         <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('platform_article_type/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
-                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('platform_article_type/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <!--<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('platform_article_type/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
                         <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('platform_article_type/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
                         
 
@@ -28,7 +28,7 @@
                                 <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
                                 <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
                             </ul>
-                        </div>
+                        </div>-->
 
                         
                     </div>

+ 2 - 2
application/admin/view/platform_banner/index.html

@@ -18,7 +18,7 @@
                     <div id="toolbar" class="toolbar">
                         <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
                         <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('platform_banner/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
-                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('platform_banner/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <!--<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('platform_banner/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
                         <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('platform_banner/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
                         
 
@@ -28,7 +28,7 @@
                                 <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
                                 <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
                             </ul>
-                        </div>
+                        </div>-->
 
                         
                     </div>

+ 2 - 2
application/admin/view/platform_select/index.html

@@ -18,7 +18,7 @@
                     <div id="toolbar" class="toolbar">
                         <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
                         <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('platform_select/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
-                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('platform_select/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <!--<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('platform_select/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
                         <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('platform_select/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
                         
 
@@ -28,7 +28,7 @@
                                 <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
                                 <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
                             </ul>
-                        </div>
+                        </div>-->
 
                         
                     </div>

+ 26 - 0
application/api/controller/Companys.php

@@ -165,6 +165,32 @@ class Companys extends Api
         }
     }
 
+    public function bindTemp()
+    {
+        try {
+            $id = $this->request->param('id',0);
+            $where['id'] = $id;
+            $where['status'] = 1;
+            $company = $this->model->where($where)->find();
+            if (empty($company)) {
+                throw new Exception('未找到门店信息');
+            }
+            $userId = $this->auth->id;
+            $userWhere['id'] = $userId;
+            $user = Db::name('user')->where($userWhere)->find();
+            if ($user['temp_company_id'] != $id) {//更新绑定门店
+                $userData['temp_company_id'] = $id;
+                $userRes = model('User')->where($userWhere)->update($userData);
+                if (!$userRes) {
+                    throw new Exception('绑定门店失败');
+                }
+            }
+            $this->success();
+        } catch (Exception $e) {
+            $this->error($e->getMessage());
+        }
+    }
+
     /**
      * 保存
      * @return void

+ 0 - 1
application/api/controller/Order.php

@@ -175,7 +175,6 @@ class Order extends Api
             $where['id'] = $id;
             $where['company_id'] = $companyId;
             $where['user_id'] = $userId;
-            $where['status'] = 2;
             $modelData = $this->model->where($where)->find();
             if (empty($modelData)) {
                 throw new Exception('未找到相关信息');

+ 28 - 2
application/api/controller/Pay.php

@@ -321,9 +321,22 @@ class Pay extends Api
             }
             $userCouponsRes = Db::name('user_coupons')->insertAll($userCouponsData);
             if (!$userCouponsRes) {
-                throw new Exception('赠送优惠失败');
+                Db::rollback();
+                return false;
             }
         }
+        //绑定门店
+        $userService = new UserService();
+        $userParams = [
+            'user_id' => $orderInfo['user_id'],
+            'company_id' => $orderInfo['company_id'],
+            'comefrom' => '',//来源
+        ];
+        $userBindRes = $userService->userWallet($userParams);
+        if (!$userBindRes['status']) {
+            Db::rollback();
+            return false;
+        }
         $userWalletWhere['user_id'] = $orderInfo['user_id'];
         $userWalletWhere['company_id'] = $orderInfo['company_id'];
         $userWalletData = Db::name('user_wallet')->where($userWalletWhere)->find();
@@ -347,7 +360,8 @@ class Pay extends Api
         ];
         $userMoneyLogRes = Db::name('user_money_log')->insertGetId($userMoneyLogData);
         if (!$userMoneyLogRes) {
-            throw new Exception('充值记录失败');
+            Db::rollback();
+            return false;
         }
         //更新钱包余额
         $update = [
@@ -465,6 +479,18 @@ class Pay extends Api
             Db::rollback();
             return false;
         }
+        //绑定门店
+        $userService = new UserService();
+        $userParams = [
+            'user_id' => $orderInfo['user_id'],
+            'company_id' => $orderInfo['company_id'],
+            'comefrom' => '',//来源
+        ];
+        $userBindRes = $userService->userWallet($userParams);
+        if (!$userBindRes['status']) {
+            Db::rollback();
+            return false;
+        }
         $orderService = new OrderService();
         $extData = json_decode($orderInfo['ext_data'], true);
         $carId = isset($extData['car_id']) ? $extData['car_id'] : 0;

+ 11 - 0
application/api/controller/PreOrder.php

@@ -103,6 +103,17 @@ class PreOrder extends Api
                 $data['createtime'] = $time;
                 $res = $this->model->insertGetId($data);
                 $id = $res;
+                //绑定门店
+                $userService = new UserService();
+                $userParams = [
+                    'user_id' => $userId,
+                    'company_id' => $companyId,
+                    'comefrom' => '',//来源
+                ];
+                $userBindRes = $userService->userWallet($userParams);
+                if (!$userBindRes['status']) {
+                    throw new Exception($userBindRes['msg']);
+                }
             } else {
                 $data['updatetime'] = $time;
                 $where['id'] = $id;

+ 5 - 0
application/api/controller/User.php

@@ -692,6 +692,11 @@ class User extends Api
     {
         try {
             $userInfo = $this->auth->getUserinfo();
+            $where['id'] = $this->auth->id;
+            $userData = Db::name('user')->where($where)->find();
+            if (!empty($userData)) {
+                $userInfo['company_id'] = $userData['company_id'];
+            }
             $userCouponsWhere['user_id'] = $this->auth->id;
             $userCouponsWhere['endtime'] = ['gt', time()];
             $userCouponsNum = Db::name('user_coupons')->where($userCouponsWhere)->sum('remain');

+ 4 - 1
application/common/library/Auth.php

@@ -26,7 +26,7 @@ class Auth
     //默认配置
     protected $config = [];
     protected $options = [];
-    protected $allowFields = ['id', 'username', 'nickname', 'mobile', 'avatar', 'score','company_id','birthday','createtime'];
+    protected $allowFields = ['id', 'username', 'nickname', 'mobile', 'avatar', 'score','company_id','temp_company_id','birthday','createtime'];
 
     public function __construct($options = [])
     {
@@ -119,6 +119,9 @@ class Auth
                 $this->setError('Account is locked');
                 return false;
             }
+            /*if ($user['company_id'] == 0 && $user['temp_company_id'] != 0) {
+                $user['company_id'] = $user['temp_company_id'];
+            }*/
             $this->_user = $user;
             $this->_logined = true;
             $this->_token = $token;

+ 53 - 0
application/common/model/UserCoupons.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+
+class UserCoupons extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'user_coupons';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'integer';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+        'endtime_text'
+    ];
+
+
+
+    public function getEndtimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['endtime']) ? $data['endtime'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
+
+    protected function setEndtimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
+
+    public function user()
+    {
+        return $this->belongsTo('User', 'user_id', 'id',[],'LEFT')->setEagerlyType(0);
+    }
+
+    public function company()
+    {
+        return $this->belongsTo('Company', 'company_id', 'id',[],'LEFT')->setEagerlyType(0);
+    }
+}

+ 8 - 2
application/common/service/UserService.php

@@ -40,7 +40,7 @@ class UserService
                 if ($user['company_id'] != $companyId) {
                     $userData['company_id'] = $companyId;
                     $userData['updatetime'] = time();
-                    $userRes = Db::name('user')->where($where['id'])->update($userData);
+                    $userRes = Db::name('user')->where($where)->update($userData);
                     if (!$userRes) {
                         throw new Exception('操作失败');
                     }
@@ -64,6 +64,7 @@ class UserService
             'msg' => '操作成功',
             'data' => [],
         ];
+        Db::startTrans();
         try {
             $userId = isset($params['user_id']) ? $params['user_id'] : 0;
             $companyId = isset($params['company_id']) ? $params['company_id'] : 0;
@@ -74,22 +75,27 @@ class UserService
             }
             $where['user_id'] = $userId;
             $where['company_id'] = $companyId;
-            $userWallet = Db::name('user_wallet')->where($where['id'])->find();
+            $userWallet = Db::name('user_wallet')->where($where)->find();
             $time = time();
             if (empty($userWallet)) {
                 $userWalletData = [
                     'user_id' => $userId,
                     'company_id' => $companyId,
+                    'staff_id' => 0,
                     'money' => 0.00,
+                    'address' => '',
                     'createtime' => $time,
                     'comefrom' => $comefrom,
+                    'remark' => '',
                 ];
                 $userWalletRes = Db::name('user_wallet')->insertGetId($userWalletData);
                 if (!$userWalletRes) {
                     throw new Exception('生成钱包失败');
                 }
             }
+            Db::commit();
         } catch (Exception $e) {
+            Db::rollback();
             $result['status'] = 0;
             $result['msg'] = $e->getMessage();
         }

+ 2 - 2
application/config.php

@@ -310,8 +310,8 @@ return [
         'appid'=>'wxcdb15751a5a2b878',
         //'secret'=>'9d382a035255f7901b8a0f76ce129f29',
         'secret'=>'5d69ab5688e4b645a146d0cc0814e6f9',
-        'mch_id' => '1625774482',//商户号
-        'key'    => 'DRs2yi80exLRn6tI4cBhISMfj7SPYMQG',//api密钥
+        'mch_id' => '1646457593',//商户号
+        'key'    => 'wLm7O3lx8kBH13iDBTz22lnbXv2yxZMf',//api密钥
     ],
 
 

+ 6 - 1
paylog/wechat/notify.txt

@@ -13,4 +13,9 @@
 2023-06-05 17:31:01 [notify][入口接收php://input流原始数据] 
 
 
-2023-06-05 17:31:01 [notify][入口接收php://input流] false
+2023-06-05 17:31:01 [notify][入口接收php://input流] false
+
+2023-06-15 11:00:03 [notify][入口接收php://input流原始数据] 
+
+
+2023-06-15 11:00:03 [notify][入口接收php://input流] false