| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- namespace common\globals;
- use common\globals\BaseGlobal;
- use common\globals\GlobalInvoke;
- use common\models\common\AddonsInvoker;
- use common\models\mall\MallAddons;
- class GoodsModel extends BaseGlobal
- {
- ##########################################################################################################
- # 模式配置返回数据格式[
- # 'Agent' => [
- # 'commission' => [
- # 'is_enable' => 1,
- # 'commission_type' => 1,
- # 'is_percent_team' => 1,
- # 'detail' => [
- # '1' => [
- # 'id' => 1,
- # 'agent_team_prize' => 1,
- # 'agent_over_prize' => 1,
- # ],
- # '2' => [
- # 'id' => 2,
- # 'agent_team_prize' => 1,
- # 'agent_over_prize' => 1,
- # ],
- # ],
- # ],
- # 'score' => [
- # 'is_enable' => 0,
- # 'item_type' => 0,
- # 'is_percent_team' => 0,
- # 'detail' => [
- # '3' => [
- # 'id' => 3,
- # 'agent_team_prize' => 1,
- # 'agent_over_prize' => 1,
- # ],
- # ],
- # ],
- # ],
- # 'Distribution' => [
- # 'commission' => [
- # 'is_enable' => 1,
- # 'commission_type' => 1,
- # 'is_percent_team' => 1,
- # 'detail' => [
- # '1' => [
- # 'id' => 1,
- # 'agent_team_prize' => 1,
- # 'agent_over_prize' => 1,
- # ],
- # ]
- # ],
- # ]
- #];
- ##########################################################################################################
- /**
- * 获取模式列表内容
- * @param [type] $invokes
- * @param array $params
- * @return array
- */
- public function getGoodsModel($invokes, $params = [])
- {
- $return = [];
- foreach ($invokes as $invoke) {
- try {
- if (!MallAddons::isInstall($params['mall_id'], $invoke['addons_name'])) continue;
- if (class_exists($invoke['class']) && method_exists($invoke['class'], 'getDetail') == false) {
- unset($params['with']);
- } else {
- $params['with'] = 'detail';
- }
- $data = $this->invoke($invoke['class'], $invoke['method'], $params);
- $is_success = $this->validateInvokeReturn($params['invoke_id'], $data);
- if ($is_success) {
- if(empty($data)){
- continue;
- }
- } else {
- throw new \Exception('结果数据格式校验未通过');
- }
- $return[$invoke['addons_name']] = $data;
- } catch (\Exception $e) {
- \Yii::error('全局调用(INVOKE_GET_WITHDRAW_COND)出错:' . $invoke['class'] . '->' . $invoke['method'] . 'msg:' . $e->getMessage());
- continue;
- }
- }
- return $return;
- }
- /**
- * 验证调用结果
- * @param [type] $return
- * @return boolean
- */
- protected function validateGetGoodsModel($return = null): bool
- {
- return true;
- }
- }
|