コード例 #1
0
        public static string _cancelBindApiUrl     = "/cancelbind.ashx";                       //用户解除绑定

        #region 订单相关
        /// <summary>
        /// 获取运费
        /// </summary>
        /// <param name="openId">商户注册时返回的OpenId</param>
        /// <param name="fromAddress">起始地址</param>
        /// <param name="fromNote">起始详细地址</param>
        /// <param name="toAddress">送达地址</param>
        /// <param name="toNote">送达详细地址</param>
        /// <param name="cityName">城市,必须带上'市'</param>
        /// <param name="countyName">区域</param>
        /// <returns></returns>
        public static UUGetPriceResult GetOrderPrice(string openId, string fromAddress, string fromNote, string toAddress, string toNote, string cityName, string countyName)
        {
            UUGetPrice model = new UUGetPrice();

            model.appid         = _appid;
            model.nonce_str     = Guid.NewGuid().ToString().Replace("-", "");
            model.timestamp     = GetTimestamp();
            model.openid        = openId;
            model.origin_id     = DateTime.Now.ToString("yyyyMMddHHmmss");
            model.from_address  = fromAddress;
            model.from_usernote = fromNote;
            model.to_address    = toAddress;
            model.to_usernote   = toNote;
            model.city_name     = cityName;
            model.county_name   = countyName;
            model.from_lng      = "0";
            model.from_lat      = "0";
            model.to_lng        = "0";
            model.to_lat        = "0";
            Dictionary <string, string> mydic = GetDictionary(model);

            model.sign = CreateMd5Sign(mydic, _appsecret);
            mydic.Add("sign", model.sign);
            string           url        = _host + _getOrderPriceApiUrl;
            string           resultJson = HttpPost(url, mydic);
            UUGetPriceResult result     = JsonConvert.DeserializeObject <UUGetPriceResult>(resultJson);

            return(result);
            //{"price_token":"a69de77bf4a24065868c4cc8d58b32d2","total_money":"7.00","need_paymoney":"0.00","total_priceoff":"7.00","distance":"0","freight_money":"7.00","business_priceoff":"0.00","couponid":"80087951","coupon_amount":"7.00","addfee":"0.00","goods_insurancemoney":"0.00","expires_in":"1200","origin_id":"20180725173348","return_code":"ok","return_msg":"价格计算成功","appid":"d2fe3af49ce544c4b5c0731aa5ab28df","nonce_str":"63d34d12f1104fbfabc78dce6477908c","sign":"1F26C26E2E089BCDFA96391326E4179E"}
        }
コード例 #2
0
ファイル: UUOrderBLL.cs プロジェクト: soon14/vzan
        /// <summary>
        /// 获取UU配送运费
        /// </summary>
        /// <param name="storeId"></param>
        /// <param name="aid"></param>
        /// <param name="lat"></param>
        /// <param name="lnt"></param>
        /// <param name="orderPrice"></param>
        /// <returns></returns>
        public UUOrderFee GetUUFee(int storeId, int aid, string toAddress, ref string msg)
        {
            msg = "获取运费出错";
            UUOrderFee         feeResult        = new UUOrderFee();
            UUCustomerRelation customerRelation = UUCustomerRelationBLL.SingleModel.GetModelByAid(aid, storeId, 0);

            if (customerRelation == null)
            {
                msg = "UU配送:未设置UU配置";
                return(feeResult);
            }
            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid);

            if (xcxrelation == null)
            {
                msg = "UU配送:权限模板不存在";
                return(feeResult);
            }

            XcxTemplate xcxtemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxtemplate == null)
            {
                msg = "UU配送:小程序模板不存在";
                return(feeResult);
            }

            //店铺信息
            ShopInfo shopinfo = GetStoreAddressPoint(aid, storeId, xcxtemplate.Type);

            UUGetPriceResult result = UUApi.GetOrderPrice(customerRelation.OpenId, shopinfo.ShopAddress, "", toAddress, "", shopinfo.CityName, shopinfo.CountyName);

            if (result == null)
            {
                LogHelper.WriteInfo(this.GetType(), "UU配送:返回结果为null,");
                return(feeResult);
            }
            if (result.return_code != "ok")
            {
                LogHelper.WriteInfo(this.GetType(), $"UU配送配送:请求参数,aid【{aid}】storeid【{storeId}】" + JsonConvert.SerializeObject(result));
                msg = result.return_msg;
                return(feeResult);
            }
            else
            {
                decimal maxFee = Math.Max(Convert.ToDecimal(result.total_money), Convert.ToDecimal(result.need_paymoney));
                int     fee    = Convert.ToInt32(maxFee * 100);
                feeResult.Fee           = fee;
                feeResult.price_token   = result.price_token;
                feeResult.total_money   = result.total_money;
                feeResult.need_paymoney = result.need_paymoney;
                msg = "";
                return(feeResult);
            }
        }