where(['id' => self::$aid, 'is_del' => CommonModel::$del_normal]) ->findOrEmpty() ->toArray(); if (empty($rs)) return json_show(CommonModel::$error_param, '该账户不存在'); $db = VideoModel::where(['is_del' => CommonModel::$del_normal, 'status' => CommonModel::$status_normal]) ->whereIn('id', $rs['video_ids']); $count = $db->count('id'); $list = $db ->field('id,video_sn,video_name,video_url,video_img') ->page($data['page'], $data['size']) ->order(['weight' => 'desc', 'id' => 'desc']) ->select() ->toArray(); return json_show(CommonModel::$success, '获取视频列表成功', ['count' => $count, 'list' => $list]); } //手机主题 public static function theme(): Json { $rs = ThemeModel::field('id,code') ->where(['is_del' => CommonModel::$del_normal, 'group_id' => self::$group_id, 'status' => CommonModel::$status_normal]) ->append(['modular']) ->withAttr('modular', function ($val, $data) { return Db::name('theme_modular') ->field('id,title,type') ->where(['is_del' => CommonModel::$del_normal, 'theme_id' => $data['id'], 'status' => CommonModel::$status_normal]) ->order(['addtime' => 'desc', 'id' => 'desc']) ->append(['data']) ->withAttr('data', function ($v, $d) { return Db::name('theme_modular_data') ->field('id,img,jump_type,jump_param,good_name,good_id,style_type') ->where(['is_del' => CommonModel::$del_normal, 'theme_modular_id' => $d['id']]) ->order(['addtime' => 'desc', 'id' => 'desc']) ->select() ->toArray(); }) ->select() ->toArray(); }) ->findOrEmpty() ->toArray(); return empty($rs) ? json_show(CommonModel::$error_param, '该手机主题不存在') : json_show(CommonModel::$success, '获取手机主题成功', $rs); } //微信支付预下单 public static function getPrepayId(array $data = []): json { $openId = AccountModel::where(['id' => self::$aid, 'is_del' => CommonModel::$del_normal]) ->value('wx_openId', ''); if ($openId == '') return json_show(CommonModel::$error_token, '获取账户openId失败,请重新登录'); Db::startTrans(); try { $amount = '0';//支付金额 if($data['type'] == CommonModel::$pay_type_service){ //购买服务 $rs=ServiceModel::field('id,original_price,activity_price,title,activity_status') ->whereIn('id',array_column($data['list'],'id')) ->where(['is_del'=>CommonModel::$del_normal,'status'=>CommonModel::$status_normal]) ->select() ->toArray(); if(empty($rs)) throw new Exception('购买的服务不存在或已下架'); foreach ($rs as $item){ if($item['activity_status'] == ServiceModel::$activity_status_ing) $amount = bcadd($amount,bcmul($rs['activity_price'],$),2); } } Db::commit(); return json_show(CommonModel::$success, '微信支付预下单成功', $res); } catch (Exception $exception) { Db::rollback(); return json_show(CommonModel::$success, '微信支付预下单失败' . $exception->getMessage()); } } }