| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 | 
							- <?php
 
- /**
 
-  * Order.php  UTF-8
 
-  * 订单处理
 
-  *
 
-  * @date    : 2020/9/15 10:27
 
-  *
 
-  * @license 这不是一个自由软件,未经授权不许任何使用和传播。
 
-  * @author  : chenbingling <cbl@huosdk.com>
 
-  * @version : H5IOS 1.0
 
-  */
 
- namespace huosdk\h5ios\core\controller;
 
- use huo\controller\pay\PaySwitch;
 
- use huo\controller\pay\Sdk;
 
- use huo\controller\request\Channel;
 
- use huo\controller\request\Device;
 
- use huo\controller\request\Game as GameRq;
 
- use huo\controller\request\Mem;
 
- use huo\controller\request\Order as OrderRq;
 
- use huo\controller\request\Role;
 
- use huoIdentify\controller\Pay;
 
- use huolib\status\CommonStatus;
 
- use huosdk\h5ios\core\constant\GameConst;
 
- use huosdk\h5ios\core\constant\OrderConst;
 
- use huosdk\h5ios\core\constant\PaywayConst;
 
- use huosdk\h5ios\core\model\GameModel;
 
- use huosdk\h5ios\core\model\GamePriceModel;
 
- use huosdk\h5ios\core\model\PayAppleModel;
 
- use huosdk\h5ios\core\status\GameStatus;
 
- use huosdk\h5ios\core\status\OrderStatus;
 
- class Order extends Base {
 
-     public function __construct() {
 
-         parent::__construct();
 
-     }
 
-     /**
 
-      * 预下单
 
-      *
 
-      * @param OrderRq $order
 
-      * @param Role    $role
 
-      * @param Mem     $mem
 
-      * @param GameRq  $game_rq
 
-      * @param Channel $channel
 
-      * @param Device  $device
 
-      *
 
-      * @return array|bool|string
 
-      */
 
-     public function preorder(OrderRq $order, Role $role, Mem $mem, GameRq $game_rq, Channel $channel, Device $device) {
 
-         $_vb_id = $game_rq->getVbId();
 
-         $_vb_info = (new GameModel())->getInfoById($_vb_id);
 
-         $_classify = get_val($_vb_info, 'classify', 0);
 
-         if (GameConst::GAME_IOS_SWITCH_H5 != $_classify) {
 
-             $_code = GameStatus::GAME_VB_NOT_EXIST;
 
-             return $this->huoError($_code, GameStatus::getMsg($_code));
 
-         }
 
-         $_game_product_id = $order->getProductId();
 
-         $_game_price_model = new GamePriceModel();
 
-         $_apple_product_id = $_game_price_model->getProductByAppChProduct($_vb_id, $_game_product_id);
 
-         if (!empty($_apple_product_id)) {
 
-             $order->setProductId($_apple_product_id);
 
-         }
 
-         $_price = $_game_price_model->getPriceByAppProduct($_vb_id, $order->getProductId());
 
-         $_product_price = $order->getProductPrice();
 
-         if (!empty($_price) && $_price != $_product_price) {
 
-             $order->setProductPrice($_price);
 
-         }
 
-         $order->setPayway(PaywayConst::PAYWAY_APPLE);
 
-         $_order = new Sdk();
 
-         /* 判断支付切换 */
 
-         $_pay_check = (new PaySwitch())->getPaySwitch(
 
-             $order, $role, $mem, $game_rq, $channel, $device
 
-         );
 
-         $_preorder_rs = $_order->preorder($order, $role, $mem, $game_rq, $channel, $device);
 
-         if (OrderStatus::NO_ERROR != $_preorder_rs['code']) {
 
-             return $this->huoReturn($_preorder_rs);
 
-         }
 
-         $_order_data = $_preorder_rs['data'];
 
-         $_order_id = $_order_data['order_id'];
 
-         $_pay_token = $order->genPayToken($_order_id);
 
-         $_rdata['order_id'] = $_order_id;
 
-         $_rdata['pay_token'] = $_pay_token;
 
-         $_rdata['check'] = $_pay_check;
 
-         $_rdata['pay_url'] = '';
 
-         $_rdata['product_id'] = $_apple_product_id;
 
-         /* 支付限制校验 */
 
-         $_rdata['url'] = (new Pay())->checkLimit($mem->getMemId(), $game_rq->getHAppId(), $_order_data['amount']);
 
-         /* 苹果下单 不切换 直接插入苹果订单表 */
 
-         if (OrderConst::PAY_SWITCH_NO == $_pay_check) {
 
-             $_data['order_id'] = $_order_id;
 
-             $_data['mem_id'] = $mem->getMemId();
 
-             $_data['mg_mem_id'] = $mem->getMgMemId();
 
-             $_data['apple_id'] = $game_rq->getAppleId();
 
-             $_data['product_id'] = $_apple_product_id;
 
-             $_data['idfv'] = $device->getMac();
 
-             $_data['idfa'] = $device->getDeviceId();
 
-             (new PayAppleModel())->addData($_data);
 
-         }
 
-         $_code = CommonStatus::NO_ERROR;
 
-         return $this->huoSuccess($_code, CommonStatus::getMsg($_code), $_rdata);
 
-     }
 
- }
 
 
  |