105, 'msg' => "参数不正确,不能为空!" ]; return $data; } $where = [ "del" => 0, "is_show" => 1, "pid" => 0, //必须是电脑 "code" => $code ]; $item = EquiCategoryModel::where($where)->find(); //判断商家服务 if(!empty($item)) { //判断商户 $shop = shopModel::where('id', $item['shop_id'])->find(); if(empty($shop)){ $data = [ 'status' => 110, 'msg' => "商户信息不存在!" ]; return $data; } //不需要转数组 //echo $shop['id']; //$shop = $shop->toArray(); //var_dump($shop);die; //判断 商家状态 is_freeze if((int)$shop['is_freeze'] === 1){ $data = [ 'status' => 111, 'msg' => "商家冻结中!" ]; return $data; } //判断 营业状态 is_run if((int)$shop['is_run'] === 0){ $data = [ 'status' => 112, 'msg' => "商家暂停营业中!" ]; return $data; } //模型调用出来的 与 直接查询字段出来的值 不一样 $expire_time = strtotime($shop['expire_time']); //dump($expire_time); //echo $expire_time;die; /*** * 原先这是 先判断是否到期 未到期 不扣次数 已到期 判断剩余数量 * if($expire_time < time()){ //判断到期时间 $data = [ 'status' => 107, 'msg' => "商户服务当前套餐到期,到期时间".date('Y-m-d H:i:s',$expire_time)."!" ]; //当商家已到期 if((int)$shop['hksy_count'] < 10){ //判断剩余数量 hksy_count $data = [ 'status' => 113, 'msg' => "商户服务可评论次数不足,剩余".$shop['hksy_count']."条,请充值后再使用 或 开通商户包年包月服务!" ]; return $data; } //可评论次数大于10 即使到期 也继续执行 $is_gi = 1; }else{ $is_gi = 0; } //未到期 不需要扣次数 继续执行即可 * */ //判断类型 if((int)$shop['hksy_type'] === 0){ //包月 if($expire_time < time()){ //判断到期时间 $data = [ 'status' => 107, 'msg' => "商户服务当前套餐到期,到期时间".date('Y-m-d H:i:s',$expire_time)."!" ]; return $data; } //包月 未过期 = 前端会按包月模式 运行 $is_gi = 0; }else{ //按量 if((int)$shop['hksy_count'] < 5){ //判断剩余数量 hksy_count $data = [ 'status' => 113, 'msg' => "商户服务可评论次数不足,剩余".$shop['hksy_count']."条,请充值次数后再使用!" ]; return $data; } //按量 统一按过期处理 = 前端会按按量模式 运行 $is_gi = 1; } } if(empty($item)) { $data = [ 'status' => 101, 'msg' => "秘钥错误,找不到设备!" ]; }else if(empty($item['machine_code'])) { //验证秘钥是否合法 $res = self::getCodeIs($item['shop_id'],$code); if($res === false){ $data = [ 'status' => 106, 'msg' => "超出套餐服务电脑数量!" ]; }else { //未绑定机器码 那么进行绑定 $row = EquiCategoryModel::where(['id' => $item['id']])->update([ "machine_code" => $mcode, ]); if ($row == 1) { $data = [ 'status' => 100, 'msg' => "绑定机器码成功!", 'is_gi' => $is_gi, 'count' => $shop['hksy_count'] ]; } else { $data = [ 'status' => 102, 'msg' => "绑定机器码失败!" ]; } } }else{ //验证秘钥是否合法 $res = self::getCodeIs($item['shop_id'],$code); if($res === false){ $data = [ 'status' => 106, 'msg' => "超出套餐服务电脑数量!" ]; }else { //var_dump($mcode); //var_dump($item['machine_code']); //机器码已存在 if($item['machine_code'] != $mcode){ //机器码不一致 $data = [ 'status' => 103, 'msg' => "该秘钥已绑定其他设备,操作失败!" ]; }else{ $data = [ 'status' => 100, 'msg' => "已绑定该机器码!", 'is_gi' => $is_gi, 'count' => $shop['hksy_count'] ]; } } } return $data; } public static function getCodeIs($shop_id,$code) { //首先获取合法的电脑数量是多少 $tid = shopModel::where('id',$shop_id)->value('tid'); if ((int)$tid === 0) { //未配置 $count_pc = 1; $count_mobile = 3; $count_run = 3; } else if ((int)$tid > 0) { //查找配置 $one = shopGoodsModel::where('id', $tid)->find(); $count_pc = $one['pc_num']; $count_mobile = $one['mobile_num']; $count_run = $one['run_num']; } else { //其他 $count_pc = 1; $count_mobile = 3; $count_run = 3; } //调用合法的秘钥是哪些 $where = [ "del" => 0, //未删除 //"is_show" => 1, "pid" => 0, //必须是电脑 "shop_id" => $shop_id ]; $code_list = EquiCategoryModel::where($where)->order('id asc')->limit($count_pc)->column('code'); //var_dump($code); if(in_array($code,$code_list)){ return true; } return false; } /* * getComputer * 获取电脑 根据code */ public static function getComputer($code){ if(empty($code)){ $data = [ 'status' => 105, 'msg' => "参数不正确,不能为空!" ]; return $data; } $where = [ "del" => 0, "is_show" => 1, "pid" => 0, //必须是电脑 "code" => $code ]; $item = EquiCategoryModel::where($where)->find(); if(empty($item)) { $data = [ 'status' => 101, 'msg' => "秘钥错误,找不到设备!" ]; }else{ $data = [ 'status' => 100, 'msg' => "设备存在!", 'item' => $item ]; } return $data; } /* * 获取手机配置 */ public static function getDefaultMobile($data){ //判断是否绑定配置 if(empty($data['pz'])){ $data = [ 'status' => 101, 'msg' => "请对该设备绑定默认配置!" ]; }else{ $pz = json_decode($data['pz'],true); //获取小红书appid $app_id = ClosureCategory::where([ 'name' => '小红书', 'shop_id' => $data['shop_id'] ])->value('id'); if(empty($app_id)){ $data = [ 'status' => 102, 'msg' => "找不到名为小红书的appID!" ]; }else{ //读取默认配置 foreach ($pz as $k=>$v){ if((int)$v['cid'] === (int)$app_id){ //读取具体配置对象 $v['val'] $item = Closure::where(['id'=>$v['val']])->find(); if(empty($item['json_data'])){ $data = [ 'status' => 103, 'msg' => "找不到配置对象记录!" ]; }else{ $data = [ 'status' => 100, 'msg' => "存在默认配置!", 'data' => json_decode($item['json_data'],true) ]; $data['data']['ver'] = $v['ver']; } } } } } //查询默认配置 return $data; } /* * 获取手机列表 */ public static function getMobile($data) { //限制手机数量 首先获取合法的手机数量是多少 $tid = shopModel::where('id',$data['shop_id'])->value('tid'); if ((int)$tid === 0) { //未配置 $count_pc = 1; $count_mobile = 3; $count_run = 3; } else if ((int)$tid > 0) { //查找配置 $one = shopGoodsModel::where('id', $tid)->find(); $count_pc = $one['pc_num']; $count_mobile = $one['mobile_num']; $count_run = $one['run_num']; } else { //其他 $count_pc = 1; $count_mobile = 3; $count_run = 3; } //只调用允许数量 按id排序即可 后台不可更改排序 $list = EquiCategoryModel::where(['pid'=>$data['id'],'is_show'=>1,'del'=>0,'is_user'=>1]) ->order('id asc') ->limit($count_run) ->select(); if(empty($list)){ $data = [ 'status' => 100, 'msg' => "找不到手机设备,全部使用默认配置!" ]; }else{ //获取小红书appid $app_id = ClosureCategory::where([ 'name' => '小红书', 'shop_id' => $data['shop_id'] ])->value('id'); if(empty($app_id)){ $data = [ 'status' => 102, 'msg' => "找不到名为小红书的appID!" ]; }else{ $pz_list = []; $ids = []; //dump($list->toArray());die; foreach ($list as $k=>$v){ //没有配置指定 就使用默认的配置 if(!empty($v['pz'])){ $pz = json_decode($v['pz'],true); foreach ($pz as $kk=>$vv){ //小红书 if((int)$vv['cid'] === (int)$app_id){ $pz_list[] = $v['name']; $ids[] = $vv['val']; $ver[] = $vv['ver']; //版本号 } } } } if(empty($ids)){ $data = [ 'status' => 100, 'msg' => "不存在手机配置,使用默认配置" ]; }else{ $data = [ 'status' => 100, 'data' => $pz_list, 'ids' => $ids, 'ver' => $ver ]; } } } return $data; } /* * 获取手机配置 */ public static function getMobileConfig($data,$ids,$ver) { $res = []; if(!empty($ids)){ $list = Closure::where('id','in',$ids)->select(); //用配置id 作 key 如果配置id相同 就会覆盖 /* foreach ($list as $k=>$v){ if(!empty($v['json_data'])){ $res[$data[(int)$v['id']]] = json_decode($v['json_data'],true); $res[$data[(int)$v['id']]]['ver'] = $ver[(int)$v['id']]; //追加版本号 } }*/ //重写 $pz_list = []; foreach ($list as $k=>$v){ if(!empty($v['json_data'])) { $pz_list[$v['id']] = $v; } } foreach ($ids as $k=>$v){ if(!empty($pz_list[$v])){ $res[$data[$k]] = json_decode($pz_list[$v]['json_data'],true); $res[$data[$k]]['ver'] = $ver[$k]; //追加版本号 } } } return $res; } /** * 获取店铺信息 */ public static function getShopInfo($shopId, $userId, $params = []) { // 记录统计信息(访问商铺用户量) Event::listen('ShopStat', 'app\common\listener\ShopStat'); event('ShopStat', $shopId); $where = [ 'del' => 0, 'id' => $shopId ]; $field = [ 'id', 'create_time', 'name', 'logo', 'background', 'type', 'score', 'star', 'intro', 'visited_num', 'cover', 'banner', 'is_freeze', 'is_run', 'expire_time', 'province_id', 'city_id', 'district_id', 'address', 'run_start_time', 'run_end_time', 'weekdays', ]; $shop = Shop::field($field) ->where($where) ->append([ 'type_desc', 'is_expire' ]) ->findOrEmpty(); if($shop->isEmpty()) { return []; }else{ $shop = $shop->toArray(); } // $shop['logo'] = UrlServer::getFileUrl($shop['logo'] ? : ShopEnum::DEFAULT_LOGO); $shop['background'] = UrlServer::getFileUrl($shop['background'] ? : ShopEnum::DEFAULT_BG); $shop['cover'] = UrlServer::getFileUrl($shop['cover'] ? :ShopEnum::DEFAULT_COVER); $shop['banner'] = UrlServer::getFileUrl($shop['banner'] ? : ShopEnum::DEFAULT_BANNER); $shop['run_start_time'] = $shop['run_start_time'] ? date('H:i:s', $shop['run_start_time']) : ''; $shop['run_end_time'] = $shop['run_end_time'] ? date('H:i:s', $shop['run_end_time']) : ''; $shop['province'] = DevRegion::getAreaName($shop['province_id']); $shop['city'] = DevRegion::getAreaName($shop['city_id']); $shop['district'] = DevRegion::getAreaName($shop['district_id']); $shop['qr_code'] = (new QrCodeLogic)->shopQrCode($shop['id'], $params['terminal'] ?? ''); // 在售商品 // 销售中商品:未删除/审核通过/已上架 $onSaleWhere = [ ['del', '=', GoodsEnum::DEL_NORMAL], // 未删除 ['status', '=', GoodsEnum::STATUS_SHELVES], // 上架中 ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK], // 审核通过 ]; $shop['on_sale_count'] = Goods::where($onSaleWhere)->where('shop_id', $shopId)->count(); // 店铺推荐商品 $shop['goods_list'] = Goods::field('id,image,name,min_price,market_price') ->where($onSaleWhere) ->where([ 'shop_id' => $shop['id'], 'is_recommend' => 1, // 推荐商品 ]) ->limit(9) ->select() ->toArray(); // 用户是否关注店铺 $shop['shop_follow_status'] = 0; if($userId) { // 用户已登录 $shopFollow = ShopFollow::where(['user_id'=>$userId, 'shop_id'=>$shopId])->findOrEmpty(); if(!$shopFollow->isEmpty()) { $shop['shop_follow_status'] = $shopFollow['status']; } } $shop['follow_num'] = ShopFollow::where(['shop_id' => $shopId,'status' => 1])->count('id'); $image = ConfigServer::get('shop_customer_service', 'image', '', $shopId); $shop['customer_image'] = $image ? UrlServer::getFileUrl($image) : ''; $shop['customer_wechat'] = ConfigServer::get('shop_customer_service', 'wechat', '', $shopId); $shop['customer_phone'] = ConfigServer::get('shop_customer_service', 'phone', '', $shopId); // 店铺广告 $adWhere = [ [ 'shop_id', '=', $shopId ], [ 'status', '=', 1 ], ]; $shop['ad'] = [ 'pc' => ShopAd::where($adWhere)->where('terminal', ShopAdEnum::TERMINAL_PC)->append([ 'link_path', 'link_query' ])->order('sort desc,id desc')->select()->toArray(), 'mobile' => ShopAd::where($adWhere)->where('terminal', ShopAdEnum::TERMINAL_MOBILE)->append([ 'link_path', 'link_query' ])->order('sort desc,id desc')->select()->toArray(), ]; return $shop; } /** * 店铺列表 */ public static function getShopList($get) { $where = [ ['is_freeze', '=', 0], // 未冻结 ['del', '=', 0], // 未删除 ['is_run', '=', 1], // 未暂停营业 ]; // 店铺名称 if(isset($get['name']) && !empty($get['name'])) { $where[] = ['name', 'like', '%'. trim($get['name']. '%')]; } // 主营类目 if(isset($get['shop_cate_id']) && !empty($get['shop_cate_id'])) { $where[] = ['cid', '=', $get['shop_cate_id']]; } $order = [ 'weight' => 'asc', 'score' => 'desc', 'id' => 'desc' ]; $list = Shop::field('id,type,name,logo,background,visited_num,cover,banner') ->where($where) // 无限期 或 未到期 ->whereRaw('expire_time =0 OR expire_time > '. time()) ->order($order) ->page($get['page_no'], $get['page_size']) ->select() ->toArray(); $count = Shop::where($where) // 无限期 或 未到期 ->whereRaw('expire_time =0 OR expire_time > '. time()) ->count(); $onSaleWhere = [ ['del', '=', GoodsEnum::DEL_NORMAL], // 未删除 ['status', '=', GoodsEnum::STATUS_SHELVES], // 上架中 ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK], // 审核通过 ]; foreach($list as &$shop) { $shop['goods_list'] = Goods::field('id,image,name,min_price,market_price') ->where($onSaleWhere) ->where([ 'shop_id' => $shop['id'], ]) ->limit(10) ->select() ->toArray(); $shop['on_sale_goods'] = count($shop['goods_list']); // logo及背景图 $shop['logo'] = $shop['logo'] ? UrlServer::getFileUrl($shop['logo']) : UrlServer::getFileUrl(ShopEnum::DEFAULT_LOGO); $shop['background'] = $shop['background'] ? UrlServer::getFileUrl($shop['background']) : UrlServer::getFileUrl(ShopEnum::DEFAULT_BG); $shop['cover'] = $shop['cover'] ? UrlServer::getFileUrl($shop['cover']) : UrlServer::getFileUrl(ShopEnum::DEFAULT_COVER); $shop['banner'] = $shop['banner'] ? UrlServer::getFileUrl($shop['banner']) : ''; } $more = is_more($count, $get['page_no'], $get['page_size']); $data = [ 'list' => $list, 'count' => $count, 'more' => $more, 'page_no' => $get['page_no'], 'page_isze' => $get['page_size'] ]; return $data; } /** * @notes 附近店铺列表 * @param $get * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author ljj * @date 2022/9/20 4:29 下午 */ public static function getNearbyShops($get) { $where = [ ['is_freeze', '=', 0], // 未冻结 ['del', '=', 0], // 未删除 ['is_run', '=', 1], // 未暂停营业 ['city_id', '=', $get['city_id']], ]; // 店铺名称 if(isset($get['name']) && !empty($get['name'])) { $where[] = ['name', 'like', '%'. trim($get['name']. '%')]; } // 主营类目 if(isset($get['shop_cate_id']) && !empty($get['shop_cate_id'])) { $where[] = ['cid', '=', $get['shop_cate_id']]; } $city = DevRegion::where('id',$get['city_id'])->field('db09_lng,db09_lat')->findOrEmpty()->toArray(); $list = Shop::field('id,name,logo,background,visited_num,cover,banner,st_distance_sphere(point('.$city['db09_lng'].','.$city['db09_lat'].'),point(longitude, latitude)) as distance') ->where($where) // 无限期 或 未到期 ->whereRaw('expire_time =0 OR expire_time > '. time()) ->order('distance asc') ->page($get['page_no'], $get['page_size']) ->select() ->toArray(); $count = Shop::where($where) // 无限期 或 未到期 ->whereRaw('expire_time =0 OR expire_time > '. time()) ->count(); $onSaleWhere = [ ['del', '=', GoodsEnum::DEL_NORMAL], // 未删除 ['status', '=', GoodsEnum::STATUS_SHELVES], // 上架中 ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK], // 审核通过 ]; foreach($list as &$shop) { $shop['goods_list'] = Goods::field('id,image,name,min_price,market_price') ->where($onSaleWhere) ->where([ 'shop_id' => $shop['id'], ]) ->select() ->toArray(); $shop['on_sale_goods'] = count($shop['goods_list']); // logo及背景图 $shop['logo'] = $shop['logo'] ? UrlServer::getFileUrl($shop['logo']) : UrlServer::getFileUrl(ShopEnum::DEFAULT_LOGO); $shop['background'] = $shop['background'] ? UrlServer::getFileUrl($shop['background']) : UrlServer::getFileUrl(ShopEnum::DEFAULT_BG); $shop['cover'] = $shop['cover'] ? UrlServer::getFileUrl($shop['cover']) : UrlServer::getFileUrl(ShopEnum::DEFAULT_COVER); $shop['banner'] = $shop['banner'] ? UrlServer::getFileUrl($shop['banner']) : ''; //转换距离单位 if ($shop['distance'] < 1000) { $shop['distance'] = round($shop['distance']).'m'; }else { $shop['distance'] = round($shop['distance'] / 1000,2).'km'; } } $more = is_more($count, $get['page_no'], $get['page_size']); $data = [ 'list' => $list, 'count' => $count, 'more' => $more, 'page_no' => $get['page_no'], 'page_isze' => $get['page_size'] ]; return $data; } public static function getXhsDefaultAppuim() { $data = [ '默认' => '', "搜索列表" => '//androidx.recyclerview.widget.RecyclerView[@class="androidx.recyclerview.widget.RecyclerView"]/android.widget.FrameLayout[@class="android.widget.FrameLayout"]/android.widget.RelativeLayout[@class="android.widget.RelativeLayout"]/android.widget.TextView[@class="android.widget.TextView" and @text!=""]', "推荐列表" => '//androidx.recyclerview.widget.RecyclerView[@class="androidx.recyclerview.widget.RecyclerView"]/android.widget.LinearLayout[@class="android.widget.LinearLayout" and @content-desc!=""]', '推荐列表元素' => '//android.widget.LinearLayout[@content-desc="变量1"]', '搜索列表元素' => '//android.widget.TextView[@text="变量1"]', "私信发送按钮" => '//android.view.ViewGroup[@class="android.view.ViewGroup"]/android.widget.TextView[contains(@text,"发送")]', '判断当前是否视频' => '//android.view.ViewGroup[@class="android.view.ViewGroup"]/android.widget.Button[@content-desc="分享"]', '视频评论数' => '//android.view.ViewGroup[@class="android.view.ViewGroup"]/android.widget.Button[contains(@content-desc,"评论")]', '视频分享按钮' => '//android.view.ViewGroup[@class="android.view.ViewGroup"]/android.widget.Button[@content-desc="分享"]', '视频获取账号名称' => '//android.widget.Button[contains(@content-desc,"作者") and @class="android.widget.Button"]/android.widget.LinearLayout[@class="android.widget.LinearLayout"]/android.widget.TextView[@class="android.widget.TextView"]', "视频获取点赞按钮" => '//android.view.ViewGroup[@class="android.view.ViewGroup"]/android.widget.Button[contains(@content-desc,"点赞")]', "视频获取收藏按钮" => '//android.view.ViewGroup[@class="android.view.ViewGroup"]/android.widget.Button[contains(@content-desc,"收藏")]', "视频详情返回按钮" => '//android.view.ViewGroup[@class="android.view.ViewGroup"]/android.widget.Button[contains(@content-desc,"返回")]' ]; return $data; } public static function getXhsDefaultU2() { $data = [ '默认' => '' ]; return $data; } public static function getXhsAppuim_1() { //相对位置 /parent::*[1]/ //p推荐页 p搜索页 p搜索列表页_1 p搜索列表页_2 p图文页 p视频页 p旧版视频页 p用户主页 p私信页 $data = [ "默认" => '', //页面唯一标识 start "p推荐页" => '//android.view.ViewGroup[@class="android.view.ViewGroup" and @index="0"]/android.widget.RelativeLayout[@class="android.widget.RelativeLayout" and @index="2" and @content-desc="发布"]', "p搜索页" => '//android.widget.LinearLayout[@class="android.widget.LinearLayout"]/android.widget.ImageView[@class="android.widget.ImageView" and @content-desc="拍照搜索"]', "p搜索列表页_1" => '//android.widget.Button[@class="android.widget.Button"]/android.widget.TextView[@text="筛选"]', "p搜索列表页_2" => '//android.widget.TextView[@class="android.widget.TextView" and @text="全部"]/parent::*[1]/android.widget.ImageView[@class="android.widget.ImageView"]', "p图文页" => '//android.widget.RelativeLayout[@class="android.widget.RelativeLayout"]/android.widget.Button[@content-desc="分享"]', "p视频页" => '//android.view.ViewGroup[@class="android.view.ViewGroup"]//android.widget.ImageView[@class="android.widget.ImageView" and @content-desc="搜索"]', "p旧版视频页" => '//androidx.recyclerview.widget.RecyclerView[@class="androidx.recyclerview.widget.RecyclerView"]//android.view.ViewGroup[@class="android.view.ViewGroup"]//android.widget.ImageView[@class="android.widget.ImageView" and @index="5"]', "p用户主页" => '//android.widget.LinearLayout[@class="android.widget.LinearLayout"]/android.widget.TextView[contains(@text,"小红书号")]', "p私信页" => '//android.widget.FrameLayout[@class="android.widget.FrameLayout"]/android.widget.EditText[@class="android.widget.EditText"]', //页面唯一标识 end //页面多版本 start "搜索列表" => '//androidx.recyclerview.widget.RecyclerView[@class="androidx.recyclerview.widget.RecyclerView"]/android.widget.FrameLayout[@class="android.widget.FrameLayout"]/android.widget.RelativeLayout[@class="android.widget.RelativeLayout"]/android.widget.TextView[@class="android.widget.TextView" and @text!=""]', "推荐列表" => '//androidx.recyclerview.widget.RecyclerView[@class="androidx.recyclerview.widget.RecyclerView"]/android.widget.FrameLayout[@class="android.widget.FrameLayout" and @content-desc!=""]', '推荐列表元素' => '//android.widget.FrameLayout[@content-desc="变量1"]', '搜索列表元素' => '//android.widget.TextView[@text="变量1"]', "私信发送按钮" => '//android.widget.RelativeLayout[@class="android.widget.RelativeLayout"]/android.widget.TextView[contains(@text,"发送")]', '判断当前是否视频' => '//android.widget.FrameLayout[@class="android.widget.FrameLayout" and @index="1"]/android.widget.LinearLayout[@index="0"]/android.widget.LinearLayout[@index="3"]/android.widget.TextView[@class="android.widget.TextView"]', '视频评论数' => '//android.widget.FrameLayout[@class="android.widget.FrameLayout" and @index="1"]/android.widget.LinearLayout[@index="0"]/android.widget.LinearLayout[@index="1"]/android.widget.TextView[@class="android.widget.TextView"]', '视频分享按钮' => '//android.widget.FrameLayout[@class="android.widget.FrameLayout" and @index="1"]/android.widget.LinearLayout[@index="0"]/android.widget.LinearLayout[@index="4"]/android.widget.ImageView[@class="android.widget.ImageView"]', '视频获取账号名称' => '//android.widget.FrameLayout[@class="android.widget.FrameLayout"]/android.view.ViewGroup[@class="android.view.ViewGroup"]/android.widget.LinearLayout[@class="android.widget.LinearLayout"]/android.widget.LinearLayout[@class="android.widget.LinearLayout"]/android.widget.TextView[@class="android.widget.TextView"]', "视频获取点赞按钮" => '//android.widget.FrameLayout[@class="android.widget.FrameLayout" and @index="1"]/android.widget.LinearLayout[@index="0"]/android.widget.LinearLayout[@index="0"]/android.widget.TextView[@class="android.widget.TextView"]', "视频获取收藏按钮" => '//android.widget.FrameLayout[@class="android.widget.FrameLayout" and @index="1"]/android.widget.LinearLayout[@index="0"]/android.widget.LinearLayout[@index="2"]/android.widget.TextView[@class="android.widget.TextView"]', "视频详情返回按钮" => '//android.view.ViewGroup[@class="android.view.ViewGroup"]/android.widget.ImageView[contains(@content-desc,"返回")]' //页面多版本 end ]; return $data; } public static function getXhsU2_1() { $data = [ '默认' => '' ]; return $data; } /** * 加密 ZMH 2025-03-18 * @param $data * @return bool|string */ public static function encrypt($data) { $key = 'ABCDEFGHIJKLMNOP'; //16位 $vi = '0102030405060708'; //16位 if (is_array($data)) { $str = json_encode($data,JSON_UNESCAPED_UNICODE); //讲数组转为字符串 } else if (is_string($data)) { $str = $data; } else { return false; } $sign = openssl_encrypt($str, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $vi); $sign = base64_encode($sign); return $sign; } /** * 获取商家信息 ZMH 2025-03-18 * @param $code * @return model|bool */ public static function getShopByCode($code) { if (empty($code)) { self::$error = "设备编码不能为空"; self::$errCode = 2; return false; } $where = [ "del" => 0, "is_show" => 1, "pid" => 0, //必须是电脑 "code" => $code ]; $item = EquiCategoryModel::where($where)->find(); if (empty($item)) { self::$error = "没有找到对应的设备"; self::$errCode = 3; return false; } $shop = ShopModel::where("id", $item["shop_id"])->find(); if (empty($shop)) { self::$error = "用户信息不存在"; self::$errCode = 4; return false; } return $shop; } /** * 获取剩余数量 ZMH 2025-03-18 * @param $get * @return bool|array */ public static function getHKSYCount($get) { $code = $get["code"] ?? ''; $shop = self::getShopByCode($code); if (empty($shop)) { return false; } return ['count' => $shop->hksy_count, 'expire_time' => $shop->expire_time]; } /** * 扣减剩余数量 ZMH 2025-03-18 * @param $get * @return bool|number */ public static function subHKSYCount($post) { $code = $post["code"] ?? ''; $mcode = $post["mcode"] ?? '0000'; //$count = $post["count"] ?? 1; //默认就是1 $count = 1; $remark = $post["remark"] ?? ''; if ($count <= 0 || empty($remark) || empty($mcode)) { self::$errCode = 1; self::$error = "参数错误"; return false; } //没有必要验证机器码 后续需要对接口进行加密传输,解密操作,验证来源 防篡改,使用token也不安全,秘钥和机器码和token都会暴露; /*$where001 = [ "del" => 0, "is_show" => 1, "pid" => 0, //必须是电脑 "code" => $code ]; $item = EquiCategoryModel::where($where001)->find();*/ $shop = self::getShopByCode($code); if (empty($shop)) { self::$errCode = 9; self::$error = "商家不存在"; return false; } if((int)$shop->is_freeze === 1){ self::$errCode = 7; self::$error = "商家冻结中"; return false; } //判断 营业状态 is_run if((int)$shop->is_run === 0){ self::$errCode = 8; self::$error = "商家暂停营业中"; return false; } /* // 判断是否过期 $expire_time = $shop->expire_time; //echo $expire_time;die; $expire_time = strtotime($expire_time); if (time() < $expire_time) { //未过期 不进行扣除 return true; }*/ //判断类型 if((int)$shop->hksy_type === 0){ self::$errCode = 10; self::$error = "商家类型是包月,不允许使用次数!"; return false; } if ($shop->hksy_count < $count) { self::$errCode = 5; self::$error = "剩余数量不足"; return false; } Db::startTrans(); try { //code... $old_hksy_count = $shop->hksy_count; $shop->hksy_count = $shop->hksy_count - $count; $shop->save(); // 添加数量记录 $hk = new ShopHkLog(); $hk->shop_id = $shop['id']; $hk->source_type = 101; $hk->change_count = 0 - $count; $hk->left_count = $shop->hksy_count; $hk->remark = $remark; $hk->save(); Db::commit(); } catch (\Throwable $th) { //throw $th; Db::rollback(); self::$errCode = 6; self::$error = "扣除失败"; return false; } return $shop->hksy_count; } }