Config.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\fenxiao\api\controller;
  11. use app\api\controller\BaseApi;
  12. use addon\fenxiao\model\Config as ConfigModel;
  13. use app\model\goods\Goods;
  14. use app\model\system\Document;
  15. /**
  16. * 分销相关配置
  17. */
  18. class Config extends BaseApi
  19. {
  20. /**
  21. * 提现配置
  22. */
  23. public function withdraw()
  24. {
  25. $config = new ConfigModel();
  26. $res = $config->getFenxiaoWithdrawConfig($this->site_id);
  27. return $this->response($this->success($res['data']['value']));
  28. }
  29. /**
  30. * 文字设置
  31. * @return false|string
  32. */
  33. public function words()
  34. {
  35. $config = new ConfigModel();
  36. $res = $config->getFenxiaoWordsConfig($this->site_id);
  37. return $this->response($this->success($res['data']['value']));
  38. }
  39. /**
  40. * 申请协议
  41. * @return false|string
  42. */
  43. public function agreement()
  44. {
  45. $config = new ConfigModel();
  46. $agreement = $config->getFenxiaoAgreementConfig($this->site_id);
  47. $res = [];
  48. $res['agreement'] = $agreement['data']['value'];
  49. if ($agreement['data']['value']['is_agreement'] == 1) {
  50. $document_model = new Document();
  51. $document = $document_model->getDocument([['site_id', '=', $this->site_id], ['app_module', '=', 'shop'], ['document_key', '=', "FENXIAO_AGREEMENT"]]);
  52. $res['document'] = $document['data'];
  53. }
  54. return $this->response($this->success($res));
  55. }
  56. /**
  57. * 分销基本设置
  58. * @return false|string
  59. */
  60. public function basics()
  61. {
  62. $config = new ConfigModel();
  63. $res = $config->getFenxiaoBasicsConfig($this->site_id);
  64. return $this->response($this->success($res['data']['value']));
  65. }
  66. /**
  67. * 分销商资格设置
  68. * @return false|string
  69. */
  70. public function fenxiao()
  71. {
  72. $config = new ConfigModel();
  73. $res = $config->getFenxiaoConfig($this->site_id);
  74. $res['data']['value']['goods_list'] = [];
  75. if($res['data']['value']['fenxiao_condition'] == 4){ //购买指定商品
  76. $page = $this->params['page']?? 1 ;
  77. $page_size = $this->params['page_size']?? 10 ;
  78. $condition[] = [ 'gs.goods_state', '=', 1 ];
  79. $condition[] = [ 'gs.is_delete', '=', 0 ];
  80. $condition[] = [ 'gs.site_id', '=', $this->site_id ];
  81. $condition[] = ['gs.goods_id','in',$res['data']['value']['goods_ids']];
  82. $goods = new Goods();
  83. $field = 'gs.goods_id,gs.sku_id,gs.sku_name,gs.price,gs.market_price,gs.discount_price,gs.stock,(g.sale_num + g.virtual_sale) as sale_num,gs.sku_image,gs.goods_name,gs.site_id,gs.is_free_shipping,gs.introduction,gs.promotion_type,g.goods_image,gs.unit';
  84. $alias = 'gs';
  85. $join = [
  86. [ 'goods g', 'gs.sku_id = g.sku_id', 'inner' ]
  87. ];
  88. $list = $goods->getGoodsSkuPageList($condition, $page, $page_size, '', $field, $alias, $join);
  89. $res['data']['value']['goods_list'] = $list[ 'data' ][ 'list' ];
  90. }
  91. return $this->response($this->success($res['data']['value']));
  92. }
  93. /**
  94. * 获取上下级关系设置
  95. * @return false|string
  96. */
  97. public function relation()
  98. {
  99. $config = new ConfigModel();
  100. $res = $config->getFenxiaoRelationConfig($this->site_id);
  101. return $this->response($this->success($res['data']['value']));
  102. }
  103. /**
  104. * 推广规则
  105. * @return false|string
  106. */
  107. public function promoteRule()
  108. {
  109. $document_model = new Document();
  110. $document = $document_model->getDocument([['site_id', '=', $this->site_id], ['app_module', '=', 'shop'], ['document_key', '=', "FENXIAO_PROMOTE_RULE"]]);
  111. return $this->response($document);
  112. }
  113. }