Browse Source

fix: 签到、二维码购买功能

wh 10 months ago
parent
commit
21a6b9876c

+ 20 - 3
app/common/dao/user/SignDao.php

@@ -16,6 +16,8 @@ namespace app\common\dao\user;
 
 use app\common\dao\BaseDao;
 use app\common\model\user\Sign;
+use think\db\BaseQuery;
+use app\common\repositories\user\UserSignRepository;
 
 class SignDao extends BaseDao
 {
@@ -36,11 +38,26 @@ class SignDao extends BaseDao
             ->when(isset($where['type']) && $where['type'] !== '', function ($query) use ($where) {
                 if(!isset($where['admin']) &&  in_array($where['type'],[1,2]))
                 {
-                    $query->whereBetween('parse_date', [date('Y-m-d H:i:s', strtotime('today')), date('Y-m-d H:i:s', strtotime('tomorrow -1second'))])
-                          ->whereOr('parse_date','0000-00-00 00:00:00');
+                    $cate = '早安';
+                    $signObj = app()->make(UserSignRepository::class)->checkDayOrNight();
+                    if($signObj=='night')
+                    {
+                        $cate = '晚安';
+                    }
+                    $query->whereBetween('parse_date', [date('Y-m-d', strtotime('today')), date('Y-m-d H:i:s', strtotime('tomorrow -1second'))])
+                          ->whereOr(function (BaseQuery $query) use ($where,$cate) {
+                            $query->where('parse_date','0000-00-00 00:00:00')
+                                  ->where('type', $where['type'])
+                                  ->where('cate', $cate);
+                        });
+                    $query->where('cate', $cate);
                 }
+    
                 $query->where('type', $where['type']);
             })
+            ->when(isset($where['cate']) && $where['cate'] !== '', function ($query) use ($where) {
+                $query->where('cate', $where['cate']);
+            })
             ->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
                 $query->where('status', $where['status']);
             })
@@ -50,6 +67,6 @@ class SignDao extends BaseDao
             ->when(isset($where['end_time']) && $where['end_time'] !== '', function ($query) use ($where) {
                 $query->where('parse_date','<=', $where['end_time']);
             })
-            ->order('parse_date DESC');
+            ;
     }
 }

+ 2 - 2
app/common/repositories/community/CommunityRepository.php

@@ -910,13 +910,13 @@ class CommunityRepository extends BaseRepository
     }
 
     //用户播放
-    public function setCommunityHit(int $id, $userInfo, int $status)
+    public function setCommunityHit(int $id, $userInfo, int $status,int $history=0)
     {
         $make = app()->make(RelevanceRepository::class);
         if ($status) {
             $this->dao->incField($id,'count_hit',1);
             //创建收藏的用户id和收藏对象的id关系
-            $res = $make->create($userInfo->uid, $id, RelevanceRepository::TYPE_COMMUNITY_HIT,true);
+            $res = $make->create($userInfo->uid, $id, RelevanceRepository::TYPE_COMMUNITY_HIT,true,$history);
             if (!$res) return false;
         }
         return true;

+ 1 - 0
app/common/repositories/store/order/StoreOrderRepository.php

@@ -81,6 +81,7 @@ class StoreOrderRepository extends BaseRepository
     const TYPE_SN_USER_RECHARGE = 'DGU';//wxu
 
     const TYPE_SN_REFUND = 'RDG';//rwx
+    const TYPE_SN_SIGN = 'SIG';//rwx
     /**
      * StoreOrderRepository constructor.
      * @param StoreOrderDao $dao

+ 10 - 0
app/common/repositories/store/service/StoreServiceRepository.php

@@ -355,6 +355,16 @@ class StoreServiceRepository extends BaseRepository
 
         return $service && $service->service_id?1:0;
 
+    }
+    /**
+     * 获取用户对应商户id
+     */
+    public function findUserMerId($uid)
+    {
+        $service = $this->dao->getService($uid);
+
+        return $service->mer_id??0;
+
     }
     /**
      * 解除用户和商户间得绑定关系

+ 30 - 3
app/common/repositories/system/RelevanceRepository.php

@@ -48,7 +48,9 @@ class RelevanceRepository extends BaseRepository
     const TYPE_COMMUNITY_REPLY_START  =  'community_reply_start';
     //商户权限
     const TYPE_MERCHANT_AUTH = 'mer_auth';
-
+    
+    //商家拉黑
+    const TYPE_MERCHANT_FORBID  =  'merchant_forbid';
     //指定范围类型
     //0全部商品
     const TYPE_ALL = 'scope_type';
@@ -85,9 +87,15 @@ class RelevanceRepository extends BaseRepository
      * @author Qinii
      * @day 10/28/21
      */
-    public function create(int $leftId, int $rightId, string $type, bool $check = false)
+    public function create(int $leftId, int $rightId, string $type, bool $check = false,$history=0)
     {
         if ($check && $this->checkHas($leftId, $rightId, $type))  {
+            //更新
+            $this->dao->getSearch([
+                'left_id' => $leftId,
+                'right_id'=> $rightId,
+                'type'    => $type,
+            ])->update(['record_time'=>date('Y-m-d H:i:s') ]);
             return false;
         }
 
@@ -96,7 +104,10 @@ class RelevanceRepository extends BaseRepository
             'right_id'=> $rightId,
             'type'    => $type,
         ];
-
+        if(!$history)
+        {
+            $data['record_time'] = date('Y-m-d H:i:s');
+        }
         try{
             $this->dao->create($data);
             return true;
@@ -201,6 +212,21 @@ class RelevanceRepository extends BaseRepository
         return compact('count','list');
     }
 
+    public function getMerforbid(int $uid, int $page, int $limit)
+    {
+        $query = $this->dao->getSearch([
+            'left_id' => $uid,
+            'type'    => self::TYPE_MERCHANT_FORBID,
+        ])->with([
+            'merchant' => function($query) {
+                $query->field('mer_id,mer_name,mer_avatar');
+            }
+        ]);
+        $count = $query->count();
+        $list = $query->page($page, $limit)->select();
+        return compact('count','list');
+    }
+
 
     /**
      * TODO 我点赞过的文章
@@ -378,6 +404,7 @@ class RelevanceRepository extends BaseRepository
                     }]);
             },
         ]);
+        $query->order('record_time DESC');
         $count = $query->count();
         $list = $query->page($page, $limit)->select()->each(function ($item){
             $item['time'] = date('m月d日', strtotime($item['create_time']));

+ 16 - 0
app/common/repositories/system/merchant/MerchantRepository.php

@@ -861,4 +861,20 @@ class MerchantRepository extends BaseRepository
         $merechant->save();
     }
 
+    //用户拉黑
+    public function setForbid(int $id, $userInfo, int $status)
+    {
+        $make = app()->make(RelevanceRepository::class);
+        if ($status) {
+            //创建收藏的用户id和收藏对象的id关系
+            $res = $make->create($userInfo->uid, $id, RelevanceRepository::TYPE_MERCHANT_FORBID,true);
+            if (!$res) throw new ValidateException('您已经拉黑过了');
+
+        }
+        if (!$status) {
+            if (!$make->checkHas($userInfo->uid, $id, RelevanceRepository::TYPE_MERCHANT_FORBID))
+                throw new ValidateException('您还没有拉黑呢~');
+            $make->destory($userInfo->uid, $id, RelevanceRepository::TYPE_MERCHANT_FORBID);
+        }
+    }
 }

+ 8 - 0
app/common/repositories/user/SignRepository.php

@@ -45,6 +45,14 @@ class SignRepository extends BaseRepository
     public function getList(array $where, $page, $limit)
     {
         $query = $this->dao->search($where);
+        if(isset($where['admin']))
+        {
+            $query->order('id DESC');
+        }
+        else
+        {
+            $query->order('parse_date DESC');
+        }
         $count = $query->count();
         $list = $query->page($page, $limit)->select();
 

+ 34 - 46
app/common/repositories/user/UserSignRepository.php

@@ -157,8 +157,6 @@ class UserSignRepository extends BaseRepository
 
     public function info(int $uid)
     {
-
-
         $ret = $this->signStatus($uid);
         $is_sign  = $ret['is_sign'];
         $sign_num = $ret['sign_num'];
@@ -167,7 +165,8 @@ class UserSignRepository extends BaseRepository
         $alert    = $this->showSingAlert();
         $userInfo = app()->make(UserRepository::class)->getWhere(['uid' => $uid],'uid,avatar,nickname,integral');
         $count = $this->dao->getSearch(['uid' => $uid])->count('*');
-        return compact('userInfo','is_sign','sign_num','count','title','create_time','alert');
+        $dayNight = $this->checkDayOrNight();
+        return compact('userInfo','is_sign','sign_num','count','title','create_time','alert','dayNight');
 
     }
 
@@ -253,14 +252,14 @@ class UserSignRepository extends BaseRepository
 
     public function nightDay($hour='',$minute='')
     {
-        $currentHour   = $hour ? $hour: (int) date('H');
+        $currentHour   = ($hour || $hour===0) ? $hour: (int) date('H');
         $currentMinute = $minute ? $minute: (int) date('i');
         $alertOne = '';
         $startMinute = 9;
         $percent = '95';
-        $currentHour  = $currentMinute==0?24:$currentMinute;
+        $currentHour  = $currentHour==0?23:$currentHour;
         switch ($currentHour) {
-            case ($currentHour>=4 && $currentHour<18):
+            case ($currentHour>=4 && $currentHour<6):
                 $endHour   = 4;
                 $nowJg = floor($currentMinute/9) ;
                 $percent -= abs($endHour-$currentHour)*6 +$nowJg;
@@ -268,32 +267,34 @@ class UserSignRepository extends BaseRepository
                 $alertOne = '比'.$percent.'%的人起的早';
      
                 break;
-            // case ($currentHour>=10 && $currentHour<18):
-            //     $endHour   = 10;
-            //     $percent   = 23800000;
-            //     $nowJg = floor($currentMinute/9) ;
-                
-            //     $percent -= $percent*((abs($endHour-$currentHour)*6 + $nowJg)/100);
-            //     $percent = abs(round($percent/10000));
+            case ($currentHour>=6 && $currentHour<18):
+                $endHour   = 10;
+                $percent   = 36820000;
+                $nowJg = floor($currentMinute/9) ;
                 
-            //     $alertOne = '比'.$percent.'万的人起的早';
+                $percent -= $percent*((abs($endHour-$currentHour)*6 + $nowJg)/100);
+                $percent = abs(round($percent/10000));
+                if($percent<=1326) {
+                    $percent = 1326;
+                }
+                $alertOne = '比'.$percent.'万的人起的早';
                 
-            //     break;
-            // case ($currentHour>=18 && $currentHour<23):
-            //     $endHour   = 18;
-            //     $nowJg = floor($currentMinute/9) ;
-            //     $percent -= abs($endHour-$currentHour)*6 + $nowJg;
-            //     $alertOne = '比'.$percent.'%的人睡得早';
+                break;
+            case ($currentHour>=18 && $currentHour<23):
+                $endHour   = 18;
+                $nowJg = floor($currentMinute/9) ;
+                $percent -= abs($endHour-$currentHour)*6 + $nowJg;
+                $alertOne = '比'.$percent.'%的人睡的早';
            
-            //     break;
-            case ($currentHour>=18 || $currentHour<4):
+                break;
+            case ($currentHour>=23 || $currentHour<4):
                 $endHour   = $currentHour>=23 ?23:0;
                 $percent   = 16330000;
                 $nowJg = floor($currentMinute/9) ;
                 $percent -= $percent*((abs($endHour-$currentHour)*6 + $nowJg)/100);
                 $percent = abs(round($percent/10000));
                 
-                $alertOne = '比'.$percent.'万的人睡得早';
+                $alertOne = '比'.$percent.'万的人睡的晚';
             
             default:
                 # code...
@@ -308,7 +309,7 @@ class UserSignRepository extends BaseRepository
         $day_night_range = $config['day_night_range'];
         $dayNight    = explode('-', $day_night_range);
         $currentHour = $hour ? $hour: (int) date('H');
-        $day_night_flag = ( $currentHour < ($dayNight[0]??7) || $currentHour > ($dayNight[1]??18) )? 'night' : 'day';
+        $day_night_flag = ( $currentHour >= ($dayNight[0]??4) && $currentHour < ($dayNight[1]??18) )? 'day' : 'night';
         return $day_night_flag;
     }
 
@@ -317,29 +318,16 @@ class UserSignRepository extends BaseRepository
     {
         $currentHour = $hour ? $hour: (int) date('H');
         $alertOne = $alertwo = '';
-        switch ($currentHour) {
-            case $currentHour>=4 && $currentHour<18:
-                $alertOne = '连续早起';
-                $alertwo  = '今日早起';
-                break;
-            // case $currentHour>=10 && $currentHour<18:
-            //     $alertOne = '连续晚起';
-            //     $alertwo  = '今日晚起';
-            //     break;
-            // case $currentHour>=18 && $currentHour<23:
-            //     $alertOne = '连续早睡';
-            //     $alertwo  = '今日早睡';
-            //     break;
-            case $currentHour>=18 || $currentHour<4:
-                $alertOne = '连续晚安';
-                $alertwo  = '今日晚安';
-                break;
-            
-            default:
-                # code...
-                break;
+        if($currentHour>=4 && $currentHour<18)
+        {
+            $alertOne = '连续早起';
+            $alertwo  = '今日早起';
+        }
+        else
+        {
+            $alertOne = '连续晚安';
+            $alertwo  = '今日晚安';
         }
-
         return compact('alertOne', 'alertwo');
     }
 

+ 10 - 4
app/controller/admin/system/common/Sign.php

@@ -34,7 +34,7 @@ class Sign extends BaseController
 
     public function getList()
     {
-        $where = $this->request->params(['type','start_time','end_time']);
+        $where = $this->request->params(['type','start_time','end_time','cate']);
         $where['admin'] = 1;
         [$page, $limit] = $this->getPage();
         return app('json')->success($this->repository->getList($where, $page, $limit));
@@ -42,7 +42,7 @@ class Sign extends BaseController
 
     public function update($id)
     {
-        $data = $this->request->params(['type','sort','name','status','content','parse_date']);
+        $data = $this->request->params(['type','sort','name','status','content','parse_date','cate']);
         if (!$this->repository->exists($id))
             return app('json')->fail('数据不存在');
         $this->repository->update($id,$data);
@@ -63,11 +63,16 @@ class Sign extends BaseController
      */
     public function create()
     {
-        $data = $this->request->params(['type','sort','name','status','content','parse_date']);
+        $data = $this->request->params(['type','sort','name','status','content','parse_date','cate']);
 
         // if ($this->repository->fieldExists('name', $data['name']) )
             // throw new ValidateException('已经添加过了!');
-        $obj = $this->repository->create($data);
+        try {
+            $obj = $this->repository->create($data);
+            //code...
+        } catch (\Throwable $th) {
+            echo $th->getMessage();
+        }
         return app('json')->success('添加成功'); //, $obj->toArray()
     }
 
@@ -79,6 +84,7 @@ class Sign extends BaseController
         $this->repository->delete($id);
         return app('json')->success('删除成功');
     }
+    
     /**
      * TODO 详情
      * @param $id

+ 2 - 2
app/controller/api/Common.php

@@ -108,12 +108,12 @@ class Common extends BaseController
         $version  = $this->request->param('version','1.4.21');
         // $platform = $this->request->param('platform','');//ios
         // Log::info($platform.'设备机型版本号:'.$version );
-        $config = systemConfig(['day_night_range','app_home_video','app_applyin_video','android_position_open_status','appiOSVersion','agent_open_status','sys_reply_status','one_login_open_status','open_android_wxlogin','open_ios_wxlogin','open_update_info', 'store_street_theme', 'is_open_service', 'is_phone_login', 'global_theme', 'integral_status', 'mer_location', 'alipay_open', 'hide_mer_status', 'mer_intention_open', 'share_info', 'share_title', 'share_pic', 'store_user_min_recharge', 'recharge_switch', 'balance_func_status', 'yue_pay_status', 'site_logo', 'routine_logo', 'site_name', 'login_logo', 'procudt_increase_status', 'sys_extension_type', 'member_status', 'copy_command_status', 'community_status','community_reply_status','community_app_switch', 'withdraw_type', 'recommend_switch', 'member_interests_status', 'beian_sn', 'community_reply_auth','hot_ranking_switch','svip_switch_status','margin_ico','margin_ico_switch']);
+        $config = systemConfig(['mer_forbid_status','day_night_range','app_home_video','app_applyin_video','android_position_open_status','appiOSVersion','agent_open_status','sys_reply_status','one_login_open_status','open_android_wxlogin','open_ios_wxlogin','open_update_info', 'store_street_theme', 'is_open_service', 'is_phone_login', 'global_theme', 'integral_status', 'mer_location', 'alipay_open', 'hide_mer_status', 'mer_intention_open', 'share_info', 'share_title', 'share_pic', 'store_user_min_recharge', 'recharge_switch', 'balance_func_status', 'yue_pay_status', 'site_logo', 'routine_logo', 'site_name', 'login_logo', 'procudt_increase_status', 'sys_extension_type', 'member_status', 'copy_command_status', 'community_status','community_reply_status','community_app_switch', 'withdraw_type', 'recommend_switch', 'member_interests_status', 'beian_sn', 'community_reply_auth','hot_ranking_switch','svip_switch_status','margin_ico','margin_ico_switch']);
         
         $day_night_range = $config['day_night_range'];
         $dayNight = explode('-', $day_night_range);
         $currentHour = (int) date('H');
-        $config['day_night_flag'] = $currentHour < ($dayNight[0]??7) || $currentHour > ($dayNight[1]??18) ? 'night' : 'day';
+        $config['day_night_flag'] = app()->make(UserSignRepository::class)->checkDayOrNight();
 
         $appiOSVersion = str_replace('.','',$config['appiOSVersion']);
         $version       = str_replace('.','',$version);

+ 2 - 1
app/controller/api/community/Community.php

@@ -583,10 +583,11 @@ class Community extends BaseController
     //播放记录
     public function hitCommunity($id)
     {
+        $history    = $this->request->param('history',0) ;
         $status = 1;//$this->request->param('status') == 1 ? 1 :0;
         if (!$this->repository->exists($id))
             return app('json')->fail('内容不存在');
-        $this->repository->setCommunityHit($id, $this->user, $status);
+        $this->repository->setCommunityHit($id, $this->user, $status,$history);
         return app('json')->success('成功');
     }
 

+ 46 - 0
app/controller/api/store/merchant/Merchant.php

@@ -23,6 +23,7 @@ use app\common\repositories\system\merchant\MerchantMainRepository;
 use app\common\model\system\groupData\SystemGroupData;
 use app\common\repositories\store\StoreCategoryRepository;
 use app\common\repositories\store\service\StoreServiceRepository;
+use app\common\repositories\system\RelevanceRepository;
 
 class Merchant extends BaseController
 {
@@ -263,4 +264,49 @@ class Merchant extends BaseController
   
         return app('json')->success($data);
     }
+
+    /**
+     * TODO 拉黑/取消
+     * @param $id
+     * @param RelevanceRepository $relevanceRepository
+     * @return \think\response\Json
+     * @author Qinii
+     * @day 10/28/21
+     */
+    public function setForbid($id)
+    {
+        $status = $this->request->param('status') == 1 ? 1 :0;
+        if (!$this->repository->exists($id))
+            return app('json')->fail('内容不存在');
+        $this->repository->setForbid($id, $this->userInfo, $status);
+        if ($status) {
+            return app('json')->success('屏蔽成功');
+        } else {
+            return app('json')->success('取消屏蔽');
+        }
+    }
+
+    /**
+     * TODO 我的拉黑
+     * @param RelevanceRepository $relevanceRepository
+     * @return \think\response\Json
+     * @author Qinii
+     * @day 10/28/21
+     */
+    public function getForbid(RelevanceRepository $relevanceRepository)
+    {
+        $uid = $this->request->param('uid',$this->userInfo->uid);
+        [$page, $limit] = $this->getPage();
+        $start = $relevanceRepository->getMerforbid($uid, $page, $limit);
+        return app('json')->success($start);
+    }
+    
+    public function getMerForbid(RelevanceRepository $relevanceRepository)
+    {
+        $uid = $this->userInfo->uid;
+        $mer_id = $this->request->param('mer_id','');
+        $status = $relevanceRepository->checkHas($uid, $mer_id, RelevanceRepository::TYPE_MERCHANT_FORBID);
+        return app('json')->success($status);
+    }
+
 }

+ 103 - 9
app/controller/api/user/Sign.php

@@ -13,8 +13,13 @@ namespace app\controller\api\user;
 
 use crmeb\basic\BaseController;
 use app\common\repositories\user\SignRepository;
+use app\common\repositories\user\SignUserRepository;
 use think\App;
-
+use app\common\repositories\system\groupData\GroupDataRepository;
+use app\common\repositories\user\MerOrderRepository;
+use app\common\repositories\user\UserOrderRepository;
+use app\common\repositories\store\service\StoreServiceRepository;
+use app\common\repositories\system\merchant\MerchantRepository;
 class Sign extends BaseController
 {
     /**
@@ -39,21 +44,110 @@ class Sign extends BaseController
         [$page,$limit] = $this->getPage();
         $where = ['type' => $type];
         $data = $this->repository->getList($where,$page,$limit);
+        // app()->make(SignUserRepository::class)->getList($where,$page,$limit);
+        return app('json')->success($data);
+    }
+
+    public function bankLst()
+    {
+        [$page,$limit] = $this->getPage();
+        $data = app()->make(GroupDataRepository::class)->groupData('sign_qrcode_recharge',0,$page,100);
+        return app('json')->success($data);
+    }
+    
+    public function save()
+    {
+        $uid  = $this->request->uid();
+        $params = $this->request->params(['qrcode_img','mer_id']);
+        $params['uid'] = $uid;
+        $obj = app()->make(SignUserRepository::class);
+        $data = $obj->get($uid);
+        if(!$data )
+        {
+            $data = $obj->create($params);
+        }
+        else
+        {
+            $data->qrcode_img = $params['qrcode_img'];
+            $data->update_time = date('Y-m-d H:i:s');
+            $data->save();
+        }
         return app('json')->success($data);
     }
 
 
+    /**
+     * TODO 购买早晚安
+     * @param $id
+     * @param $merId
+     * @param GroupDataRepository $groupDataRepository
+     * @param ServeOrderRepository $serveOrderRepository
+     * @return \think\response\Json|void
+     * @author Qinii
+     * @day 2022/11/7
+     */
+    public function createOrder($id, GroupDataRepository $groupDataRepository, SignUserRepository $signUserRepository)
+    {
+        $params = $this->request->params(['pay_type']);
+        if (!in_array($params['pay_type'], ['weixin', 'routine', 'h5', 'alipay', 'alipayQr', 'weixinQr','iap'], true))
+            return app('json')->fail('请选择正确的支付方式');
+        $res = $groupDataRepository->getWhere(['group_data_id' => $id, 'status' => 1]);
+        if (!$res) return  app('json')->fail('参数有误~');
+        $params['is_app'] = $this->request->isApp();
+        return $signUserRepository->add($res,$this->request->userInfo(),$params);
+    }
+
+
     public function info()
     {
-        $data = [];
-        $data['sign_day'] = 1;
-        $data['sign_year_month']  = date('Y.m');
-        $data['sign_day']         = date('d');
-        $data['sign_hour_minute'] = date('H:i');
-        
-        $data['sign_word'] = '';
-        $data['sign_bg']   = '';
+        $uid  = $this->request->uid();
+        if($uid)
+        {
+            $obj = app()->make(SignUserRepository::class);
+            $data = $obj->get($uid);
+            $data['merchant_flag'] = true;
+
+            // $userOrder = app()->make(UserOrderRepository::class);
+            $findMer   = app()->make(StoreServiceRepository::class)->findUserMerId($uid);  
+            if($findMer)
+            {
+                $merchant = app()->make(MerchantRepository::class);
+                $merObj   = $merchant->get($findMer);
+                if($merObj->month_card_endtime)
+                {
+                    $data['merchant_flag'] = (strtotime($merObj->month_card_endtime)>time())?false:true;
+                }
+            }     
+            if(!isset($data['uid']) || empty($data['uid'])) 
+            {
+                $data['uid'] = $uid;
+                $data['expire_time'] = '';
+                $data['expire_flag'] = true;
+                $data['buy_flag']    = false;
+                $data['buy_flag']    = false;
+                $data['hour']    = (int) date('H');
+            }
+            else
+            {
+                $data['expire_flag'] = true;
+                if($data['expire_time'])
+                {
+                    $data['expire_flag'] = strtotime($data['expire_time'])>time()?false:true;
+                }
+                $data['buy_flag']    = $data['expire_flag']?false:true;
+            }
+            //商家未过期都可以使用
+            if(!$data['merchant_flag'] )
+            {
+                $data['expire_flag'] = false;
+                $data['buy_flag'] = true;
+            }
+            return app('json')->success($data??[]);
+
+        }
+        return app('json')->fail('请先登录');
 
     }
+
  
 }

+ 25 - 13
app/controller/api/user/UserSign.php

@@ -58,24 +58,36 @@ class UserSign extends BaseController
     public function info()
     {
         $uid  = $this->request->uid();
-        $data = $this->repository->info($uid);
-        if( empty($data['create_time']) ) 
+        if($uid)
         {
-            $signDate = time();
-        }
-        else
-        {
-            $signDate = strtotime($data['create_time']);
-            $hour = (int) date('H');
-            if($hour<=4 || $hour>=18)
+            $data = $this->repository->info($uid);
+            if( empty($data['create_time']) ) 
+            {
+                $signDate = time();
+            }
+            else
             {
+                $hour = intval( date('H') );
                 $signDate = time();
+                if($hour>=4 && $hour<18)
+                {
+                    $signDate = strtotime($data['create_time']);
+                    $newhour = (int)date('H',$signDate) ;
+                    if($newhour < 4)
+                    {
+                        $signDate = time();
+                        $sign = $this->repository->getLastSign($uid);
+                        $sign->create_time = date('Y-m-d H:i:s');
+                        $sign->save();
+                    }
+                }
             }
+            $data['sign_year_month']  = date('Y.m',$signDate);
+            $data['sign_day']         = date('d',$signDate);
+            $data['sign_hour_minute'] = date('H:i',$signDate);
+            return app('json')->success($data);
         }
-        $data['sign_year_month']  = date('Y.m',$signDate);
-        $data['sign_day']         = date('d',$signDate);
-        $data['sign_hour_minute'] = date('H:i',$signDate);
-        return app('json')->success($data);
+        return app('json')->fail('请先登录');
     }
 
     public function month()

+ 12 - 1
crmeb/listens/pay/MerOrderSuccessListen.php

@@ -15,6 +15,7 @@ namespace crmeb\listens\pay;
 
 
 use app\common\repositories\user\MerOrderRepository;
+use app\common\repositories\user\SignUserRepository;
 use app\common\repositories\user\UserRechargeRepository;
 use crmeb\interfaces\ListenerInterface;
 
@@ -23,6 +24,16 @@ class MerOrderSuccessListen implements ListenerInterface
 
     public function handle($data): void
     {
-        app()->make(MerOrderRepository::class)->paySuccess($data);
+        $orderSn = $data['order_sn'];
+        $firstFlag  = substr($orderSn,0,3);
+        if($firstFlag == 'SIG' ) //二维码支付
+        {
+            app()->make(SignUserRepository::class)->paySuccess($data);
+        }
+        else
+        {
+            app()->make(MerOrderRepository::class)->paySuccess($data);
+
+        }
     }
 }

+ 9 - 1
route/api.php

@@ -212,6 +212,11 @@ Route::group('api/', function () {
 
             //签到
             Route::get('sign/new/lst', 'Sign/lst');
+            Route::get('sign/new/info', 'Sign/info');
+            Route::get('sign/new/banklst', 'Sign/bankLst');
+            Route::post('sign/new/save', 'Sign/save');
+            Route::post('sign/new/order/:id', 'Sign/createOrder');
+
             Route::get('sign/lst', 'UserSign/lst');
             Route::get('sign/info', 'UserSign/info');
             Route::post('sign/create', 'UserSign/create');
@@ -659,7 +664,10 @@ Route::group('api/', function () {
             Route::get('/album_cate', 'Merchant/albumCate');
             
             Route::get('/local', 'Merchant/localLst');
-            Route::post('/start/:id', 'Merchant/start'); 
+            Route::post('/start/:id', 'Merchant/start');
+            Route::post('/forbid/:id', 'Merchant/setForbid');
+            Route::get('/forbid/lst', 'Merchant/getForbid');
+            Route::get('/forbid/status', 'Merchant/getMerForbid');
         })->prefix('api.store.merchant.');
         Route::post('store/certificate/:merId', 'api.Auth/getMerCertificate');