Пример #1
0
        public ActionResult QueryDelivery()
        {
            string lat   = Context.GetRequest("lat", string.Empty);
            string appid = Context.GetRequest("appid", string.Empty);
            string lnt   = Context.GetRequest("lnt", string.Empty);

            XcxAppAccountRelation umodel = _xcxAppAccountRelationBLL.GetModelByAppid(appid);

            if (umodel == null)
            {
                returnObj.Msg = "请先授权 umodel_null";
                return(Json(returnObj));
            }

            FNStoreRelation fstorer = FNStoreRelationBLL.SingleModel.GetModelByRid(umodel.Id);

            if (fstorer == null)
            {
                returnObj.Msg = "请先绑定蜂鸟门店";
                return(Json(returnObj));
            }

            FNStore fstore = FNStoreBLL.SingleModel.GetModel(fstorer.fnstoreid);

            if (fstore == null)
            {
                returnObj.Msg = "找不到蜂鸟门店数据";
                return(Json(returnObj));
            }

            object data = new
            {
                chain_store_code   = fstore.chain_store_code, //门店编号(支持数字、字母的组合)
                position_source    = 1,                       //收货点坐标属性(0:未知, 1:腾讯地图, 2:百度地图, 3:高德地图)
                receiver_longitude = lnt,
                receiver_latitude  = lat
            };

            string url    = FNApi._querydeliveryapi;
            string result = FNApi.SingleModel.UseFNApi(data, url);

            returnObj.isok = true;
            returnObj.Msg  = "在配送范围内";

            return(Json(returnObj, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        /// <summary>
        /// 生成蜂鸟物流订单
        /// </summary>
        /// <param name="rid">权限表ID</param>
        /// <param name="userinfo">用户信息</param>
        /// <param name="orderid">订单ID</param>
        /// <param name="goodcars">购物车</param>
        /// <param name="price">订单价格</param>
        /// <param name="receviename">收货人姓名</param>
        /// <param name="receviephone">收货人电话</param>
        /// <param name="address">收货人地址</param>
        /// <param name="lat">纬度</param>
        /// <param name="lnt">经度</param>
        /// <param name="ordertype">看枚举TmpType</param>
        /// <returns></returns>
        public string AddFNOrder(List <elegood> fngoods, DistributionApiModel model)
        {
            string          msg      = "";
            FNStoreRelation relation = FNStoreRelationBLL.SingleModel.GetModelByRid(model.aid);

            if (relation != null)
            {
                msg = "请先配置蜂鸟门店";
                return(msg);
            }
            FNStore fnstore = FNStoreBLL.SingleModel.GetModel(relation.fnstoreid);

            if (fnstore != null)
            {
                msg = "没有找到蜂鸟门店信息";
                return(msg);
            }
            if (fngoods == null || fngoods.Count <= 0)
            {
                msg = "商品信息不能为空";
                return(msg);
            }

            TransactionModel tran      = new TransactionModel();
            long             timestamp = Convert.ToInt64(FNApi.SingleModel.GetTimeStamp());
            string           callback  = FNApi._callbackurl;
            string           orderno   = model.userid + DateTime.Now.ToString("yyyyMMddHHmmss");
            string           storecode = fnstore.chain_store_code;
            float            buyprice  = model.buyprice / 100.0f;
            int goodcount = 0;

            //收货人信息
            FNReceiverInfo reciverifo = new FNReceiverInfo()
            {
                receiver_name          = model.accepterName,
                receiver_primary_phone = model.accepterTelePhone,
                receiver_address       = model.address,
                receiver_longitude     = model.lnt,
                receiver_latitude      = model.lat,
            };

            //门店信息
            FNStoreInfo storeinfo = new FNStoreInfo()
            {
                transport_name      = fnstore.chain_store_name,
                transport_address   = fnstore.address,
                transport_longitude = Convert.ToDouble(fnstore.longitude),
                transport_latitude  = Convert.ToDouble(fnstore.latitude),
                transport_tel       = fnstore.contact_phone,
            };

            //生成订单实体类对象
            FNOrder data = new FNOrder(storecode, goodcount, callback, buyprice, timestamp, buyprice, orderno, model.remark, fngoods, reciverifo, storeinfo);

            tran.Add(base.BuildAddSql(data));

            //订单与系统订单关联
            FNOrderRelation orderrelation = new FNOrderRelation();

            orderrelation.dataid        = model.aid;
            orderrelation.orderid       = model.orderid;
            orderrelation.ordertype     = model.temptype;
            orderrelation.uniqueorderno = orderno;

            tran.Add(FNOrderRelationBLL.SingleModel.BuildAddSql(orderrelation));

            if (!ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray))
            {
                msg = "添加蜂鸟物流出错";
            }
            return(msg);
        }