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;
- class General extends Base
- {
- public function initialize()
- {
- parent::initialize();
- parent::checkLogin();
- }
-
- 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;
- }
- }
-
- public function deliveryDetails(){
- $send_no = input('get.send_no');
- $data = get_delivery($send_no);
- $this->success('ok',$data);
- }
-
- public function getCalendar()
- {
- $num = input('num',7);
- $calendar = get_calendar($num);
- $this->success('ok',['list'=>$calendar]);
- }
-
- 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]);
- }
-
- public function delUserTrack()
- {
- $ids = input('post.ids');
- UserTrack::where('id','in',$ids)->delete();
- $this->success('删除成功');
- }
- }
|