Esempio n. 1
0
        /// <summary>
        /// 获取团队信息
        /// </summary>
        public static KPZResult <object> GetTeamInfo(string teamToken)
        {
            object data = new object();
            Dictionary <string, string> param = KPZApi.GetParamApi(data, teamToken);

            param["sign"] = KPZApi.GetSign(param, KPZApi._devSecret);

            return(KPZApi.KPZRequest <object>(KPZApi._getTeamInfoApiUrl, param, "get"));
        }
Esempio n. 2
0
        /// <summary>
        /// 获取订单详情
        /// </summary>
        public static KPZResult <object> GetOrderLog(string orderid, string teamToken)
        {
            //string orderId = "18061516542500002";  // 生成一个第三方订单 ID
            object data = new { trade_no = orderid };
            Dictionary <string, string> param = KPZApi.GetParamApi(data, teamToken);

            param["sign"] = KPZApi.GetSign(param, KPZApi._devSecret);

            return(KPZApi.KPZRequest <object>(KPZApi._getOrderLogApiUrl, param, "get"));
        }
Esempio n. 3
0
        /// <summary>
        /// 获取配送员最新坐标
        /// </summary>
        public static KPZResult <object> GetCourierTag(string orderId, string teamToken)
        {
            //string orderId = "2654849875465125498";  // 生成一个第三方订单 ID
            object data = new { trade_no = orderId };
            Dictionary <string, string> param = KPZApi.GetParamApi(data, teamToken);

            param["sign"] = KPZApi.GetSign(param, KPZApi._devSecret);

            return(KPZApi.KPZRequest <object>(KPZApi._getCourierTagApiUrl, param, "get"));
        }
Esempio n. 4
0
        /// <summary>
        /// 取消订单
        /// </summary>
        public static KPZResult <object> CancelOrder(string orderId, string reason, string teamToken)
        {
            //string orderId = "18061516542500002";  // 生成一个第三方订单 ID
            object data = new { trade_no = orderId, reason };
            Dictionary <string, string> param = KPZApi.GetParamApi(data, teamToken);

            param["sign"] = KPZApi.GetSign(param, KPZApi._devSecret);

            return(KPZApi.KPZRequest <object>(KPZApi._cancelOrderApiUrl, param));
        }
Esempio n. 5
0
        public static Dictionary <string, string> GetParamApi(object data, string teamToken)
        {
            string expire_time = KPZApi.GetTimeStamp().ToString().Substring(0, 10) + 60;
            Dictionary <string, string> param = new Dictionary <string, string>();

            param["dev_key"]    = KPZApi._devKey;
            param["version"]    = KPZApi._version;
            param["ticket"]     = Guid.NewGuid().ToString();
            param["team_token"] = teamToken;
            param["body"]       = JsonConvert.SerializeObject(data);
            param["timestamp"]  = expire_time;

            return(param);
        }
Esempio n. 6
0
        /// <summary>
        /// 获取运费
        /// </summary>
        /// <param name="shopId">第三方商户ID</param>
        /// <param name="sendTag">送达坐标</param>
        /// <param name="getTag">取单坐标</param>
        /// <param name="orderPrice">第三方订单总价</param>
        /// <param name="payFee">第三方订单原配送费</param>
        public static KPZResult <KPZFee> GetFee(int shopId, string sendTag, string getTag, string orderPrice, string payFee, string teamToken)
        {
            KPZFee data = new KPZFee();

            data.shop_id      = shopId;     //1;
            data.customer_tag = sendTag;    //"23.15098980049273,113.3218529820442";
            data.get_tag      = getTag;     //"23.15098980049273,113.3218529820442";
            data.order_price  = orderPrice; //"1";
            data.pay_fee      = payFee;     //"1";
            Dictionary <string, string> param = KPZApi.GetParamApi(data, teamToken);

            param["sign"] = KPZApi.GetSign(param, KPZApi._devSecret);

            return(KPZApi.KPZRequest <KPZFee>(KPZApi._getFeeApiUrl, param, "get"));
        }
Esempio n. 7
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);
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        public static string _getTeamInfoApiUrl   = "/open/team/getTeamInfo?";    //获取团队信息

        /// <summary>
        /// 生成订单
        /// </summary>
        public static KPZResult <OrderTradeNo> CreateOrder(KPZOrder data, string teamToken)
        {
            //log4net.LogHelper.WriteInfo(typeof(KPZApi),"快跑者订单:"+JsonConvert.SerializeObject(data));
            //string orderId = "2654849875465125499";  // 生成一个第三方订单 ID
            ////string preTime = DateTime.Now.AddHours(1).ToString("yyyy-MM-dd HH:mm:ss");   // 预计一个小时之后送达
            //string ordertime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            //KPZOrder data = new KPZOrder()
            //{
            //    shop_id = 1,
            //    shop_name = "小未商家",
            //    shop_tel = "18718463809",
            //    shop_address = "广东省天河区天河公园",
            //    shop_tag = "113.366326,23.128052",
            //    order_content = "2份烧白开(100x1),2份拉面(18x1)",
            //    order_note = "不要太辣了",
            //    //order_mark = "12",
            //    order_from = "小未科技",
            //    order_time = ordertime,
            //    //order_photo = "http://a4.att.hudong.com/38/47/19300001391844134804474917734_950.png",
            //    note = orderId,
            //    customer_name = "张三丰",
            //    customer_tel = "18288888888",
            //    customer_address = "广东省天河区天河公园",
            //    customer_tag = "113.366326,23.128052",
            //    order_no = orderId,
            //    order_price = 99.99f,
            //    order_origin_price = 100.00f,
            //    pay_status = 1,
            //    pay_fee = 1.66f,
            //    //pre_times = preTime,
            //};

            Dictionary <string, string> param = KPZApi.GetParamApi(data, teamToken);

            param["sign"] = KPZApi.GetSign(param, KPZApi._devSecret);

            return(KPZApi.KPZRequest <OrderTradeNo>(KPZApi._createOrderApiUrl, param));
        }
Esempio n. 10
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);
        }