活动介绍

$yue_end = date('Y-m-t', strtotime("+" . (30 ) . " days", $timestamp));

时间: 2024-04-09 13:29:15 浏览: 235
根据您的代码,`$yue_end` 是用于获取给定日期所在月份的最后一天的变量。以下是代码解释: ```php $yue_end = date('Y-m-t', strtotime("+" . (30) . " days", $timestamp)); ``` 在这段代码中,`strtotime("+" . (30) . " days", $timestamp)` 将给定日期增加 30 天,并返回新的日期。然后,`date('Y-m-t', $new_timestamp)` 将返回新日期所在月份的最后一天的日期。 请注意,这里假设您希望获取给定日期所在月份的后 30 天作为最后一天。如果您想要获取当前月份的最后一天,可以简单地使用 `date('Y-m-t', $timestamp)`。 以下是一些示例用法: ```php // 使用 UNIX 时间戳 $timestamp = time(); $yue_end = date('Y-m-t', strtotime("+" . (30) . " days", $timestamp)); // 使用日期字符串 $timestamp = '2022-06-15'; $timestamp = strtotime($timestamp); $yue_end = date('Y-m-t', strtotime("+" . (30) . " days", $timestamp)); ``` 在这些示例中,我们使用当前时间戳或一个日期字符串,并使用 `strtotime("+" . (30) . " days", $timestamp)` 来获取增加了 30 天的日期,然后使用 `date('Y-m-t', $new_timestamp)` 来获取新日期所在月份的最后一天。 希望这可以帮助到您!如果您有任何其他问题,请随时提问。
阅读全文

相关推荐

<?php declare (strict_types=1); namespace app\api\controller; use app\api\controller\Base; use app\common\model\Goods as Goodsmodel; use app\common\model\GoodsLock; use app\common\model\GoodsList; use app\common\model\Collect; use app\common\model\Shang; use app\common\model\User; use app\common\model\Order; use app\common\model\OrderList; use app\common\model\UserVip; use think\facade\Db; use think\facade\Log; use \think\Request; use app\common\model\CouponReceive as CouponReceiveModel; class Goods extends Base { static $page_size = 10; static $shang_prize_id = [10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33];#抽奖赏品id static $shang_count_id = [10, 38];#统计次数 // static $shang_give_arr = [ // 1 => '上半场随机获得', // 2 => '下半场随机获得', // 3 => '最后一发获得', // 4 => '全场随机获得', // 5 => '获取指定数量全局赏获得', // ];#赠送(FIRST赏 LAST赏 最终赏 全局赏 拳王赏)赏品id static $shang_give_arr = [ 1 => '只赠不售', 2 => '只赠不售', 3 => '只赠不售', 4 => '只赠不售', 5 => '只赠不售', 6 => '只赠不售', 7 => '只赠不售', 39 => '只赠不售', ];#赠送(FIRST赏 LAST赏 最终赏 全局赏 拳王赏)赏品id /** * 首页盒子列表 * @param Request $request * @return \think\response\Json * @throws \think\db\exception\DbException * created by Admin at 2022/12/7 15:49 * @param [type] 类型 (14)推荐 (1)一番赏 (2)积分赏 (3)擂台赏 */ public function goods(Request $request) { $user_id = $this->getuserid(); $draw_num = 0; if($user_id > 0){ $draw_num = User::where(['id'=>$user_id])->value('draw_num'); } //$user_info = $this->getUser(); $keyword = request()->param('keyword', ''); $whe = []; // $whe[] = ['status', '=', 1]; $whe[] = ['show_is', '=', 0]; $whe[] = ['tower_id', '=', 0]; $whe[] = ['status', 'in', [1, 3]]; #搜索 if ($keyword) { $whe[] = ['title', 'like', '%' . $keyword . '%']; } $type_str = request()->param('type', -1); if ($type_str == 1) { $whe[] = ['type', '=', 1]; } elseif ($type_str == 2) { $whe[] = ['type', '=', 2]; } elseif ($type_str == 3) { $whe[] = ['type', '=', 3]; } elseif ($type_str == 5) { $whe[] = ['type', '=', 5]; }elseif ($type_str == 6) { $whe[] = ['type', '=', 6]; }elseif ($type_str == 7) { # 7抽奖券 $whe[] = ['type', '=', 7]; }elseif ($type_str == 8) { $whe[] = ['type', '=', 8]; }elseif ($type_str == 9) { $whe[] = ['type', '=', 9]; }else { $whe[] = ['type', 'not in', [4,2]]; } #盒子 $goods = GoodsModel::where($whe) ->field("id,title,imgurl,imgurl_detail,price,type,stock,sale_stock,status,box_is,leitai_num") ->order("sort desc,status esc,id desc")->paginate(15)->each(function ($itme) { $itme['imgurl'] = imageUrl($itme['imgurl']); #剩余 $itme['sale_stock'] = $itme['stock'] - $itme['sale_stock']; #参与人数 $join_user = OrderList::field('user_id') ->append(['userinfo']) ->where('goods_id', '=', $itme['id']) ->where('shang_id', 'between', self::$shang_count_id) ->where('order_type', '=', $itme['type']) ->order('id desc') ->group('user_id') ->limit(5) ->select(); $itme['join_user'] = $join_user; #参与次数 $join_count = OrderList::field('id') ->where('shang_id', 'between', self::$shang_count_id) ->where('goods_id', '=', $itme['id']) ->where('order_type', '=', $itme['type']) ->count(); $itme['join_count'] = $join_count; $itme['need_draw_num'] = 0; if($itme['type'] == 7){ $itme['need_draw_num'] = 1; } $box_id = 0; if($itme['box_is'] == 1 && $itme['type'] == 2){ $box_id = GoodsList::where(['shang_id'=>39,'goods_id'=>$itme['id']])->value('id'); } $itme['box_id'] = $box_id; }); $new_data = [ 'data' => $goods->items(), 'last_page' => $goods->lastPage(), 'draw_num' => $draw_num #优惠券的数量 ]; //▼▼▼ 新增配置部分 ▼▼▼ $rule = getConfig('base'); $other = [ 'jump_appid' => $rule['jump_appid'], 'corpid' => $rule['corpid'], 'wx_link' => $rule['wx_link'], 'mp3' => $rule['mp3'], 'logo' => $rule['logo'], 'types' => $rule['types'], 'erweima' => imageUrl($rule['erweima']), ]; $new_data['other'] = $other; return $this->renderSuccess('请求成功', $new_data); } /** * 商品详情 * @param $goods_id 盒子id * @param $goods_num 盒子箱号 */ public function goodsdetail() { //$user_info = $this->getUser(); $user_id = $this->getuserid(); $goods_id = request()->param('goods_id/d', 0); $goods_num = request()->param('goods_num/d', 0); $goods = Goodsmodel::field('id,title,imgurl_detail,price,stock,sale_stock,lock_is,type,status,sale_time,is_integral') ->where(['id' => $goods_id]) ->find(); if (!$goods) { return $this->renderError("盒子不存在"); } if ($goods['status'] != 1 && $goods['status'] != 3) { return $this->renderError("盒子已下架"); } if (($goods_num > $goods['stock']) || ($goods_num < 0)) { return $this->renderError("箱号错误"); } if ($goods['sale_time']) { $goods['addtime'] = date('m-d', $goods['sale_time']); } else { $goods['addtime'] = ''; } $goods['imgurl_detail'] = imageUrl($goods['imgurl_detail']); #自动找箱号 if ($goods_num == 0) { #奖品信息 $goodslist_info = GoodsList::field('num,sum(surplus_stock) as all_surplus_stock') ->where(['goods_id' => $goods_id]) ->where('shang_id','not in',[1,2,3,4,5]) ->having('all_surplus_stock', '>', 0) ->group('num') ->order('num asc') ->find(); if ($goodslist_info) { $goods_num = $goodslist_info['num']; } else { $goods_num = 1; } } $goods['num'] = $goods_num; #是否收藏 $collection_is = Collect::field('id') ->where(['user_id' => $user_id]) ->where(['goods_id' => $goods_id]) ->where(['num' => $goods_num]) ->find(); $goods['collection_is'] = $collection_is ? 1 : 0; #本箱子余量 $goods_surplus = GoodsList::field('sum(stock) as stock, sum(surplus_stock) as surplus_stock') ->where('goods_id', '=', $goods_id) ->where('num', '=', $goods_num) ->where('shang_id', 'in', self::$shang_prize_id) ->find(); $all_surplus_stock = $goods_surplus['surplus_stock']; $goods['surplus_stock'] = $goods['stock'] - $goods['sale_stock']; $goods['goodslist_stock'] = $goods_surplus['stock']; $goods['goodslist_surplus_stock'] = $goods_surplus['surplus_stock']; #概率不足时 $pro_all = 0; $pro_max = 0; $pro_key = 0; #所有奖品信息 $goodslist = GoodsList::field('id,shang_id,title,stock,surplus_stock,imgurl,goods_type,sale_time,price,sc_money,goods_id,k_zz_num,zz_num') ->append(['shang_title','goods_typename','shang_info']) ->where(['goods_id' => $goods_id]) ->where(['num' => $goods_num]) ->where(['is_box' => 2]) ->order('sort desc,shang_id asc,id asc') ->select()->toArray(); foreach ($goodslist as $key => &$value) { #价格 $value['price'] = $value['price'] * 1; #预售时间 if ($value['sale_time']) { $value['sale_time'] = date('Y-m-d', $value['sale_time']); } #剩余 $surplus_stock = $value['surplus_stock']; if (array_key_exists($value['shang_id'], self::$shang_give_arr)) { #概率 $pro = self::$shang_give_arr[$value['shang_id']]; if($value['shang_id'] == 1){ $pro = '参与'. ($goods['goodslist_stock'] / 2) .'前发数/'. ($goods['goodslist_stock'] / 2); } if($value['shang_id'] == 2){ $pro = '参与'. ($goods['goodslist_stock'] / 2) .'后发数/'. ($goods['goodslist_stock'] / 2); } if($value['shang_id'] == 3){ $pro = '随最后一发赠送'; } if($value['shang_id'] == 4){ $pro = '参与发数/'. $goods['goodslist_stock']; } if($value['shang_id'] == 5){ $pro = '只赠不售'; } if($value['shang_id'] == 6){ $pro = '1-'. $goods['goodslist_stock'] . '发数最多得'; } if($value['shang_id'] == 7){ $pro = $value['k_zz_num'].'-'. $value['zz_num'] . '发数最多得'; } $pro_num = 0; } else { #概率 if ($surplus_stock > 0) { $pro_basics = bcdiv("$surplus_stock", "$all_surplus_stock", 4); $pro = '概率:' . ($pro_basics * 100) . '%'; $pro_num = ($pro_basics * 100); } else { $pro = '概率:' . 0 . '%'; $pro_num = 0; } } $value['surplus_stock'] = $surplus_stock; $value['pro'] = $pro; $value['imgurl'] = imageUrl($value['imgurl']); #计算剩余概率 $pro_all += $pro_num; if ($pro_num >= $pro_max) { $pro_max = $pro_num; $pro_key = $key; } } #概率不足时 if ($pro_max > 0 && $pro_all < 100) { $surplus_pro = bcsub("100", "$pro_all", 2); $goodslist[$pro_key]['pro'] = bcadd("$pro_max", "$surplus_pro", 2) . '%'; } #锁箱信息=============== $goods_lock_user_nickname = 0; $goods_lock_user_headimg = 0; $goods_lock_surplus_time = 0; $goods_id_num = $goods_id . '_' . $goods_num; $goods_lock_info = GoodsLock::where(['goods_id_num' => $goods_id_num]) ->where('endtime', '>', time()) ->order('id desc') ->find(); if ($goods['lock_is'] && $goods_lock_info) { $goods_lock_surplus_time = $goods_lock_info['endtime']; $user_info = User::field('nickname,headimg')->where(['id' => $goods_lock_info['user_id']])->find(); $goods_lock_user_nickname = $user_info['nickname']; $goods_lock_user_headimg = $user_info['headimg']; } $lock_info = [ 'lock_is' => $goods['lock_is'], 'goods_lock_user_nickname' => $goods_lock_user_nickname, 'goods_lock_user_headimg' => $goods_lock_user_headimg, 'goods_lock_surplus_time' => $goods_lock_surplus_time, ]; #锁箱信息=============== #参与人数 $join_user = OrderList::field('user_id') ->append(['userinfo']) ->where('goods_id', '=', $goods_id) ->where('num', '=', $goods_num) ->where('shang_id', 'between', self::$shang_count_id) ->where('order_type', '=', $goods['type']) ->order('id desc') ->group('user_id') ->limit(5) ->select(); $new_join_user = []; foreach ($join_user as $join_user_value) { $new_join_user[] = $join_user_value['userinfo']['headimg']; } #参与次数 $join_count = OrderList::field('id')->where('goods_id', '=', $goods_id) ->where('num', '=', $goods_num) ->where('shang_id', 'between', self::$shang_count_id) ->where('order_type', '=', $goods['type']) ->count(); #时间配置 $config = getConfig('base'); $goods['three_time'] = $config['three_time']; $goods['five_time'] = $config['five_time']; $new_data = [ 'goods' => $goods, 'lock_info' => $lock_info, 'join_user' => $new_join_user, 'join_count' => $join_count, 'goodslist' => $goodslist, ]; return $this->renderSuccess("请求成功", $new_data); } /** * 换箱箱号 */ public function goodslist_count() { $goods_id = request()->param('goods_id/d', 0); #盒子信息 $goods = Goodsmodel::field('id,stock,status') ->where(['id' => $goods_id]) ->find(); if (!$goods) { return $this->renderError("盒子不存在"); } if ($goods['status'] != 1 && $goods['status'] != 3) { return $this->renderError("盒子已下架"); } $page_size = self::$page_size; $length = ceil($goods['stock'] / $page_size); $data = []; for ($i = 0; $i < $length; $i++) { $start_length = ($i * $page_size) + 1; $end_length = ($i * $page_size) + $page_size; if ($end_length >= $goods['stock']) { $end_length = $goods['stock']; } $data[] = [ 'title' => $start_length . '-' . $end_length, 'page_no' => $i, ]; } return $this->renderSuccess("请求成功", $data); } /** * 统计多少箱 */ public function goodslist_content(Request $request) { $sort = request()->param('sort/d', 0);#排序1箱号高 2余量高 $goods_id = request()->param('goods_id/d', 0); $page_no = request()->param('page_no/d', 0);#页码 if ($page_no <= 0) { $page_no = 0; } #盒子信息 $goods = Goodsmodel::field('id,stock,status') ->where(['id' => $goods_id]) ->find(); if (!$goods) { return $this->renderError("盒子不存在"); } if ($goods['status'] != 1 && $goods['status'] != 3) { return $this->renderError("盒子已下架"); } $page_size = self::$page_size; $start_length = ($page_no * $page_size) + 1; $end_length = ($page_no * $page_size) + $page_size; if ($end_length >= $goods['stock']) { $end_length = $goods['stock']; } $data = []; for ($goods_num = $start_length; $goods_num <= $end_length; $goods_num++) { #奖品信息 $goodlist = GoodsList::field('id,stock,surplus_stock,shang_id') ->append(['shang_title']) ->where(['goods_id' => $goods_id]) ->where(['num' => $goods_num]) ->order('sort desc,shang_id asc,id asc') ->select(); #剩余 $surplus_all_stock = 0; foreach ($goodlist as $key => $value) { if (!array_key_exists($value['shang_id'], self::$shang_give_arr)) { $surplus_all_stock += $value['surplus_stock']; } unset($value['id']); } if ($surplus_all_stock <= 0) { $surplus_all_stock = 0; } $data[] = [ 'num' => $goods_num, 'surplus_all_stock' => $surplus_all_stock, 'goodslist' => $goodlist, ]; } if ($sort == 2) { $data = arraySequence($data, 'surplus_all_stock'); } return $this->renderSuccess("请求成功", $data); } /** * 中赏记录 */ public function shang_log(Request $request) { $shang_id = request()->param('shang_id/d', 0); $goods_id = request()->param('goods_id/d', 0); $goods_num = request()->param('goods_num/d', 0); #盒子信息 $goods = Goodsmodel::field('id,stock,status,type') ->where(['id' => $goods_id]) ->find(); if (!$goods) { return $this->renderError("盒子不存在"); } if ($goods['status'] != 1 && $goods['status'] != 3) { return $this->renderError("盒子已下架"); } if (RegInt($goods_num)) { return $this->renderError("箱号选择错误"); } #中奖记录分类 $category = GoodsList::field('shang_id') ->append(['shang_title']) ->where('goods_id', '=', $goods_id) ->where('num', '=', $goods_num) ->where('is_box', '=', 2) ->group('shang_id') ->select()->toArray(); array_unshift($category, ['shang_id' => 0, 'shang_title' => '全部']); $where = []; if ($shang_id) { $where[] = ['shang_id', '=', $shang_id]; } $data = OrderList::field('user_id,goodslist_title,goodslist_imgurl,shang_id,addtime,count(id) as prize_num') ->append(['shang_title', 'user_info']) ->where('goods_id', '=', $goods_id) ->where('num', '=', $goods_num) ->where('order_type', '=', $goods['type']) ->where($where) ->order('id desc') ->group("order_id,goodslist_id,user_id") ->paginate(10)->each(function ($item) { $item['addtime'] = date('Y-m-d H:i:s', $item['addtime']); $item['goodslist_imgurl'] = imageUrl($item['goodslist_imgurl']); return $item; }); // dd($data); $new_data = [ 'category' => $category, 'data' => $data->items(), 'last_page' => $data->lastPage(), ]; return $this->renderSuccess("请求成功", $new_data); } /** * 发数排名 */ public function paiming_log(Request $request) { $goods_id = request()->param('goods_id/d', 0); $goods_num = request()->param('goods_num/d', 0); #盒子信息 $goods = Goodsmodel::field('id,stock,status,type') ->where(['id' => $goods_id]) ->find(); if (!$goods) { return $this->renderError("盒子不存在"); } if ($goods['status'] != 1 && $goods['status'] != 3) { return $this->renderError("盒子已下架"); } if (RegInt($goods_num)) { return $this->renderError("箱号选择错误"); } $ranking = OrderList::field('user_id, sum(goodslist_type) as total_orders') ->append(['user_info']) ->group('user_id') ->where('goods_id', '=', $goods_id) ->where('num', '=', $goods_num) ->where('order_type', '=', $goods['type']) ->where('shang_id', 'in', self::$shang_prize_id) ->order('total_orders', 'desc') ->select() ->toArray(); $new_data = [ 'data' => $ranking, ]; return $this->renderSuccess("请求成功", $new_data); } /** * 下单计算金额 */ public function ordermoney() { //return $this->renderError("正在调试"); $user = $this->getUser(); $user_id = $user['id'] ?? 0; $prize_num = request()->param('prize_num/d', 0); #抽几发 $goods_id = request()->param('goods_id/d', 0); #盒子ID $num = request()->param('goods_num/d', 0); #第几箱 $todaySpent = 0; if ($user_id > 0) { $start_time = strtotime(date('Y-m-d 00:00:00')); // 今日开始时间 $end_time = strtotime(date('Y-m-d 23:59:59')); // 今日结束时间 $todaySpent = Order::where('user_id', $user_id) ->where('status', 1) // 已支付订单 ->where('addtime', '>=', $start_time) ->where('addtime', '<=', $end_time) ->sum('price'); } // $use_money_is = request()->param('use_money_is/d', 0); #0不抵扣 1抵扣 $use_money_is = 0; $use_integral_is = request()->param('use_integral_is/d', 0); #0不抵扣 1抵扣 $coupon_id = request()->param('coupon_id'); //优惠券 #盒子信息 $goods = Goodsmodel::field('title,imgurl_detail,type,price,status,imgurl')->where(['id' => $goods_id]) ->find(); if (!$goods) { return $this->renderError("盒子不存在"); } if ($goods['status'] != 1) { return $this->renderError("盒子已下架"); } $goods['imgurl_detail'] = !empty($goods['imgurl_detail']) ? imageUrl($goods['imgurl_detail']) : ''; $goods['imgurl'] = !empty($goods['imgurl']) ? imageUrl($goods['imgurl']) : ''; if (RegInt($num)) { return $this->renderError("箱号选择错误"); } #奖品信息 $goodslist = GoodsList::field('sum(stock) as stock, sum(surplus_stock) as surplus_stock') ->where('goods_id', '=', $goods_id) ->where('num', '=', $num) ->where('shang_id', 'in', self::$shang_prize_id) ->find(); if (!$goodslist) { return $this->renderError('暂无奖品信息'); } $surplus_stock = $goodslist['surplus_stock']; if ($surplus_stock <= 0) { return $this->renderError('库存剩余不足,请刷新重试'); } #判断库存 if (RegInt($prize_num)) { return $this->renderError("抽奖数量选择错误,请刷新重试"); } if ($prize_num > $surplus_stock) { return $this->renderError("剩余数量不足,请刷新重试"); } #盒子单价 $box_price = $goods['price']; #订单金额 微信支付金额 $order_total = $order_zhe_total = $price = bcmul("$box_price", "$prize_num", 2); #使用优惠券 $coupon_price = 0; if(!empty($coupon_id)){ $coupon = CouponReceiveModel::where(['id'=>$coupon_id,'status'=>0,'user_id'=>$user['id']])->where('man_price','<=',$price)->find(); if($coupon){ $coupon_price = $coupon['price']; } }else{ $coupon_id = 0; $coupon = CouponReceiveModel::where(['status'=>0,'user_id'=>$user['id']])->where('man_price','<=',$price)->order('price desc')->find(); if($coupon){ $coupon_price = $coupon['price']; $coupon_id = $coupon['id']; } } $price = bcsub("$price","$coupon_price",2); if($price <= 0){ $price = 0; } $order_zhe_total = $price; if ($goods['type'] == 1 || $goods['type'] == 3 || $goods['type'] == 6) { $zhe = 0; $vip_info = UserVip::where(['id' => $user['vip']])->find(); if ($vip_info && $vip_info['discount'] > 0) { $zhe = $vip_info['discount']; $zhe_bl = bcdiv("$zhe", "10", 2); $order_zhe_total = $price = bcmul("$price", "$zhe_bl", 2); } #潮币抵扣 $use_integral = 0; if ($use_integral_is == 1) { if ($user['integral'] >= $price) { $use_integral = $price; $price = 0; } else { $use_integral = $user['integral']; $price = bcsub("$price", "{$user['integral']}", 2); } } #余额抵扣 $use_money = 0; if ($use_money_is == 1) { if ($user['money'] >= $price) { $use_money = $price; $price = 0; } else { $use_money = $user['money'];# $price = bcsub("$price", "{$user['money']}", 2); } } $use_score = 0; } elseif ($goods['type'] == 5) { #优惠券 $coupon_id =0; $coupon_price = 0; #折扣 $zhe = 0; #微信支付 $price = 0; #潮币抵扣 $use_integral = 0; #余额抵扣 $use_money = 0; #积分 $use_score = $order_total; } else { return $this->renderError("非法请求"); } #抽奖数量 $goods['prize_num'] = $prize_num; $data = [ 'goods' => $goods, 'order_total' => $order_total * 1, 'order_zhe_total' => $order_zhe_total * 1, 'zhe' => ($zhe * 1), 'today_spent' => $todaySpent, 'price' => $price * 1, 'integral' => $user['integral'] * 1, 'use_integral' => $use_integral * 1, 'money' => $user['money'] * 1, 'use_money' => $use_money * 1, 'score' => $user['score'] * 1, 'use_score' => $use_score, 'coupon_price'=>$coupon_price, 'coupon_id' =>$coupon_id ]; //▼▼▼ 新增配置部分 ▼▼▼ $rule = getConfig('base'); $other = [ 'jump_appid' => $rule['jump_appid'], 'corpid' => $rule['corpid'], 'wx_link' => $rule['wx_link'], 'titlek' => $rule['titlek'], 'logoo' => $rule['logoo'], 'day_limit' => $rule['day_limit'], 'mp3' => $rule['mp3'], 'logo' => $rule['logo'], 'types' => $rule['types'], 'erweima' => imageUrl($rule['erweima']), ]; $data['other'] = $other; // 将配置合并到返回数据 return $this->renderSuccess("请求成功", $data); } /** * 下单计算金额 */ public function orderbuy() { $user = $this->getUser(); if (empty($user['mobile'])) { return $this->renderError('请先绑定手机号', [], -9); } // 获取系统配置 $config = getConfig('base'); $day_limit = $config['day_limit'] ?? 0; // 每日限额,0表示不限制 // 如果有限额设置,则检查用户当日消费 if ($price > 0) { // 只在需要现金支付时检查限额 $config = getConfig('base'); $day_limit = $config['day_limit'] ?? 0; if ($day_limit > 0) { $start_time = strtotime(date('Y-m-d 00:00:00')); $end_time = strtotime(date('Y-m-d 23:59:59')); $total_spent = Order::where('user_id', $user['id']) ->where('status', 1) ->where('addtime', '>=', $start_time) ->where('addtime', '<=', $end_time) ->sum('price'); if ($total_spent >= $day_limit) { return $this->renderError("当日消费金额已超过限额"); } } } $prize_num = request()->param('prize_num/d', 0); #抽几发 $goods_id = request()->param('goods_id/d', 0); #盒子ID $num = request()->param('goods_num/d', 0); #第几箱 // $use_money_is = request()->param('use_money_is/d', 0); #0不抵扣 1抵扣 $use_money_is = 0; $use_integral_is = request()->param('use_integral_is/d', 0); #0不抵扣 1抵扣 $coupon_id = request()->param('coupon_id'); //优惠券 $pay_type = request()->param('pay_type') ? request()->param('pay_type') : 1; // 1微信 2支付宝 #盒子信息 $goods = Goodsmodel::field('title,imgurl_detail,type,price,status,lock_is,lock_time,leitai_num')->where(['id' => $goods_id]) ->find(); if (!$goods) { return $this->renderError("盒子不存在"); } if ($goods['status'] != 1) { return $this->renderError("盒子已下架"); } if (RegInt($num)) { return $this->renderError("箱号选择错误"); } #奖品信息 $is_goodslist = GoodsList::field('id') ->where('goods_id', '=', $goods_id) ->where('num', '=', $num) ->where('shang_id', 'in', self::$shang_prize_id) ->find(); if (!$is_goodslist) { return $this->renderError('暂无奖品信息'); } #锁箱信息=============== if ($goods['type'] == 1 || $goods['type'] == 6) { //限购 if($prize_num > 1 && $goods['title'] == '新人福利,胶个朋友'){ return $this->renderError('该赏限购1发'); } $user_num = OrderList::where('goods_id', '=', $goods_id) ->where('user_id',$user['id']) ->where('num', '=', $num) ->where('order_type', '=', $goods['type']) ->where('shang_id', 'in', self::$shang_prize_id) ->count(); if($user_num >= 1 && $goods['title'] == '新人福利,胶个朋友'){ return $this->renderError('该赏限购1发'); } $goods_id_num = $goods_id . '_' . $num; $lock_info = GoodsLock::where(['goods_id_num' => $goods_id_num]) ->where('endtime', '>', time()) ->order('id desc') ->find(); if ($lock_info && $lock_info['endtime'] > time() && $lock_info['user_id'] !== $user['id']) { $surplus_time = $lock_info['endtime'] - time(); return $this->renderError('有会员正在锁箱,请等待' . $surplus_time . '秒'); } } #锁箱信息=============== #擂台赏限购=============== if ($goods['type'] == 3) { //限购 if($prize_num > $goods['leitai_num']){ return $this->renderError('该赏限购'.$goods['leitai_num'].'发'); } $user_num = Order::where('goods_id', '=', $goods_id) ->where('user_id',$user['id']) ->where('num', '=', $num) ->where('order_type', '=', $goods['type']) ->where('status', '=', 1) ->sum('prize_num'); //已购买 + 当前购买 大于 限购 if($user_num + $prize_num > $goods['leitai_num']){ return $this->renderError('该赏限购'.$goods['leitai_num'].'发'); } } #擂台赏限购=============== #奖品信息 $goodslist = GoodsList::field('sum(stock) as stock, sum(surplus_stock) as surplus_stock') ->where('goods_id', '=', $goods_id) ->where('num', '=', $num) ->where('shang_id', 'in', self::$shang_prize_id) ->find(); $surplus_stock = $goodslist['surplus_stock']; if ($surplus_stock <= 0) { return $this->renderError('库存剩余不足,请刷新重试'); } #判断库存 if (RegInt($prize_num)) { return $this->renderError("抽奖数量选择错误,请刷新重试"); } if ($prize_num > $surplus_stock) { return $this->renderError("剩余数量不足,请刷新重试"); } #盒子单价 $box_price = $goods['price']; #订单金额 微信支付金额 $order_total = $order_zhe_total = $price = bcmul("$box_price", "$prize_num", 2); #使用优惠券 $coupon_price = 0; if(!empty($coupon_id)){ $coupon = CouponReceiveModel::where(['id'=>$coupon_id,'status'=>0,'user_id'=>$user['id']])->where('man_price','<=',$price)->find(); if($coupon){ $coupon_price = $coupon['price']; } } $price = bcsub("$price","$coupon_price",2); if($price <= 0){ $price = 0; } $order_zhe_total = $price; if ($goods['type'] == 1 || $goods['type'] == 3 || $goods['type'] == 6) { #折扣 $zhe = 0; $vip_info = UserVip::where(['id' => $user['vip']])->find(); if ($vip_info && $vip_info['discount'] > 0) { $zhe = $vip_info['discount']; $zhe_bl = bcdiv("$zhe", "10", 2); $order_zhe_total = $price = bcmul("$price", "$zhe_bl", 2); } #潮币抵扣 $use_integral = 0; if ($use_integral_is == 1) { if ($user['integral'] >= $price) { $use_integral = $price; $price = 0; } else { $use_integral = $user['integral']; $price = bcsub("$price", "{$user['integral']}", 2); } } #余额抵扣 $use_money = 0; if ($use_money_is == 1) { if ($user['money'] >= $price) { $use_money = $price; $price = 0; } else { $use_money = $user['money'];# $price = bcsub("$price", "{$user['money']}", 2); } } $use_score = 0; } elseif ($goods['type'] == 5) { #优惠券 $coupon_id =0; $coupon_price = 0; #折扣 $zhe = 0; #微信支付 $price = 0; #潮币抵扣 $use_integral = 0; #余额抵扣 $use_money = 0; #积分 $use_score = $order_total; if ($user['score'] < $use_score) { return $this->renderError("积分不足"); } } else { return $this->renderError("非法请求"); } #一番赏锁箱 if ($goods['type'] == 1 || $goods['type'] == 6) { #盒子id_箱号 $goods_id_num = $goods_id . '_' . $num; #盒子是否配置锁箱 if ($goods['lock_is'] == 1 && $goods['lock_time'] > 0) { $redis = new \Redis(); $redis->connect('127.0.0.1', 6379); $redis_key = "kpw_lock" . '_' . $goods_id_num; $redis_key_info = $redis->get($redis_key); if ($redis_key_info) { return $this->renderError("有会员正在锁箱,请等待"); } else { $redis->set($redis_key, 1, 1); } #默认锁箱时间 $defaulttime = (time() + $goods['lock_time']); #锁箱信息 $lock_info = GoodsLock::where('goods_id_num', '=', $goods_id_num) ->where('endtime', '>', time()) ->order('id desc') ->find(); if ($lock_info) {#存在锁箱 if ($prize_num == 3 || $prize_num == 5) { $config_time = getConfig('base'); if ($prize_num == 3) { $endtime = $defaulttime + $config_time['three_time']; } elseif ($prize_num == 5) { $endtime = $defaulttime + $config_time['five_time']; } GoodsLock::where('id', '=', $lock_info['id']) ->update([ 'endtime' => $endtime, 'update_time' => time(), ]); } else { GoodsLock::where('id', '=', $lock_info['id']) ->update([ 'endtime' => $defaulttime, 'update_time' => time(), ]); } } else { if ($prize_num == 3 || $prize_num == 5) { $config_time = getConfig('base'); if ($prize_num == 3) { $endtime = $defaulttime + $config_time['three_time']; } elseif ($prize_num == 5) { $endtime = $defaulttime + $config_time['five_time']; } #新增锁箱信息 GoodsLock::insert([ 'user_id' => $user['id'], 'goods_id_num' => $goods_id_num, 'endtime' => $endtime, 'update_time' => time(), ]); } else { #新增锁箱信息 GoodsLock::insert([ 'user_id' => $user['id'], 'goods_id_num' => $goods_id_num, 'endtime' => $defaulttime, 'update_time' => time(), ]); } } } } #一番赏锁箱 $redis = new \Redis(); $redis->connect('127.0.0.1', 6379); $redis_key = "kpw_orderbuy" . '_' . $user['id']; $redis_key_info = $redis->get($redis_key); if ($redis_key_info) { return $this->renderError("当前操作太快了,请等待"); } else { $redis->set($redis_key, 1, 10); } //轮换商户号 $redis_pay_key = "pay_sh"; $redis_pay_key_info = $redis->get($redis_pay_key); if(!$redis_pay_key_info){ $redis->set($redis_pay_key, 1, 86400); $redis_pay_key_info = $redis->get($redis_pay_key); } Db::startTrans(); #===================================================*********** #奖品信息加锁 GoodsList::field('id,stock,surplus_stock') ->where('goods_id', '=', $goods_id) ->where('num', '=', $num) ->lock(true)->select(); #奖品信息 $goodslist_lock = GoodsList::field('sum(surplus_stock) as surplus_stock') ->where('goods_id', '=', $goods_id) ->where('num', '=', $num) ->where('shang_id', 'in', self::$shang_prize_id) ->find(); #判断库存 if ($goodslist_lock['surplus_stock'] <= 0) { Db::rollback(); $redis->del($redis_key); return $this->renderError("已售空,请刷新重试"); } #===================================================*********** $res = []; $order_num = create_order_no('MH_', 'order', 'order_num'); #创建订单 $res[] = $order_id = Order::insertGetId([ 'user_id' => $user['id'], 'order_num' => $order_num, 'order_total' => $order_total,#订单金额 'order_zhe_total' => $order_zhe_total,#订单折扣金额 'price' => $price,#微信支付 'use_money' => $use_money,#余额抵扣 'use_integral' => $use_integral,#潮币抵扣 'use_score' => $use_score,#积分抵扣 'zhe' => $zhe,#会员折扣 'goods_id' => $goods_id, 'num' => $num, 'goods_price' => $goods['price'], 'goods_title' => $goods['title'], 'goods_imgurl' => $goods['imgurl_detail'], 'prize_num' => $prize_num, 'status' => 0, 'pay_type' => $pay_type,#1微信 2支付宝 'pay_sh' => $redis_pay_key_info, 'order_type' => $goods['type'], 'addtime' => time(), 'coupon_id' => $coupon_id?$coupon_id:0, 'use_coupon' => $coupon_price #优惠券抵扣 ]); #微信支付金额大于0 if ($price > 0) { $body = '购买盒子' . $goods['title']; if($pay_type == 1){ if ($goods['type'] == 1) { $attach = 'order_yfs'; } elseif ($goods['type'] == 3) { $attach = 'order_lts'; } elseif ($goods['type'] == 6) { $attach = 'order_lts'; } $payRes = (new Pay())->wxCreateOrder($order_num, $price, $user['openid'], $body, $attach,$redis_pay_key_info); if($redis_pay_key_info == 1){ $redis->set($redis_pay_key, 2, 86400); }elseif($redis_pay_key_info == 2){ $redis->set($redis_pay_key, 3, 86400); }elseif($redis_pay_key_info == 3){ $redis->set($redis_pay_key, 4, 86400); }elseif($redis_pay_key_info == 4){ $redis->set($redis_pay_key, 5, 86400); }elseif($redis_pay_key_info == 5){ $redis->set($redis_pay_key, 1, 86400); } if ($payRes['status'] == 1) { #结果集 $new_data = [ 'status' => 1, 'pay_type'=>$pay_type, 'order_num' => $order_num, 'res' => $payRes['data'], ]; } else { #删除redis $redis->del($redis_key); Db::rollback(); return $this->renderError("下单失败"); } } if($pay_type == 2){ //生成一个 api/login/alipay?订单号的链接 $url = 'https://zxcw.xby6991282.xyz/api/alipay?order_num='.$order_num; if($url && $order_num){ #结果集 $new_data = [ 'status' => 1, 'pay_type'=>$pay_type, 'order_num' => $order_num, 'res' => $url, ]; } else { #删除redis $redis->del($redis_key); Db::rollback(); return $this->renderError("下单失败"); } } if($pay_type == 3){ //调用通联支付 $payRes = (new Allinpay())->pay($order_num, $price, $user['openid'], $body); if($payRes['status'] == 1){ #结果集 $new_data = [ 'status' => 1, 'pay_type'=>$pay_type, 'order_num' => $order_num, 'res' => json_decode($payRes['data']['payinfo'], true), ]; } else { #删除redis $redis->del($redis_key); Db::rollback(); return $this->renderError("下单失败"); } } } else { try { #开盒子 $res[] = (new Notify($this->app))->drawprize_notice($user['id'], $order_id, $goods_id, $num); } catch (\Throwable $e) { Db::rollback(); #删除redis $redis->del($redis_key); return $this->renderError("火爆中...请刷新重新购买"); } #结果集 $new_data = [ 'status' => 0, 'order_num' => $order_num, ]; } if (resCheck($res)) { Db::commit(); #删除redis $redis->del($redis_key); return $this->renderSuccess("下单成功", $new_data); } else { Db::rollback(); #删除redis $redis->del($redis_key); return $this->renderError("购买失败,请刷新重试"); } } /** * 抽中的奖品 * $order_num 订单编号 */ public function prizeorderlog() { $user = $this->getUser(); $order_num = request()->param('order_num', ''); $order_info = Order::field('id,goods_id,num,order_type,price,pay_sh,pay_type') ->where('order_num', '=', $order_num) ->where('user_id', '=', $user['id']) ->where('status', '=', 1) ->find(); if (!$order_info) { return $this->renderError("支付异常,请刷新重试"); } // if($order_info['price'] > 0 && $order_info['pay_type'] !== 2 && $order_info['pay_type'] !== 4){ // $this->xcc_fahuo($order_num,$user['openid'],$order_info['pay_sh'],$order_info['pay_type']); // } #普通赏 $data = OrderList::field('user_id,shang_id,goodslist_id,goodslist_title,goodslist_imgurl') ->append(['shang_title','shang_imgurl','special_imgurl','color','color1','gn_type']) ->where('user_id', '=', $user['id']) ->where('order_id', '=', $order_info['id']) ->where('order_type', '=', $order_info['order_type']) // ->orderRaw("field(shang_id,39,34,35,36,37,38) asc,id asc") ->order('shang_id asc, id asc') ->paginate(100)->each(function ($item) { $item['goodslist_imgurl'] = imageUrl($item['goodslist_imgurl']); return $item; }); $new_data = [ 'user_info' => [ 'nickname' => $user['nickname'], 'headimg' => $user['headimg'], ], 'data' => $data->items(), ]; return $this->renderSuccess("请求成功", $new_data); } /** * 支付同步发货 */ public function xcc_fahuo($order_num,$openid,$pay_sh = 1,$pay_type = 1){ #同步发货********************************************************** log::info("**********************************************************"); log::info("开始发货 order_num:,".json_encode($order_num)); log::info("开始发货 openid:,".json_encode($openid)); $wxServer = new \app\common\server\Wx($this->app); $access_token = $wxServer->get_access_token(); log::info("获取token:,".json_encode($access_token)); $send_url = 'https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token='.$access_token; if($pay_type == 1){ if($pay_sh == 1){ $mch_id = getConfig('weixinpay')['mch_id']; }elseif($pay_sh == 2){ $mch_id = getConfig('weixinpay')['mch_id2']; }elseif($pay_sh == 3){ $mch_id = getConfig('weixinpay')['mch_id3']; }elseif($pay_sh == 4){ $mch_id = getConfig('weixinpay')['mch_id4']; }elseif($pay_sh == 5){ $mch_id = getConfig('weixinpay')['mch_id5']; } } if($pay_type == 3 || $pay_type == 4){ $mch_id = '1501244881'; $content = Db::name('wxpay_log')->where('order_no',$order_num)->value('content'); $content = json_decode($content,true); $order_num = $content['trxid']; log::info("通联发货:,".$order_num); } $sendD = [ 'order_key' => [ 'order_number_type' => 1, //订单单号类型,用于确认需要上传详情的订单。枚举值1,使用下单商户号和商户侧单号;枚举值2,使用微信支付单号。 "mchid" => $mch_id, "out_trade_no"=>$order_num ], 'logistics_type' => 3,//物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提 'delivery_mode' => 1, //发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)2、SPLIT_DELIVERY(分拆发货) 示例值: UNIFIED_DELIVERY 'shipping_list' => [ [ 'item_desc' => '您的商品已发到赏袋,请自行发货' ] ], 'upload_time' => date('Y-m-d\TH:i:sP', time()), 'payer' => [ 'openid' => $openid ] ]; $sendD = json_encode($sendD, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); $result = $this->httpPost($send_url,$sendD); log::info("发货结果:,".$result); $result = json_decode($result,true); } // 模拟提交数据函数 public function httpPost($url,$data){ $curl = curl_init(); // 启动一个CURL会话 curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在 curl_setopt($curl, CURLOPT_POST, true); // 发送一个常规的Post请求 curl_setopt($curl, CURLOPT_POSTFIELDS,$data); // Post提交的数据包 curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环 curl_setopt($curl, CURLOPT_HEADER, false); // 显示返回的Header区域内容 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // 获取的信息以文件流的形式返回 $result = curl_exec($curl); // 执行操作 if (curl_errno($curl)) { return 'Error POST'.curl_error($curl); } curl_close($curl); // 关键CURL会话 return $result; // 返回数据 } /** * 收藏列表 */ public function listCollect(Request $request) { $user = $this->getUser(); $type = \request()->param('type', 0); if ($type == 1) { $data = Collect::field('id,goods_id,type,num') ->where(['user_id' => $user['id']]) ->where('type', 'in', [1, 3, 5]) ->append(['goods_info']) ->paginate(100)->each(function ($item) { $item['goods_title'] = $item['goods_info']['title']; $item['imgurl'] = imageUrl($item['goods_info']['imgurl']); if ($item['type'] == 1 || $item['type'] == 3 || $item['type'] == 5) { #库存 $surplus = GoodsList::field('sum(stock) as stock, sum(surplus_stock) as surplus_stock') ->where('goods_id', '=', $item['goods_id']) ->where('num', '=', $item['num']) ->where('shang_id', 'in', self::$shang_prize_id) ->find(); $item['stock'] = $surplus['stock']; $item['surplus_stock'] = $surplus['surplus_stock']; } else { $item['stock'] = 0; $item['surplus_stock'] = 0; } return $item; }); } elseif ($type == 2) { $data = Collect::field('id,goods_id,type,num') ->where(['user_id' => $user['id']]) ->where('type', '=', 2) ->append(['goods_info']) ->paginate(100)->each(function ($item) { $item['goods_title'] = $item['goods_info']['title']; $item['imgurl'] = imageUrl($item['goods_info']['imgurl']); if ($item['type'] == 1 || $item['type'] == 3 || $item['type'] == 5) { #库存 $surplus = GoodsList::field('sum(stock) as stock, sum(surplus_stock) as surplus_stock') ->where('goods_id', '=', $item['goods_id']) ->where('num', '=', $item['num']) ->where('shang_id', 'in', self::$shang_prize_id) ->find(); $item['stock'] = $surplus['stock']; $item['surplus_stock'] = $surplus['surplus_stock']; } else { $item['stock'] = 0; $item['surplus_stock'] = 0; } return $item; }); } $new_data = [ 'data' => $data->items(), 'last_page' => $data->lastPage(), ]; return $this->renderSuccess("操作成功", $new_data); } /** * 添加收藏 */ public function addCollect(Request $request) { $user = $this->getUser(); $goods_id = request()->param('goods_id/d', 0); $goods_num = request()->param('goods_num/d', 0); #盒子信息 $goods = Goodsmodel::field('id,stock,status,type') ->where(['id' => $goods_id]) ->find(); if (!$goods) { return $this->renderError("盒子不存在"); } if ($goods['status'] != 1 && $goods['status'] != 3) { return $this->renderError("盒子已下架"); } $info = Collect::field('id') ->where(['user_id' => $user['id']]) ->where(['goods_id' => $goods_id]) ->where(['num' => $goods_num]) ->find(); if ($info) { $res = Collect::where(['id' => $info['id']])->delete(); } else { $res = Collect::insert([ 'user_id' => $user['id'], 'goods_id' => $goods_id, 'num' => $goods_num, 'type' => $goods['type'], 'addtime' => time(), ]); } if ($res) { return $this->renderSuccess("操作成功"); } else { return $this->renderError("操作失败"); } } /** * 删除收藏 */ public function delCollect(Request $request) { $user = $this->getUser(); $id = request()->param('id/d', 0); $info = Collect::field('id') ->where(['user_id' => $user['id']]) ->where(['id' => $id]) ->find(); if (!$info) { return $this->renderError("请求重复操作"); } $res = Collect::where(['id' => $info['id']])->delete(); if ($res) { return $this->renderSuccess("删除成功"); } else { return $this->renderError("删除失败"); } } /** * 抽奖统计 * @param Request $request *created by Admin at 2022/12/21 11:14 */ public function luck_draw_log(Request $request){ $id = $request->param('id'); $goods = Goodsmodel::where('id',$id)->find(); if (!$goods){ return $this->renderError("盒子不存在"); } $user_ids = OrderList::field('user_id') ->append(['userinfo']) ->where('goods_id',$goods['id']) ->group('user_id') ->paginate(20); foreach ($user_ids as $value){ $count = OrderList::field('user_id') ->where('goods_id',$goods['id']) ->where('user_id',$value['user_id']) ->count(); $value['count'] = $count; } return $this->renderSuccess("操作成功", $user_ids); } /* 宝箱详情 */ public function box_detail(Request $request){ $id = $request->param('id'); // $goods_num = request()->param('goods_num/d', 0); if(empty($id) ){ return $this->renderError("参数有误"); } $box_detail = GoodsList::where('id', '=', $id) ->where('shang_id', '=', 39) ->find(); if(empty($box_detail)){ return $this->renderError("宝箱不存在"); } $type = Goodsmodel::where(['id'=>$box_detail['goods_id']])->value('type'); if ($type == 1 || $type == 3 || $type == 5 || $type == 6) { $whe[] = ['num', '=', 1]; #因为是一番赏,所以有点区别 $id = GoodsList::where('goods_id', '=', $box_detail['goods_id']) ->where('prize_code','=',$box_detail['prize_code']) ->where('shang_id', '=', 39) ->where('num','=',1) ->value('id'); } elseif ($type == 2) { $whe[] = ['num', '=', 0]; } else { return $this->renderError('请求参数错误1'); } #所有奖品信息 $goods_list = GoodsList::field('goods_id,shang_id,title,imgurl,price,real_pro,sc_money,gn_type') ->append(['shang_info']) ->withAttr('imgurl', function($value, $data){ return imageUrl($value); }) ->where(['box_id' => $id]) ->where($whe) ->order('sort desc,shang_id asc,id asc') ->paginate(1000); foreach ($goods_list as &$value) { $value['shang_title'] = $value['shang_info']['title']; $value['shang_imgurl'] = $value['shang_info']['imgurl']; $value['shang_color'] = $value['shang_info']['color']; unset($value['shang_info']); } return $this->renderSuccess("请求成功", $goods_list); } } 这串代码的这个orderbuy方法报错未定义变量: price

大家在看

recommend-type

NBU备份一体机技术解决方案.docx

NBU备份一体机技术解决方案.docx
recommend-type

Kalam32 ESP32开发板作为无线WiFi / TCP ECG / Resp Monitor-项目开发

我们将最受欢迎的Arduino防护板之一ADS1292R ECG /呼吸防护板连接到ProtoCentral的新ESP32平台。
recommend-type

高频感应加热电源斩波器补偿电路的设计

本文在分析基于功率控制的Buck斩波器的小信号模型和反馈控制模式的基础上,探讨了反馈控制的传递函数和环路参数的设计。对于高频感应加热电源广泛应用的Buck斩波调功电路,设计了双极点、双零点补偿电路,补偿后的系统不仅提高了系统响应速度,而且消除了稳态误差,系统性能明显提高。实验结果证明了这种补偿电路的实用性和有效性,对高频感应加热电源的改进和研究具有很好的参考价值。
recommend-type

IFIX 4.5 MB1 驱动

 MB1:有两个版本,6.x 和 7.x 版,通过串行口连接所有支持 Modbus 串行通讯协议的设备。主要有 Modicon PLC 和其它控制仪表如:Honeywell UDC,UMC,Moore 的控制仪表等。支持 Mobus RTU 和 ASCII 两种通讯协议。当使用其与其它兼容设备通讯时,注意数据类型会与 Modicon 的数据类型有所差别。7.x 版本支持电话拨号连接和无线电连接。
recommend-type

tanner pro 集成电路设计和布局实战指导 配套 CD

《tanner pro 集成电路设计和布局实战指导》配套CD , 包含多有例子:有Layout和 code,学习非常方便。

最新推荐

recommend-type

双向CLLLC谐振闭环仿真设计与软开关技术实现:高压侧与低压侧波形优化及软开关性能研究 · 谐振波形优化

内容概要:本文介绍了双向CLLLC谐振技术及其在电力电子领域的应用,重点讨论了软开关和谐振波形的优化设计。文中首先简述了CLLLC谐振技术的基本原理,然后详细描述了在一个仿真环境下构建的双向CLLLC谐振系统,该系统能够在广泛的电压范围内(高压侧380-430V,低压侧40-54V)实现过谐振、欠谐振及满载轻载情况下的软开关。此外,文章展示了理想的谐振波形,并强调了软开关对减少开关损耗和电磁干扰的重要性。最后,文章提到可以通过参考相关文献深入了解系统的电路设计、控制策略和参数优化。 适合人群:从事电力电子设计的研究人员和技术工程师。 使用场景及目标:适用于需要理解和掌握双向CLLLC谐振技术及其仿真设计的专业人士,旨在帮助他们提升电源转换和能量回收系统的性能。 其他说明:文中提供的代码片段和图示均为假设的仿真环境,实际应用时需根据具体情况调整。建议参考相关文献获取更详尽的设计细节。
recommend-type

精选Java案例开发技巧集锦

从提供的文件信息中,我们可以看出,这是一份关于Java案例开发的集合。虽然没有具体的文件名称列表内容,但根据标题和描述,我们可以推断出这是一份包含了多个Java编程案例的开发集锦。下面我将详细说明与Java案例开发相关的一些知识点。 首先,Java案例开发涉及的知识点相当广泛,它不仅包括了Java语言的基础知识,还包括了面向对象编程思想、数据结构、算法、软件工程原理、设计模式以及特定的开发工具和环境等。 ### Java基础知识 - **Java语言特性**:Java是一种面向对象、解释执行、健壮性、安全性、平台无关性的高级编程语言。 - **数据类型**:Java中的数据类型包括基本数据类型(int、short、long、byte、float、double、boolean、char)和引用数据类型(类、接口、数组)。 - **控制结构**:包括if、else、switch、for、while、do-while等条件和循环控制结构。 - **数组和字符串**:Java数组的定义、初始化和多维数组的使用;字符串的创建、处理和String类的常用方法。 - **异常处理**:try、catch、finally以及throw和throws的使用,用以处理程序中的异常情况。 - **类和对象**:类的定义、对象的创建和使用,以及对象之间的交互。 - **继承和多态**:通过extends关键字实现类的继承,以及通过抽象类和接口实现多态。 ### 面向对象编程 - **封装、继承、多态**:是面向对象编程(OOP)的三大特征,也是Java编程中实现代码复用和模块化的主要手段。 - **抽象类和接口**:抽象类和接口的定义和使用,以及它们在实现多态中的不同应用场景。 ### Java高级特性 - **集合框架**:List、Set、Map等集合类的使用,以及迭代器和比较器的使用。 - **泛型编程**:泛型类、接口和方法的定义和使用,以及类型擦除和通配符的应用。 - **多线程和并发**:创建和管理线程的方法,synchronized和volatile关键字的使用,以及并发包中的类如Executor和ConcurrentMap的应用。 - **I/O流**:文件I/O、字节流、字符流、缓冲流、对象序列化的使用和原理。 - **网络编程**:基于Socket编程,使用java.net包下的类进行网络通信。 - **Java内存模型**:理解堆、栈、方法区等内存区域的作用以及垃圾回收机制。 ### Java开发工具和环境 - **集成开发环境(IDE)**:如Eclipse、IntelliJ IDEA等,它们提供了代码编辑、编译、调试等功能。 - **构建工具**:如Maven和Gradle,它们用于项目构建、依赖管理以及自动化构建过程。 - **版本控制工具**:如Git和SVN,用于代码的版本控制和团队协作。 ### 设计模式和软件工程原理 - **设计模式**:如单例、工厂、策略、观察者、装饰者等设计模式,在Java开发中如何应用这些模式来提高代码的可维护性和可扩展性。 - **软件工程原理**:包括软件开发流程、项目管理、代码审查、单元测试等。 ### 实际案例开发 - **项目结构和构建**:了解如何组织Java项目文件,合理使用包和模块化结构。 - **需求分析和设计**:明确项目需求,进行系统设计,如数据库设计、系统架构设计等。 - **代码编写和实现**:根据设计编写符合要求的代码,实现系统的各个模块功能。 - **测试和维护**:进行单元测试、集成测试,确保代码质量,对项目进行维护和升级。 ### 其他相关知识点 - **Java虚拟机(JVM)**:了解JVM的基本工作原理,包括类加载机制、内存管理、垃圾回收算法等。 - **常用Java框架**:比如Spring、Hibernate、MyBatis等,在实际开发中常常与Java基础结合使用,提高开发效率。 以上知识点可以作为学习Java案例开发的基础框架。在实际的开发实践中,开发者需要结合具体的项目需求,对这些知识点进行灵活运用。通过反复的案例实践,可以加深对Java编程的理解,并逐步提升开发技能。这份集锦可能包含的案例可能涉及上述知识点的具体应用,能够帮助学习者更好地理解理论与实践的结合,从而快速提升个人的Java开发能力。
recommend-type

【VASP报错深度解析】:5大技巧识别并永久解决离子距离太近警告

# 1. VASP软件简介及离子距离太近问题概述 ## 1.1 VASP软件简介 **VASP(Vienna Ab initio Simulation Package)** 是一款广泛应用于计算材料科学的软件,它基于密度泛函理论(DFT)计算固体、表面和分子的电子结构和性质。
recommend-type

npm error A complete log of this run can be found in: D:\Program Files\nodejs\node_cache\_logs\2025-04-20T15_11_51_454Z-debug-0.log

<think>好的,我需要帮助用户找到npm的错误调试日志位置,并解决他们遇到的npm错误。首先,用户已经提供了一个具体的日志路径:'D:\Program Files\nodejs\node_cache\_logs\2025-04-20T15_11_51_454Z-debug-0.log',但看起来这个路径可能有问题,因为日期是2025年,这可能是一个示例或输入错误。我需要确认正确的日志路径生成方式。 根据npm的默认配置,日志文件通常位于npm的缓存目录下的_logs文件夹中。默认情况下,Windows系统中npm的缓存路径是%AppData%\npm-cache,而日志文件会以当前日期和
recommend-type

深入理解内存技术文档详解

由于文件内容无法查看,仅能根据文件的标题、描述、标签以及文件名称列表来构建相关知识点。以下是对“内存详解”这一主题的详细知识点梳理。 内存,作为计算机硬件的重要组成部分,负责临时存放CPU处理的数据和指令。理解内存的工作原理、类型、性能参数等对优化计算机系统性能至关重要。本知识点将从以下几个方面来详细介绍内存: 1. 内存基础概念 内存(Random Access Memory,RAM)是易失性存储器,这意味着一旦断电,存储在其中的数据将会丢失。内存允许计算机临时存储正在执行的程序和数据,以便CPU可以快速访问这些信息。 2. 内存类型 - 动态随机存取存储器(DRAM):目前最常见的RAM类型,用于大多数个人电脑和服务器。 - 静态随机存取存储器(SRAM):速度较快,通常用作CPU缓存。 - 同步动态随机存取存储器(SDRAM):在时钟信号的同步下工作的DRAM。 - 双倍数据速率同步动态随机存取存储器(DDR SDRAM):在时钟周期的上升沿和下降沿传输数据,大幅提升了内存的传输速率。 3. 内存组成结构 - 存储单元:由存储位构成的最小数据存储单位。 - 地址总线:用于选择内存中的存储单元。 - 数据总线:用于传输数据。 - 控制总线:用于传输控制信号。 4. 内存性能参数 - 存储容量:通常用MB(兆字节)或GB(吉字节)表示,指的是内存能够存储多少数据。 - 内存时序:指的是内存从接受到请求到开始读取数据之间的时间间隔。 - 内存频率:通常以MHz或GHz为单位,是内存传输数据的速度。 - 内存带宽:数据传输速率,通常以字节/秒为单位,直接关联到内存频率和数据位宽。 5. 内存工作原理 内存基于电容器和晶体管的工作原理,电容器存储电荷来表示1或0的状态,晶体管则用于读取或写入数据。为了保持数据不丢失,动态内存需要定期刷新。 6. 内存插槽与安装 - 计算机主板上有专用的内存插槽,常见的有DDR2、DDR3、DDR4和DDR5等不同类型。 - 安装内存时需确保兼容性,并按照正确的方向插入内存条,避免物理损坏。 7. 内存测试与优化 - 测试:可以使用如MemTest86等工具测试内存的稳定性和故障。 - 优化:通过超频来提高内存频率,但必须确保稳定性,否则会导致数据损坏或系统崩溃。 8. 内存兼容性问题 不同内存条可能由于制造商、工作频率、时序、电压等参数的不匹配而产生兼容性问题。在升级或更换内存时,必须检查其与主板和现有系统的兼容性。 9. 内存条的常见品牌与型号 诸如金士顿(Kingston)、海盗船(Corsair)、三星(Samsung)和芝奇(G.Skill)等知名品牌提供多种型号的内存条,针对不同需求的用户。 由于“内存详解.doc”是文件标题指定的文件内容,我们可以预期在该文档中将详细涵盖以上知识点,并有可能包含更多的实践案例、故障排查方法以及内存技术的最新发展等高级内容。在实际工作中,理解并应用这些内存相关的知识点对于提高计算机性能、解决计算机故障有着不可估量的价值。
recommend-type

【机械特性分析进阶秘籍】:频域与时域对比的全面研究

# 1. 机械特性分析的频域与时域概述 ## 1.1 频域与时域分析的基本概念 机械特性分析是通
recommend-type

dslicsrv安装报错Too many errors

<think>好的,用户遇到了安装dslicsrv时出现“Too many errors”的问题,需要帮助解决。首先,我需要明确dslicsrv是什么。可能是指某个特定的软件服务,但根据常见软件库和搜索引擎的信息,没有直接对应的结果。可能是拼写错误,或者是某个特定领域的专有软件?比如,可能与Dell的某个服务有关?例如,Dell System License Manager Service(dsLicSvc)可能更接近。假设用户可能拼写错误,将dslicsrv理解为dsLicSvc,即Dell的系统许可证管理服务。 接下来,用户遇到的错误是安装时出现“Too many errors”,这通常
recommend-type

深入解析Pro Ajax与Java技术的综合应用框架

根据提供的文件信息,我们可以推断出一系列与标题《Pro Ajax and Java》相关的IT知识点。这本书是由Apress出版,关注的是Ajax和Java技术。下面我将详细介绍这些知识点。 ### Ajax技术 Ajax(Asynchronous JavaScript and XML)是一种无需重新加载整个页面即可更新网页的技术。它通过在后台与服务器进行少量数据交换,实现了异步更新网页内容的目的。 1. **异步通信**:Ajax的核心是通过XMLHttpRequest对象或者现代的Fetch API等技术实现浏览器与服务器的异步通信。 2. **DOM操作**:利用JavaScript操作文档对象模型(DOM),能够实现页面内容的动态更新,而无需重新加载整个页面。 3. **数据交换格式**:Ajax通信中常使用的数据格式包括XML和JSON,但近年来JSON因其轻量级和易用性更受青睐。 4. **跨浏览器兼容性**:由于历史原因,实现Ajax的JavaScript代码需要考虑不同浏览器的兼容性问题。 5. **框架和库**:有许多流行的JavaScript库和框架支持Ajax开发,如jQuery、Dojo、ExtJS等,这些工具简化了Ajax的实现和数据操作。 ### Java技术 Java是一种广泛使用的面向对象编程语言,其在企业级应用、移动应用开发(Android)、Web应用开发等方面有着广泛应用。 1. **Java虚拟机(JVM)**:Java程序运行在Java虚拟机上,这使得Java具有良好的跨平台性。 2. **Java标准版(Java SE)**:包含了Java的核心类库和API,是Java应用开发的基础。 3. **Java企业版(Java EE)**:为企业级应用提供了额外的API和服务,如Java Servlet、JavaServer Pages(JSP)、Enterprise JavaBeans(EJB)等。 4. **面向对象编程(OOP)**:Java是一种纯粹的面向对象语言,它的语法和机制支持封装、继承和多态性。 5. **社区和生态系统**:Java拥有庞大的开发者社区和丰富的第三方库和框架,如Spring、Hibernate等,这些资源极大丰富了Java的应用范围。 ### 结合Ajax和Java 在结合使用Ajax和Java进行开发时,我们通常会采用MVC(模型-视图-控制器)架构模式,来构建可维护和可扩展的应用程序。 1. **服务器端技术**:Java经常被用来构建服务器端应用逻辑。例如,使用Servlet来处理客户端的请求,再将数据以Ajax请求的响应形式返回给客户端。 2. **客户端技术**:客户端的JavaScript(或使用框架库如jQuery)用于发起Ajax请求,并更新页面内容。 3. **数据格式**:Java后端通常会使用JSON或XML格式与Ajax进行数据交换。 4. **安全性**:Ajax请求可能涉及敏感数据,因此需要考虑如跨站请求伪造(CSRF)等安全问题。 5. **性能优化**:合理使用Ajax可以提升用户体验,但同时也需要注意对服务器和网络的负载,以及客户端脚本的执行性能。 ### 出版信息及文件信息 《Pro Ajax and Java》由Apress出版社出版,通常这种出版物会包含丰富的实例代码、开发指导、最佳实践以及相关的技术讨论。它旨在帮助开发者深化对Ajax和Java技术的理解和应用能力。 文件名“Apress.Pro.Ajax.and.Java.Frameworks.Jul.2006.HAPPY.NEW.YEAR.pdf”暗示了这份文档可能是一本专业的技术书籍。从文件名可以看出,该书还可能包含了框架使用方面的内容,并且是2006年出版的。标题中的“HAPPY.NEW.YEAR”可能仅仅是为了庆祝新年而加入的非标准部分。 总结而言,了解Ajax和Java的结合使用,不仅需要掌握两种技术的基本原理和使用方法,还要熟悉如何将它们整合到实际项目中,解决可能出现的技术挑战,从而构建功能强大且用户友好的Web应用。
recommend-type

【频域分析深度解读】:揭秘机械系统分析中的实用应用

# 1. 频域分析基础理论 频域分析是信号处理领域的一个重要分支,其核心在于研究信号在频率维度上的特性。与时域分析不同,频域分析关注的是信号频率成分的组成,这允许我们以一种直观的方式识别和处理信号中的特定频率特征。通过对信号进行傅里叶变换,原始的时域信号可以被转换为频域信号,这样就可以清晰地显示出各频率成分的幅度和相位信息。这种分析手段对于信号去噪、特征提取、压缩编码等应用场景至关重
recommend-type

openmv与stm32通信的时候,openmv的vin接5v会出问题吗

<think>我们正在处理用户关于OpenMV与STM32通信时,将OpenMV的VIN引脚连接到5V是否会引发问题。 根据引用[3]中的信息,AMG8833传感器在STM32上使用时,由单片机的3.3V和GND引脚供电。同时,引用[3]提到OpenMV相机作为配套计算机的情况,但用户的问题具体是OpenMV的VIN引脚接5V的问题。 我们需要明确OpenMV的电源要求: - OpenMV Cam的VIN引脚是电源输入引脚,其可接受电压范围通常在3.6V至5V。因此,5V是在可接受范围内的。 但是,我们还需要注意: 1. OpenMV Cam内部有稳压电路,会将输入电压降到3.3V