(cls, pay, user=None, request=None, **kwargs)
return cls.objects.create(pay=pay, **data)
:type pay: wechat_django.pay.models.WeChatPay
        :param user: 发生支付的用户,如不填写,请填写openid或sub_openid
        :type user: wechat_django.models.WeChatUser
        :param request: 发生此次请求的request
        :param kwargs: 参见模型其他各字段的值
:type pay: wechat_django.pay.models.WeChatPay
        :param user: 发生支付的用户,如不填写,请填写openid或sub_openid
        :type user: wechat_django.models.WeChatUser
        :param request: 发生此次请求的request
        :param kwargs: 参见模型其他各字段的值
: type pay : wechat_django . pay . models . WeChatPay : param user : 发生支付的用户 如不填写 请填写openid或sub_openid : type user : wechat_django . models . WeChatUser : param request : 发生此次请求的request : param kwargs : 参见模型其他各字段的值
def create(cls, pay, user=None, request=None, **kwargs):
        """
        :type pay: wechat_django.pay.models.WeChatPay
        :param user: 发生支付的用户,如不填写,请填写openid或sub_openid
        :type user: wechat_django.models.WeChatUser
        :param request: 发生此次请求的request
        :param kwargs: 参见模型其他各字段的值
        """
        data = {}

        if user:
            if pay.sub_appid and user.app.appid == pay.sub_appid:
                data["sub_openid"] = user.openid
            else:
                data["openid"] = user.openid

        # 自动构造trade_type
        data["trade_type"] = cls.TradeType.JSAPI

        fields = model_fields(UnifiedOrder)
        data.update({k: v for k, v in kwargs.items() if k in fields})

        return cls.objects.create(pay=pay, **data)
def create ( cls , pay , user = None , request = None , * * kwargs ) : data = { } if user : if pay . sub_appid and user . app . appid == pay . sub_appid : data [ "sub_openid" ] = user . openid else : data [ "openid" ] = user . openid # 自动构造trade_type data [ "trade_type" ] = cls . TradeType . JSAPI fields = model_fields ( UnifiedOrder ) data . update ( { k : v for k , v in kwargs . items ( ) if k in fields } ) return cls . objects . create ( pay = pay , * * data )