register_event_type = 'register'; $this->charge_event_type = 'ec_buy'; $this->add_desk_event_type = 'activate'; } public function getRegisterQueryParams(ReportUserBindRecord $user): array { return []; } public function getChargeQueryParams(ReportUserBindRecord $user, float $amount): array { //百度回传链接 $this->report_url = $user->link; //替换a_type的值 $this->getReplaceUrl('a_type',$this->charge_event_type); //替换a_value的值 $this->getReplaceUrl('a_value',$amount * 100); //百度akey $akey = $this->getBaiduAkey($user->uid); $this->report_url .= '&sign=' . md5($this->report_url.$akey); return []; } /** * 替换url中的操作类型和值 * @param $type * @param $value * @return void */ protected function getReplaceUrl($type, $value) { //获取$type的值 $type_value = $this->matchItemInUrl($type,$this->report_url); //替换$type的值 $this->report_url = str_replace($type.$type_value,$type.$value,$this->report_url); } /** * 获取百度akey * @param $uid * @return mixed|string */ protected function getBaiduAkey($uid) { //获取派单id $send_order_id = Order::where('uid',$uid)->value('send_order_id'); //获取派单平台配置 $extra_config = QappSendOrders::where('send_order_id',$send_order_id)->value('extra_config'); if(isset($extra_config) && !empty($extra_config)){ $extra_config = json_decode($extra_config,true); return isset($extra_config['baidu_akey']) ? $extra_config['baidu_akey'] : ''; } return ''; } /** * 获取查询字符串的值 * @param string $item * @param string $url * @return mixed|string */ protected function matchItemInUrl(string $item, string $url) { preg_match('/&?' . $item . '=([^&\s]+)&?/i', $url, $arr); if ($arr) { return $arr[1]; } return ''; } }