end_time)-time(); if($v>=0){ return $v; } return 0; } /** * 一对多关联表 */ public function help(){ return $this->hasMany('GroupBuyLbHelp', 'join_id')->where('pay_state','in',[0,1]) ->where('has_canceled',0) ->order('id', 'asc'); } public function getHcCountAttr(){ $v = $this->people_count - $this->help_count; if($v>=0){ return $v; } return 0; } /** * 关联用户表 * @return \think\model\relation\BelongsTo */ public function user() { $module = self::getCalledModule(); return $this->belongsTo("app\\{$module}\\model\\User"); } // //下单并发起拼团,拼团成功后发送 // public function activityEnd($openid){ // $template_id = 'M4Nw40B4Hpn4C8NkCiBDajEqz1St_CRRjGlkxDOVP1g'; // $weixinToken = (new Wechat)->weixinTokenCache(); // $accessToken = $weixinToken['access_token']; // $url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" . $accessToken; // $data['touser']= $openid; // $data['template_id'] = $template_id; // $data['page'] = 'pages/index/index'; // $data['miniprogram_state'] = env('APP_ENV')=="PRODUCT"?'formal':'developer'; // $data['data']= ['thing1'=>["value"=>"拼团有礼"],'thing3'=>["value"=>'活动已结束,去看看活动结果']]; // $res = post_curl($url,json_encode($data)); // return $res; // } }