123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- <?php
- /**
- * ApplePayQueue.php UTF-8
- * 苹果支付队列
- *
- * @date : 2018/6/11 19:58
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @version : HUOSDK 8.0
- */
- namespace huo\controller\queue;
- use huo\controller\common\Base;
- use huolib\queue\constant\ClassConst;
- use huolib\queue\constant\JobConst;
- use huolib\status\CommonStatus;
- use think\Queue;
- class ApplePayQueue extends Base {
- protected $param = [];
- protected $job_class = '';
- protected $job_name = '';
- public function __construct($apple_id = '') {
- $this->job_class = ClassConst::CLASS_APPLE_PAY_FIRE;
- $this->job_name = JobConst::JOB_APPLE_PAY;
- $this->param['ts'] = time();
- $this->setAppleId($apple_id);
- }
- /**
- * 返回数据
- *
- * @param int $code
- * @param array $data
- *
- * @return array
- */
- protected function retSucMsg($code = CommonStatus::NO_ERROR, $data = []) {
- /* 数据录入LOG */
- $this->param['queue'] = '1';
- return $this->huoSuccess($code, '', $data);
- }
- /**
- * 返回数据
- *
- * @param $code
- *
- * @return array|mixed
- */
- protected function retErrMsg($code = CommonStatus::PUSH_QUEUE_ERROR) {
- /* 数据录入LOG */
- $this->param['queue'] = '0';
- return $this->huoError($code);
- }
- public function setApplePayQueue(
- $order_id, $trans_id, $receipt_data = null, $is_sandbox = false, $idfv = '', $apple_id = ''
- ) {
- $this->setOrderId($order_id);
- $this->setTransId($trans_id);
- $this->setReceiptData($receipt_data);
- $this->setIsSandbox($is_sandbox);
- $this->setIdfv($idfv);
- $this->setAppleId($apple_id);
- return $this->pushQueue();
- }
- /**
- * 入队列
- *
- * @return array
- */
- protected function pushQueue() {
- if (class_exists('think\\Queue')) {
- $_is_pushed = Queue::push($this->job_class, $this->param, $this->job_name);
- if ($_is_pushed !== false) {
- return $this->retErrMsg();
- }
- }
- return $this->retSucMsg();
- }
- /**
- * 设置平台订单ID
- *
- * @param string $order_id 平台订单ID
- */
- public function setOrderId($order_id) {
- $this->param['order_id'] = $order_id;
- }
- /**
- * 设置苹果订单ID
- *
- * @param string $trans_id 苹果订单ID
- */
- public function setTransId($trans_id) {
- $this->param['trans_id'] = $trans_id;
- }
- /**
- * 设置苹果支付票据
- *
- * @param string $receipt_data 苹果支付票据
- */
- public function setReceiptData($receipt_data) {
- $this->param['receipt_data'] = $receipt_data;
- }
- /**
- * 设置是否沙盒环境
- *
- * @param bool $is_sandbox 是否是沙盒环境
- */
- public function setIsSandbox($is_sandbox) {
- $this->param['is_sandbox'] = $is_sandbox;
- }
- /**
- * 设置IDFV
- *
- * @param string $idfv 苹果IDFV
- */
- public function setIdfv($idfv) {
- $this->param['idfv'] = $idfv;
- }
- /**
- * 设置苹果应用ID
- *
- * @param string $apple_id 苹果应用ID
- */
- public function setAppleId($apple_id) {
- $this->param['apple_id'] = $apple_id;
- }
- /**
- * @return string
- */
- public function getJobClass() {
- return $this->job_class;
- }
- /**
- * @param string $job_class
- */
- public function setJobClass($job_class) {
- $this->job_class = $job_class;
- }
- /**
- * @return string
- */
- public function getJobName() {
- return $this->job_name;
- }
- /**
- * @param string $job_name
- */
- public function setJobName($job_name) {
- $this->job_name = $job_name;
- }
- }
|