1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace App\Modules\OrangeSite\Services;
- use App\Modules\Trace\TraceContext;
- use RuntimeException;
- class OrangeSiteRechargeReportCheckContext
- {
- /**
- * @var string 平台,橙子建站
- */
- public $platform = 'orange';
- /**
- * @var 订单的用户 表 users 记录
- */
- public $user;
- /**
- * @var 订单信息 表 orders 记录
- */
- public $order;
- /**
- * @var 订单关联站点的回传配置信息 表 channel_callback_configs 记录
- */
- public $channelCallbackConfig;
- /**
- * @var array 判定过程中的附带信息.
- * <pre>
- * [
- * 'configRate' => 32, // 当前站点设置的回传比例为 32%
- * 'reportRate' => 43, // 当前站点实际的回传比例[在本单回传之前的比例] 为 43%
- * ]
- * </pre>
- */
- public $reportInfo;
- /**
- * @var array 根据配置,对当前订单的回传与否的判定结果
- * <pre>
- * [
- * 'result' => true|false , // true-表示订单回传,false-订单不回传
- * 'type' => 'xxx', // 不回传的原因:amount_filter-金额过滤
- * 'content' => 'xxx', // 具体的提示信息
- * 'needRecord' => true | false , // true-需要记录到report_user_charge_records表中,false-不记录
- * ]
- * <pre>
- */
- public $result;
- /**
- * @var TraceContext traceInfo 信息
- */
- public $traceContext;
- public function __construct($user, $order, $channelCallbackConfig, $traceContext, $channelSettingRate = 0)
- {
- $this->user = $user;
- $this->order = $order;
- $this->channelCallbackConfig = $channelCallbackConfig;
- $this->traceContext = $traceContext;
- $this->result = [
- 'result' => true,
- 'needRecord' => true,
- ];
- $this->reportInfo = [
- 'configRate' => $channelSettingRate,
- 'reportRate' => 0
- ];
- }
- public function checkNecessaryInfo()
- {
- if (!$this->user) {
- throw new RuntimeException('用户信息不存在');
- }
- if (!$this->order) {
- throw new RuntimeException('订单信息不存在');
- }
- if (!$this->channelCallbackConfig) {
- throw new RuntimeException('站点回传配置信息不存在');
- }
- }
- }
|