Пример #1
0
        /// <summary>
        /// 快跑者配送推单
        /// </summary>
        /// <param name="orderid">小程序订单表ID</param>
        /// <param name="rid"></param>
        /// <param name="tran"></param>
        /// <returns></returns>
        public string GetKPZOrderUpdateSql(int orderid, int aid, int storeid, ref TransactionModel tran, bool gettransql = false)
        {
            KPZOrder order = GetModelByOrerId(aid, storeid, orderid);

            if (order == null)
            {
                return("快跑者配送:订单不存在");
            }

            KPZStoreRelation kpzstore = KPZStoreRelationBLL.SingleModel.GetModel(order.shop_id);

            if (kpzstore == null)
            {
                return("快跑者配送:关联店铺不存在");
            }

            KPZResult <OrderTradeNo> result = KPZApi.CreateOrder(order, kpzstore.TeamToken);

            if (result == null)
            {
                return("快跑者配送:新增订单接口异常");
            }
            if (result.code == 200)
            {
                order.status = (int)KPZOrderEnum.待发单;
                if (result.data == null || string.IsNullOrEmpty(result.data.trade_no))
                {
                    LogHelper.WriteInfo(this.GetType(), "快跑者新增订单接口返回值异常" + JsonConvert.SerializeObject(result));
                    return("快跑者新增订单接口返回值异常");
                }
                order.trade_no = result.data.trade_no;
                if (gettransql)
                {
                    return(base.ExecuteNonQuery($"update KPZOrder set status={order.status},trade_no='{order.trade_no}' where id={order.id}") > 0 ? "" : "修改快跑者订单状态出错");
                }
                else
                {
                    tran.Add($"update KPZOrder set status={order.status},trade_no='{order.trade_no}' where id={order.id}");
                }

                return("");
            }

            return(result.message);
        }
Пример #2
0
        /// <summary>
        /// 取消订单
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="storeid"></param>
        /// <param name="orderid"></param>
        /// <param name="reason"></param>
        /// <returns></returns>
        public bool CancelOrder(int aid, int storeid, int orderid, string reason = "")
        {
            bool     success = false;
            KPZOrder model   = GetModelByOrerId(aid, storeid, orderid);

            if (model == null)
            {
                LogHelper.WriteInfo(this.GetType(), $"快跑者配送:取消订单失败,没有找到快跑者订单数据_{aid}_{storeid}_{orderid}");
                return(success);
            }
            KPZStoreRelation storemodel = KPZStoreRelationBLL.SingleModel.GetModel(model.shop_id);

            if (storemodel == null)
            {
                LogHelper.WriteInfo(this.GetType(), $"快跑者配送:取消订单失败,快跑者配送没配置_{aid}_{storeid}_{orderid}");
                return(success);
            }
            if (model.status == (int)KPZOrderEnum.已送达)
            {
                LogHelper.WriteInfo(this.GetType(), $"快跑者配送:取消订单失败,该订单已送达_{aid}_{storeid}_{orderid}");
                return(success);
            }

            KPZResult <object> result = KPZApi.CancelOrder(model.trade_no, reason, storemodel.TeamToken);

            if (result == null || result.code != 200)
            {
                LogHelper.WriteInfo(this.GetType(), $"快跑者配送:取消订单失败,接口返回异常_{model.trade_no}_{storemodel.TeamToken}" + (result != null?result.message:""));
            }
            else
            {
                model.status = (int)KPZOrderEnum.已撤销;
                success      = base.Update(model, "status");
                if (!success)
                {
                    LogHelper.WriteInfo(this.GetType(), $"快跑者配送:更新系统订单状态失败_{model.id}");
                }
            }
            return(success);
        }
Пример #3
0
        public static KPZResult <T> KPZRequest <T>(string apiUrl, Dictionary <string, string> param, string type = "post")
        {
            KPZResult <T> dataResult = new KPZResult <T>();
            string        url        = _host + apiUrl;
            string        result     = "";

            try
            {
                switch (type)
                {
                case "post":
                    string json = SortParamString(param);
                    result = CommonCore.HttpPost(url, json);
                    break;

                case "get":
                    url   += SortParamString(param);
                    result = HttpHelper.GetData(url);
                    break;
                }
                KPZResult <object> tempResult = JsonConvert.DeserializeObject <KPZResult <object> >(result);
                if (tempResult.code == 200)
                {
                    dataResult = JsonConvert.DeserializeObject <KPZResult <T> >(result);
                }
                else
                {
                    dataResult.code    = tempResult.code;
                    dataResult.message = tempResult.message;
                }
            }
            catch (Exception ex)
            {
                log4net.LogHelper.WriteInfo(typeof(KPZApi), $"快跑者接口请求异常:{ex.Message},result={result}");
            }

            return(dataResult);
        }
Пример #4
0
        /// <summary>
        /// 获取运费
        /// </summary>
        /// <param name="storeid"></param>
        /// <param name="aid"></param>
        /// <param name="lat"></param>
        /// <param name="lnt"></param>
        /// <param name="orderprice"></param>
        /// <returns></returns>
        public int GetKPZFee(int storeid, int aid, string address, string lat, string lnt, int orderprice, ref string msg)
        {
            int fee = 0;
            KPZResult <KPZFee> result = new KPZResult <KPZFee>();

            if (!string.IsNullOrEmpty(address))
            {
                //再请求一次腾讯地图,获取准确的坐标
                AddressApi addressModel = AddressHelper.GetLngAndLatByAddress(address);
                if (addressModel != null && addressModel.result != null && addressModel.result.location != null)
                {
                    lnt = addressModel.result.location.lng.ToString();
                    lat = addressModel.result.location.lat.ToString();
                }
                else
                {
                    msg = "快跑者配送:获取腾讯地址失败";
                    return(0);
                }
            }

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid);

            if (xcxrelation == null)
            {
                msg = "快跑者配送:权限模板不存在";
                return(fee);
            }

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

            if (xcxtemplate == null)
            {
                msg = "快跑者配送:小程序模板不存在";
                return(fee);
            }

            KPZStoreRelation storerelation = KPZStoreRelationBLL.SingleModel.GetModelBySidAndAid(aid, storeid);

            if (storerelation == null)
            {
                msg = "快跑者配送:未设置快跑者配送配置";
                return(fee);
            }

            int    shopid  = storerelation.Id;
            string sendtag = lnt + "," + lat;
            //店铺信息
            ShopInfo shopinfo = GetStoreAddressPoint(storerelation.AId, storerelation.StoreId, xcxtemplate.Type);
            string   payfee   = "0";

            if (shopinfo.ShopTag.Length <= 0)
            {
                msg = "快跑者配送:店铺经纬不能为空";
                return(fee);
            }

            if (sendtag.Length <= 1)
            {
                msg = "快跑者配送:取货经纬不能为空";
                return(fee);
            }
            result = KPZApi.GetFee(shopid, sendtag, shopinfo.ShopTag, (orderprice * 0.01).ToString("0.00"), payfee, storerelation.TeamToken);

            if (result == null)
            {
                log4net.LogHelper.WriteInfo(this.GetType(), "快跑者配送:返回结果为null,");
                return(fee);
            }
            if (result.data == null)
            {
                log4net.LogHelper.WriteInfo(this.GetType(), "快跑者配送:返回运费为null,");
                return(fee);
            }
            if (result.code == 200)
            {
                fee = Convert.ToInt32(result.data.pay_fee);
                return(fee);
            }
            else
            {
                msg = result.message;
            }

            if (result == null)
            {
                result      = new KPZResult <KPZFee>();
                result.code = 204;
            }
            //msg = "获取运费出错";

            log4net.LogHelper.WriteInfo(this.GetType(), $"快跑者配送:请求参数,shopid【{shopid}】sendtag【{sendtag}】gettag【{shopinfo.ShopTag}】orderprice【{orderprice}】payfee【{payfee}】" + JsonConvert.SerializeObject(result));

            return(fee);
        }