123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- <?php
- namespace app\api\controller;
- use AlibabaCloud\Client\AlibabaCloud;
- use AlibabaCloud\Client\Exception\ClientException;
- use AlibabaCloud\Client\Exception\ServerException;
- use AliPay\Scan;
- use app\common\model\StoreGoods;
- use app\common\model\StoreGoodsItem;
- use app\common\model\User;
- use app\common\model\UserMessage;
- use app\common\model\UserTrack;
- use think\Db;
- use think\Exception;
- use EasyWeChat\Factory;
- use function AlibabaCloud\Client\value;
- /**
- * @title 其他接口
- * @controller General
- * @group base
- */
- class General extends Base
- {
- public function initialize()
- {
- parent::initialize();
- parent::checkLogin();
- }
- /**
- * @title 发送短信验证码
- * @desc 发送短信验证码
- * @author qc
- * @url /api/General/sendSms
- * @method POST
- * @tag 短信验证码
- * @param name:phone type:int require:1 default:-- desc:要获取验证码的手机号
- * @return name:code type:string default:-- desc:验证码
- */
- public function sendSms(){
- $phone = input('post.phone');
- if(empty($phone)) $this ->error('参数错误');
- $code = rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9);
- AlibabaCloud::accessKeyClient('LTAI5tEEfowhMkLu8auo6n6G', 'ch94CL3TEwNAxXNREweZl3gfk8jQ84')
- ->regionId('cn-hangzhou')->asDefaultClient();
- try {
- $result = AlibabaCloud::rpc()
- ->product('Dysmsapi')
- ->version('2017-05-25')
- ->action('SendSms')
- ->method('POST')
- ->host('dysmsapi.aliyuncs.com')
- ->options([
- 'query' => [
- 'RegionId' => "cn-hangzhou",
- 'PhoneNumbers' => $phone,
- 'SignName' => "康养食品",
- 'TemplateCode' => "SMS_241155218",
- 'TemplateParam' => json_encode(array("code"=>$code)),
- ],
- ])->request();
- $result = $result->toArray();
- if($result['Code'] == "OK") {
- $sms_data = array(
- 'phone'=>$phone,
- 'code'=>$code,
- 'result'=>$result['Message']
- );
- Db::name('store_member_sms')->insert($sms_data);
- $this->success('发送成功',$code);
- }else{
- $this->error('发送失败');
- }
- } catch (ClientException $e) {
- echo $e->getErrorMessage() . PHP_EOL;
- } catch (ServerException $e) {
- echo $e->getErrorMessage() . PHP_EOL;
- }
- }
- /**
- * @title 获取物流详情
- * @desc 获取物流详情
- * @author qc
- * @url /api/General/deliveryDetails
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @param name:send_no type:string require:1 default:-- desc:物流单号(订单express_send_no字段)
- * @return name:number type:string default:-- desc:单号
- * @return name:type type:string default:-- desc:快递类型
- * @return name:list type:array default:-- desc:数据列表
- * @return name:list.time type:string default:-- desc:时间
- * @return name:list.status type:string default:-- desc:内容
- * @return name:deliverystatus type:int default:-- desc:0:快递收件(揽件)1.在途中2.正在派件3.已签收4.派送失败5.疑难件6.退件签收
- * @return name:issign type:int default:-- desc:是否签收(1.是否签收)
- * @return name:expName type:string default:-- desc:快递公司名称
- * @return name:expSite type:string default:-- desc:快递公司官网
- * @return name:expPhone type:string default:-- desc:快递公司电话
- * @return name:courier type:string default:-- desc:快递员 或 快递站(没有则为空)
- * @return name:courierPhone type:string default:-- desc:快递员电话 (没有则为空)
- * @return name:updateTime type:string default:-- desc:快递轨迹信息最新时间
- * @return name:takeTime type:string default:-- desc:发货到收货消耗时长 (截止最新轨迹)
- * @return name:logo type:string default:-- desc:快递公司LOGO
- */
- public function deliveryDetails(){
- $send_no = input('get.send_no');
- $data = get_delivery($send_no);
- $this->success('ok',$data);
- }
- /**
- * @title 获取足迹日历信息
- * @desc 获取足迹日历信息
- * @author qc
- * @url /api/General/getCalendar
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @param name:num type:int default:7 desc:时间(最近几天,默认7天)
- * @return name:day_time type:string default:-- desc:时间
- * @return name:week_day type:string default:-- desc:周几
- */
- public function getCalendar()
- {
- $num = input('num',7);
- $calendar = get_calendar($num);
- $this->success('ok',['list'=>$calendar]);
- }
- /**
- * @title 获取足迹
- * @desc 获取足迹
- * @author qc
- * @url /api/General/getUserTrack
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @param name:type type:int default:1 desc:查询类型1商品2资讯
- * @param name:day_time type:string default:-- desc:查询时间(2022-04-22)
- * @return name:id type:int default:-- desc:足迹id
- * @return name:rel_id type:float default:-- desc:浏览的id(商品类型是商品id,资讯类型是资讯的id)
- * @return name:low_price type:float default:-- desc:商品最低价
- * @return name:max_price type:float default:-- desc:商品下划线价格
- * @return name:goods_cover type:string default:-- desc:商品封面
- * @return name:goods_name type:string default:-- desc:商品名
- * @return name:article_title type:string default:-- desc:资讯标题
- * @return name:article_cover type:string default:-- desc:资讯封面
- * @return name:video_url type:string default:-- desc:视频地址
- * @return name:read_num type:int default:-- desc:阅读量
- * @return name:article_type type:int default:-- desc:资讯类型(1图文,2视频)
- */
- public function getUserTrack()
- {
- $type = input('get.type',1);
- $day_time = input('get.day_time',date('Y-m-d'));
- $where = [];
- $where[] = ['t.user_id','=',$this->user_id];
- $where[] = ['t.type','=',$type];
- $where[] = ['t.year','=',date('Y',strtotime($day_time))];
- $where[] = ['t.month','=',date('m',strtotime($day_time))];
- $where[] = ['t.day','=',date('d',strtotime($day_time))];
- if($type == 1){
- $list = UserTrack::field('t.*,g.low_price,g.name goods_name,g.cover goods_cover')->where($where)
- ->alias('t')
- ->leftJoin('StoreGoods g','t.rel_id = g.id')
- ->order('t.update_int desc')
- ->select()->toArray();
- foreach ($list as &$v){
- $v['max_price'] = StoreGoodsItem::where('goods_id',$v['rel_id'])->max('original_price');
- }
- }else{
- $list = UserTrack::field('t.*,i.title article_title,i.cover article_cover,i.video_url,i.type article_type,i.read_num')->where($where)
- ->alias('t')
- ->leftJoin('InformationArticle i','t.rel_id = i.id')
- ->order('t.update_int desc')
- ->select()->toArray();
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 删除足迹
- * @desc 删除足迹
- * @author qc
- * @url /api/General/delUserTrack
- * @method POST
- * @header name:Authorization require:1 desc:Token
- * @param name:ids type:string default:-- desc:足迹id(多个用逗号隔开)
- */
- public function delUserTrack()
- {
- $ids = input('post.ids');
- UserTrack::where('id','in',$ids)->delete();
- $this->success('删除成功');
- }
- }
|