示例#1
0
        /// <summary>
        /// 达达推单
        /// </summary>
        /// <param name="data">订单</param>
        /// <param name="sourceid">商户号编号</param>
        /// <param name="raddorder">是否预发单:0:新增订单,1:重发订单,2:预发单</param>
        /// <returns></returns>
        public DadaApiReponseModel <ResultReponseModel> AddOrder(DadaOrder data, string sourceid, int raddorder)
        {
            DadaApiReponseModel <ResultReponseModel> reposemodel = new DadaApiReponseModel <ResultReponseModel>();

            _dadaapi._sourceid = sourceid;
            _dadaapi._shop_no  = data.shop_no;

            string json = _dadaapi.PostParamJson(data);
            string url  = _dadaapi._addorderapi;

            if (raddorder == 1)
            {
                url = _dadaapi._readdorderapi;
            }
            else if (raddorder == 2)
            {
                url = _dadaapi._querydeliverfeeorderapi;
            }

            string result = HttpHelper.DoPostJson(url, json);

            if (!string.IsNullOrEmpty(result))
            {
                reposemodel = JsonConvert.DeserializeObject <DadaApiReponseModel <ResultReponseModel> >(result);
                //if (raddorder == 2)
                //{
                //    RedisUtil.Set(string.Format("_dadaRaddorderkey", data.origin_id), reposemodel.result.deliveryNo, TimeSpan.FromMinutes(3));
                //}
            }

            return(reposemodel);
        }
示例#2
0
        /// <summary>
        /// 获取取消订单原因列表
        /// </summary>
        /// <returns></returns>
        public List <ResultReponseModel> GetCancelOrderReasonList()
        {
            List <ResultReponseModel> cancellist = RedisUtil.Get <List <ResultReponseModel> >(_cancelorderkey);

            if (cancellist != null)
            {
                return(cancellist);
            }

            object data   = "";
            string json   = PostParamJson(data);
            string url    = _cancelorderreasonsapi;
            string result = HttpHelper.DoPostJson(url, json);

            if (!string.IsNullOrEmpty(result))
            {
                DadaApiReponseModel <List <ResultReponseModel> > resultmodel = JsonConvert.DeserializeObject <DadaApiReponseModel <List <ResultReponseModel> > >(result);
                if (resultmodel.status == "success" && resultmodel.result != null && resultmodel.result.Count > 0)
                {
                    cancellist = resultmodel.result;
                    RedisUtil.Set <List <ResultReponseModel> >(_cancelorderkey, cancellist, TimeSpan.FromHours(12));
                }
            }
            else
            {
                cancellist = new List <ResultReponseModel>();
            }

            log4net.LogHelper.WriteInfo(this.GetType(), "获取达达取消订单原因列表出错:" + result);
            return(cancellist);
        }
示例#3
0
        /// <summary>
        /// 获取修改达达订单状态sql
        /// </summary>
        /// <param name="orderid">小程序订单表ID</param>
        /// <param name="rid"></param>
        /// <param name="ordertype">看枚举TmpType</param>
        /// <param name="tran"></param>
        /// <returns></returns>
        public string GetDadaOrderUpdateSql(int orderid, int rid, int ordertype, ref TransactionModel tran, bool gettransql = false)
        {
            DadaOrderRelation model = DadaOrderRelationBLL.SingleModel.GetModelOrder(rid, orderid, ordertype);

            if (model == null)
            {
                return("达达配送:没有找到订单关联数据");
            }

            DadaOrder order = GetModelByOrderNo(model.uniqueorderno);

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

            DadaMerchant merchant = DadaMerchantBLL.SingleModel.GetModelByRId(rid);

            if (merchant == null || merchant.id <= 0)
            {
                return("达达配送:找不到商户数据");
            }


            DadaApiReponseModel <ResultReponseModel> result = AddOrder(order, merchant.sourceid, 0);

            if (result == null)
            {
                return("达达配送:新增订单接口异常");
            }
            //log4net.LogHelper.WriteInfo(this.GetType(),JsonConvert.SerializeObject(result));
            if (result.status == "success")
            {
                order.state = (int)DadaOrderEnum.推单中;
                if (gettransql)
                {
                    return(base.ExecuteNonQuery($"update dadaorder set state={order.state} where id={order.id}") > 0?"":"修改达达订单状态出错");
                }
                else
                {
                    tran.Add($"update dadaorder set state={order.state} where id={order.id}");
                }

                return("");
            }

            return(result.msg);
        }
示例#4
0
        /// <summary>
        /// 创建订单
        /// </summary>
        /// <returns></returns>
        public ActionResult AddOrder()
        {
            string sourceid  = Context.GetRequest("sourceid", "73753");
            string shop_no   = Context.GetRequest("shop_no", "11047059");
            string order_id  = Context.GetRequest("order_id", "");
            int    raddorder = Context.GetRequestInt("raddorder", 0);

            _dadaApi._sourceid = sourceid;
            _dadaApi._shop_no  = shop_no;

            DadaOrder data = new DadaOrder()
            {
                shop_no = _dadaApi._shop_no, origin_id = order_id, city_code = "123456", cargo_price = 20.01f, is_prepay = 1, expected_fetch_time = _dadaApi.GetTimeStamp(), receiver_name = "ceshi", receiver_address = "ceshi", receiver_lat = 20.12548, receiver_lng = 120.548565, callback = _dadaApi._ordercallback, insurance_fee = 0, receiver_phone = "18718463809", receiver_tel = "18718463809", tips = 1, info = "测试", cargo_type = 1, cargo_weight = 1.1, cargo_num = 1, invoice_title = "", deliver_locker_code = "", pickup_locker_code = "", origin_mark = "", origin_mark_no = "", is_finish_code_needed = 0, delay_publish_time = 0
            };

            string json = _dadaApi.PostParamJson(data);
            string url  = _dadaApi._addorderapi;

            if (raddorder == 1)
            {
                url = _dadaApi._readdorderapi;
            }
            else if (raddorder == 2)
            {
                url = _dadaApi._querydeliverfeeorderapi;
            }
            string result = WxHelper.DoPostJson(url, json);

            if (!string.IsNullOrEmpty(result))
            {
                DadaApiReponseModel <ResultReponseModel> reposemodel = JsonConvert.DeserializeObject <DadaApiReponseModel <ResultReponseModel> >(result);
                if (raddorder == 2)
                {
                    RedisUtil.Set("dada_key_" + order_id, reposemodel.result.deliveryNo, TimeSpan.FromMinutes(3));
                }
            }
            return(Json(new { isok = true, msg = result }, JsonRequestBehavior.AllowGet));
        }
示例#5
0
        /// <summary>
        /// 修改订单状态
        /// </summary>
        /// <returns></returns>
        public DadaApiReponseModel <ResultReponseModel> UpdateOrderState(string order_id, int state, string sourceid)
        {
            _dadaapi._sourceid = sourceid;
            DadaApiReponseModel <ResultReponseModel> reposemodel = new DadaApiReponseModel <ResultReponseModel>();

            reposemodel.status = "fail";
            reposemodel.msg    = "执行出错";

            if (state == -1)
            {
                reposemodel.msg = "订单状态出错";
                return(reposemodel);
            }

            object data = new object();
            string url  = string.Empty;

            switch (state)
            {
            case 0:    //取消订单
                data = new { order_id = order_id, cancel_reason_id = 1, cancel_reason = "" };
                url  = _dadaapi._cancelorderapi;
                break;

            case 1:    //查询订单
                data = new { order_id = order_id };
                url  = _dadaapi._orderqueryapi;
                break;

            case 2:    //接收订单
                data = new { order_id = order_id };
                url  = _dadaapi._acceptorderapi;
                break;

            case 3:    //完成取货
                data = new { order_id = order_id };
                url  = _dadaapi._fetchgoodapi;
                break;

            case 4:    //完成订单
                data = new { order_id = order_id };
                url  = _dadaapi._finishorderapi;
                break;

            case 5:    //订单过期
                data = new { order_id = order_id };
                url  = _dadaapi._expireorderapi;
                break;

            case 6:    //取消追加订单
                data = new { order_id = order_id };
                url  = _dadaapi._cancelappendorderapi;
                break;

            case 7:    //执行预发单后发单
                string deliveryNo = RedisUtil.Get <string>(string.Format("_dadaRaddorderkey", order_id));
                data = new { deliveryNo = deliveryNo };
                url  = _dadaapi._addafterqueryorderapi;
                break;
            }

            string json   = _dadaapi.PostParamJson(data);
            string result = HttpHelper.DoPostJson(url, json);

            if (!string.IsNullOrEmpty(result))
            {
                reposemodel = JsonConvert.DeserializeObject <DadaApiReponseModel <ResultReponseModel> >(result);
            }

            return(reposemodel);
        }
示例#6
0
        /// <summary>
        /// 达达运费
        /// </summary>
        /// <param name="cityName"></param>
        /// <param name="appid"></param>
        /// <param name="openid"></param>
        /// <param name="lat"></param>
        /// <param name="lnt"></param>
        /// <param name="accepterName"></param>
        /// <param name="accepterPhone"></param>
        /// <param name="address"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public int GetDadaFee(string cityName, string appid, string openid, string accepterName, string accepterPhone, string address, string lat, string lnt, ref string msg)
        {
            if (string.IsNullOrEmpty(appid))
            {
                msg = "appid不能为空";
                return(0);
            }
            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 umodel = XcxAppAccountRelationBLL.SingleModel.GetModelByAppid(appid);

            if (umodel == null)
            {
                msg = "达达配送:权限模板不能为空";
                return(0);
            }
            C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModelByAppId_OpenId(appid, openid);

            if (userInfo == null)
            {
                msg = "达达配送:用户不存在";
                return(0);
            }
            if (accepterName == null || accepterName.Length == 0)
            {
                msg = "达达配送:收货人姓名不能为空";
                return(0);
            }
            if (accepterPhone == null || accepterPhone.Length == 0)
            {
                msg = "达达配送:收货人手机号不能为空";
                return(0);
            }
            if (address == null || address.Length == 0)
            {
                msg = "达达配送:收货人地址不能为空";
                return(0);
            }

            DadaMerchant merchant = DadaMerchantBLL.SingleModel.GetModelByRId(umodel.Id);

            if (merchant == null || merchant.id <= 0)
            {
                msg = "达达配送:商户还没开通达达配送";
                return(0);
            }

            try
            {
                DadaOrder dadaOrderModel = GetDadaOrderModel(merchant.id, userInfo.Id, 0, cityName, 0, accepterName, accepterPhone, address, Convert.ToDouble(lat), Convert.ToDouble(lnt), "", ref msg);
                if (dadaOrderModel == null || !string.IsNullOrEmpty(msg))
                {
                    msg = $"达达配送:获取物流运费失败:" + msg;
                    return(0);
                }

                DadaApiReponseModel <ResultReponseModel> postData = AddOrder(dadaOrderModel, merchant.sourceid, 2);
                if (postData != null && postData.result != null)
                {
                    return(Convert.ToInt32(postData.result.deliverFee * 100));
                }

                log4net.LogHelper.WriteInfo(this.GetType(), "达达运费出错:" + JsonConvert.SerializeObject(postData) + ",请求参数=" + JsonConvert.SerializeObject(dadaOrderModel));

                msg = "获取运费出错";
            }
            catch (Exception ex)
            {
                msg = ex.Message + ",msg" + msg;
            }

            return(0);
        }
示例#7
0
        /// <summary>
        /// 修改订单状态
        /// </summary>
        /// <returns></returns>
        public ActionResult UpdateDadaOrderState()
        {
            string order_id         = Context.GetRequest("order_id", "");
            string merchantid       = Context.GetRequest("merchantid", string.Empty);
            int    state            = Context.GetRequestInt("state", -1);
            int    cancel_reason_id = Context.GetRequestInt("cancel_reason_id", 0);
            string cancel_reason    = Context.GetRequest("cancel_reason", string.Empty);

            if (string.IsNullOrEmpty(merchantid))
            {
                return(Json(new { isok = false, msg = "找不到商户号" }, JsonRequestBehavior.AllowGet));
            }
            if (state == -1)
            {
                return(Json(new { isok = false, msg = "订单状态出错" }, JsonRequestBehavior.AllowGet));
            }

            //DadaOrderRelation orelationmodel = _dadaOrderRelationBll.GetModelUOrderNo(order_id);
            //if (orelationmodel == null)
            //{
            //    return Json(new { isok = false, msg = "找不到系统订单,请刷新重试" }, JsonRequestBehavior.AllowGet);
            //}

            DadaOrder ordermodel = _dadaOrderBll.GetModelByOrderNo(order_id);

            if (ordermodel == null || !(ordermodel.state == (int)DadaOrderEnum.待接单 || ordermodel.state == (int)DadaOrderEnum.待取货))
            {
                return(Json(new { isok = false, msg = "找不到系统订单,请刷新重试" }, JsonRequestBehavior.AllowGet));
            }

            _dadaApi._sourceid = merchantid;
            object data = new object();
            string url  = string.Empty;

            switch (state)
            {
            case 0:    //取消订单
                data = new { order_id = order_id, cancel_reason_id = cancel_reason_id, cancel_reason = cancel_reason };
                url  = _dadaApi._cancelorderapi;
                break;
            }

            string json   = _dadaApi.PostParamJson(data);
            string result = WxHelper.DoPostJson(url, json);

            if (!string.IsNullOrEmpty(result))
            {
                DadaApiReponseModel <ResultReponseModel> resultmodel = JsonConvert.DeserializeObject <DadaApiReponseModel <ResultReponseModel> >(result);
                if (resultmodel.status == "success")
                {
                    ordermodel.state       = (int)DadaOrderEnum.取消中;
                    ordermodel.update_time = DateTime.Now;
                    if (!_dadaOrderBll.Update(ordermodel, "state"))
                    {
                        return(Json(new { isok = false, msg = "更新订单状态失败" }, JsonRequestBehavior.AllowGet));
                    }
                }
                return(Json(new { isok = true, msg = resultmodel.msg }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new { isok = false, msg = "系统繁忙" }, JsonRequestBehavior.AllowGet));
        }