Skip to content

新插件开发方式

Hook注解

php
    //application/model/Newplugin.php
    public const  H_orderStatusChange= "orderStatusChange";  //订单支付成功或订单完成时
    public const  H_openCustomPusherInfo= "openCustomPusherInfo";  //是否开启权益页-自定义等级展示
    public const  H_getCustomPusherInfo= "getCustomPusherInfo";  //获取权益页-自定义等级展示
    public const  H_getGoodsUnitPrice= "getGoodsUnitPrice";   //获取商品单价
    public const  H_wxappUrlconfig= "wxappUrlconfig";   //DIY链接(wxapp_url_config.php)
    public const  H_homeUrlconfig= "homeUrlconfig";   //DIY链接(admin/controller/Chome.php)
    public const  H_userAfterInsert= "userAfterInsert";   //用户创建之后
    public const  H_setParents= "setParents";   //设置上下级关系时
    public const  H_hasGoodsAreaType= "hasGoodsAreaType";  //是否开启商品区功能
    public const  H_goodsAreaList= "goodsAreaList";  //商品区列表

H_orderStatusChange使用(//订单支付成功或订单完成时)

php
  /**
  $params = [
      "order_id" => $order_id,
      "type" => $type,//0表示订单支付完成,1表示订单完成
      "user_id" => $user_id,
      "flag" =>$flag,//first表示第一单核销,middle表示中间单核销,last表示最后一单核销,only表示仅一单[订单完成时]
  ];
  */
  public function orderStatusChange($params)
  {
      print_r("接收参数\n");
      print_r($params);
  }

H_openCustomPusherInfo使用(//是否开启权益页-自定义等级展示)

php
  public function openCustomPusherInfo(&$res)
     {
         $res = true;
     }

H_getCustomPusherInfo使用(//获取权益页-自定义等级展示)

php
public function getCustomPusherInfo(&$param)
    {
        if (Yimei::isOpen()) {
            $param["data"] = (new Yimei())->getPusherInfo($param["user_id"]);
        } else {
            $param["data"] = false;
        }

    }

getGoodsUnitPrice使用(//获取商品单价)

php
  /**
  $params = [
      "user_id"=>$user_id, //用户id
      "gid"=>$gid, //商品id
      "unit_price"=>$data["price"], //当前销售价
      "result"=>false, //是否修改
  ];
  */
    public function getGoodsUnitPrice(&$param)
    {
        $goods = Goods::find($param["gid"]);
        if ($goods["area_type"] == 3) {
            $pusher = Pusher::where("user_id", $param["user_id"])->find();
            if ($pusher) {
                $param["unit_price"] = $goods["ningming_vip_price"];
                $param["result"] = true;
            }
        }


    }

H_wxappUrlconfig使用(DIY链接(wxapp_url_config.php))

php
  /**
  $arr为DIY链接(wxapp_url_config.php)的数组
  */
      public function wxappUrlconfig(&$arr)
      {
          $arr[] = array(
              'name' => '排位团队',
              'value' => '/subfeature/ningming/team/team',
              'plugin' => 'plugin_ningming',
              'plugin_name' => '甯敏松',
          );
      }

H_homeUrlconfig使用(DIY链接(admin/controller/Chome.php))

php
  /**
  $arr为DIY链接(admin/controller/Chome.php)的数组
  */
    public function homeUrlconfig(&$plugList)
    {
        $plugList[] = [
            type => 'plugin_ningming',
            name => '排位团队',
            url => '/subfeature/ningming/team/team',
            param => [],
            other => [
                desc => '甯敏松'
            ]
        ];
    }

H_userAfterInsert使用(//用户创建之后)

php
    public function userAfterInsert($param)
    {
        $user_count = User::count();
        if ($user_count == 1) {
            (new Ningminggrid())->addGrid($param["user_id"], 0);
        }
    }

H_setParents使用(//设置上下级关系时)

php
    public function setParents($param)
    {
       //to do something
    }

H_hasGoodsAreaType使用(//是否开启商品区功能)

php
   public function hasGoodsAreaType(&$param)
       {
           $param = true;
       }

H_goodsAreaList使用(//商品区列表)

php
   public function goodsAreaList(&$param)
      {
          $param = [
              ["text" => "会员礼包区", "id" => 3],
              ["text" => "合作商礼包区", "id" => 4],
              ["text" => "复购区", "id" => 5],
          ];
      }