Index.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
  4. * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
  5. * @author pillar<ltmn@qq.com>
  6. * 小程序公共API服务
  7. */
  8. namespace app\fastshop\controller\api\v3;
  9. use app\fastshop\controller\api\Base;
  10. use app\fastshop\model\Article;
  11. use app\fastshop\model\Config;
  12. use app\fastshop\model\Store;
  13. use app\fastshop\model\RegNum;
  14. use app\fastshop\model\Vip;
  15. use think\facade\Request;
  16. class Index extends Base{
  17. /**
  18. * 获取配置
  19. */
  20. public function config(){
  21. if($this->user){
  22. RegNum::countMum($this->miniapp_id,$this->user->id); //统计直推人数
  23. $vip = Vip::where(['member_miniapp_id' => $this->miniapp_id,'user_id' => $this->user->id,'state' => 1])->find();
  24. $is_store = Store::where(['uid'=> $this->user->id])->count();
  25. }
  26. $config = Config::where(['member_miniapp_id' => $this->miniapp_id])->field('shopping_name')->find();
  27. $config['shopping_name'] = $config->shopping_name;
  28. $config['is_vip'] = empty($vip) ? 0 : 1;
  29. $config['is_store'] = empty($is_store) ? 0 : 1;
  30. return enjson(200,'成功',$config);
  31. }
  32. /**
  33. *
  34. * 获得首页公告
  35. */
  36. public function notice(){
  37. $data['signkey'] = Request::param('signkey');
  38. $data['sign'] = Request::param('sign');
  39. $rel = $this->apiSign($data);
  40. if($rel['code'] == 200){
  41. $condition[] = ['member_miniapp_id','=',$this->miniapp_id];
  42. $condition[] = ['types','=',0];
  43. $result = Article::where($condition)->field('id,title')->order('id desc')->find();
  44. if(!empty($result)){
  45. return enjson(200,'成功',$result->toArray());
  46. }
  47. }
  48. return enjson(204,'签名失败');
  49. }
  50. /**
  51. * 读取是否开启余额支付
  52. */
  53. public function shopBuyTypes(){
  54. $param['signkey'] = Request::param('signkey');
  55. $param['sign'] = Request::param('sign');
  56. $rel = $this->apiSign($param);
  57. if($rel['code'] != 200){
  58. return enjson(204,'签名失败');
  59. }
  60. $info = Config::where(['member_miniapp_id' => $this->miniapp_id])->find();
  61. $data[] = ['name'=>'微信支付','types'=>1,'disabled' => false];
  62. if($info->payment_type_shop){
  63. $data[] = ['name'=>'余额支付','types'=>2,'disabled' => false];
  64. }
  65. return enjson(200,'成功',$data);
  66. }
  67. /**
  68. * 抢购
  69. */
  70. public function saleBuyTypes(){
  71. $param['signkey'] = Request::param('signkey');
  72. $param['sign'] = Request::param('sign');
  73. $rel = $this->apiSign($param);
  74. if($rel['code'] != 200){
  75. return enjson(204,'签名失败');
  76. }
  77. $info = Config::where(['member_miniapp_id' => $this->miniapp_id])->find();
  78. $data[] = ['name'=>'微信支付','types'=>1,'disabled' => false];
  79. if($info->payment_type){
  80. $data[] = ['name'=>'余额支付','types'=>2,'disabled' => false];
  81. }
  82. return enjson(200,'成功',$data);
  83. }
  84. }