GoodsModel.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace common\globals;
  3. use common\globals\BaseGlobal;
  4. use common\globals\GlobalInvoke;
  5. use common\models\common\AddonsInvoker;
  6. use common\models\mall\MallAddons;
  7. class GoodsModel extends BaseGlobal
  8. {
  9. ##########################################################################################################
  10. # 模式配置返回数据格式[
  11. # 'Agent' => [
  12. # 'commission' => [
  13. # 'is_enable' => 1,
  14. # 'commission_type' => 1,
  15. # 'is_percent_team' => 1,
  16. # 'detail' => [
  17. # '1' => [
  18. # 'id' => 1,
  19. # 'agent_team_prize' => 1,
  20. # 'agent_over_prize' => 1,
  21. # ],
  22. # '2' => [
  23. # 'id' => 2,
  24. # 'agent_team_prize' => 1,
  25. # 'agent_over_prize' => 1,
  26. # ],
  27. # ],
  28. # ],
  29. # 'score' => [
  30. # 'is_enable' => 0,
  31. # 'item_type' => 0,
  32. # 'is_percent_team' => 0,
  33. # 'detail' => [
  34. # '3' => [
  35. # 'id' => 3,
  36. # 'agent_team_prize' => 1,
  37. # 'agent_over_prize' => 1,
  38. # ],
  39. # ],
  40. # ],
  41. # ],
  42. # 'Distribution' => [
  43. # 'commission' => [
  44. # 'is_enable' => 1,
  45. # 'commission_type' => 1,
  46. # 'is_percent_team' => 1,
  47. # 'detail' => [
  48. # '1' => [
  49. # 'id' => 1,
  50. # 'agent_team_prize' => 1,
  51. # 'agent_over_prize' => 1,
  52. # ],
  53. # ]
  54. # ],
  55. # ]
  56. #];
  57. ##########################################################################################################
  58. /**
  59. * 获取模式列表内容
  60. * @param [type] $invokes
  61. * @param array $params
  62. * @return array
  63. */
  64. public function getGoodsModel($invokes, $params = [])
  65. {
  66. $return = [];
  67. foreach ($invokes as $invoke) {
  68. try {
  69. if (!MallAddons::isInstall($params['mall_id'], $invoke['addons_name'])) continue;
  70. if (class_exists($invoke['class']) && method_exists($invoke['class'], 'getDetail') == false) {
  71. unset($params['with']);
  72. } else {
  73. $params['with'] = 'detail';
  74. }
  75. $data = $this->invoke($invoke['class'], $invoke['method'], $params);
  76. $is_success = $this->validateInvokeReturn($params['invoke_id'], $data);
  77. if ($is_success) {
  78. if(empty($data)){
  79. continue;
  80. }
  81. } else {
  82. throw new \Exception('结果数据格式校验未通过');
  83. }
  84. $return[$invoke['addons_name']] = $data;
  85. } catch (\Exception $e) {
  86. \Yii::error('全局调用(INVOKE_GET_WITHDRAW_COND)出错:' . $invoke['class'] . '->' . $invoke['method'] . 'msg:' . $e->getMessage());
  87. continue;
  88. }
  89. }
  90. return $return;
  91. }
  92. /**
  93. * 验证调用结果
  94. * @param [type] $return
  95. * @return boolean
  96. */
  97. protected function validateGetGoodsModel($return = null): bool
  98. {
  99. return true;
  100. }
  101. }