Пример #1
0
        /// <summary>
        /// 创建微信支付参数
        /// </summary>
        /// <param name="money"></param>
        /// <param name="vpm"></param>
        /// <param name="uniacid"></param>
        /// <param name="account"></param>
        /// <param name="weChatOrder"></param>
        /// <returns></returns>
        private WXPayModel GetCreatePacketsPayParams(decimal money, VoicePacketsModel vpm, string uniacid, AccountModel account, out WeChatOrder weChatOrder)
        {
            weChatOrder = new WeChatOrder()
            {
                CreateTime    = DateTime.Now,
                Total         = money,
                VoicePackets  = vpm,
                WeChatOrderID = ObjectId.GenerateNewId()
            };
            if (account.WeChatOrders == null)
            {
                collection.UpdateOne(x => x.AccountID.Equals(account.AccountID),
                                     Builders <AccountModel> .Update.Set(x => x.WeChatOrders, new List <WeChatOrder>()));
            }
            collection.UpdateOne(x => x.AccountID.Equals(account.AccountID),
                                 Builders <AccountModel> .Update.Push(x => x.WeChatOrders, weChatOrder));
            ///微擎相关
            JsApiPay jsApiPay = new JsApiPay();

            jsApiPay.openid    = account.OpenID;
            jsApiPay.total_fee = money.ConvertToMoneyCent();
            var body      = "test";
            var attach    = account.AccountID + "," + weChatOrder.WeChatOrderID.ToString();
            var goods_tag = "创建红包";

            jsApiPay.CreateWeChatOrder(uniacid, body, attach, goods_tag);
            var param = jsApiPay.GetJsApiParameters(We7Tools.Models.We7ProcessMiniConfig.GetAllConfig(uniacid).KEY);
            var wxpm  = JsonConvert.DeserializeObject <WXPayModel>(param);

            return(wxpm);
        }
Пример #2
0
        private WXPayModel GetCreatePacketsPayParams(string uniacid, AccountModel account, Order order)
        {
            if (account.Orders == null)
            {
                collection.UpdateOne(x => x.AccountID.Equals(account.AccountID),
                                     Builders <AccountModel> .Update.Set(x => x.Orders, new List <Order>()));
            }
            collection.UpdateOne(x => x.AccountID.Equals(account.AccountID),
                                 Builders <AccountModel> .Update.Push(x => x.Orders, order));
            ///微擎相关
            JsApiPay jsApiPay = new JsApiPay();

            jsApiPay.openid    = account.OpenID;
            jsApiPay.total_fee = order.Total.ConvertToMoneyCent();
            var body      = "二维码邮寄";
            var attach    = account.AccountID + "," + order.OrderID.ToString();
            var goods_tag = "二维码邮寄";

            jsApiPay.CreateWeChatOrder(uniacid, body, attach, goods_tag);
            var param = jsApiPay.GetJsApiParameters(We7Tools.Models.We7ProcessMiniConfig.GetAllConfig(uniacid).KEY);
            var wxpm  = JsonConvert.DeserializeObject <WXPayModel>(param);

            return(wxpm);
        }