Exemplo n.º 1
0
        /// <summary>
        /// 获取餐饮版达达订单状态
        /// </summary>
        /// <param name="list"></param>
        /// <param name="rid"></param>
        /// <returns></returns>
        public void GetFoodDadaOrderState(ref List <FoodAdminGoodsOrder> list, int rid)
        {
            if (list == null || list.Count <= 0)
            {
                return;
            }

            string orderis = string.Join(",", list.Where(w => w.GetWay == (int)miniAppOrderGetWay.达达配送).Select(s => s.Id));

            if (!string.IsNullOrEmpty(orderis))
            {
                List <DadaOrderRelation> relist = DadaOrderRelationBLL.SingleModel.GetListByOrderIds(orderis, (int)TmpType.小程序餐饮模板, rid);
                if (relist == null || relist.Count <= 0)
                {
                    return;
                }

                DadaRelation merchantrelation = DadaRelationBLL.SingleModel.GetModelByRid(rid);
                if (merchantrelation == null)
                {
                    return;
                }

                DadaMerchant merchantmodel = DadaMerchantBLL.SingleModel.GetModel(merchantrelation.merchantid);
                if (merchantmodel == null)
                {
                    return;
                }

                string dadaqids = "'" + string.Join("','", relist.Select(s => s.uniqueorderno)) + "'";
                if (string.IsNullOrEmpty(dadaqids))
                {
                    return;
                }

                List <DadaOrder> dadaorderlist = GetListByQOderId(dadaqids);
                if (dadaorderlist == null || dadaorderlist.Count <= 0)
                {
                    return;
                }

                foreach (FoodAdminGoodsOrder orderitem in list)
                {
                    DadaOrderRelation dadarelation = relist.Where(w => w.orderid == orderitem.Id).FirstOrDefault();
                    if (dadarelation != null)
                    {
                        DadaOrder dadaorder = dadaorderlist.Where(w => w.origin_id == dadarelation.uniqueorderno).FirstOrDefault();
                        if (dadaorder != null)
                        {
                            orderitem.State             = dadaorder.state;
                            orderitem.DadaOrderStateStr = Enum.GetName(typeof(DadaOrderEnum), orderitem.State);
                            orderitem.sourceid          = merchantmodel.sourceid;
                            orderitem.dadaorderid       = dadarelation.uniqueorderno;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 注册商户
        /// </summary>
        /// <returns></returns>
        public ActionResult RegistMerchant()
        {
            DadaMerchant data = new DadaMerchant()
            {
                city_name = "上海", contact_name = "测试", contact_phone = "18718463808", email = "*****@*****.**", enterprise_address = "浦东新区", enterprise_name = "点赞科技", mobile = "18718463808"
            };

            //object data = new { city_name = "广州", contact_name = "测试", contact_phone = "18718463808", email = "*****@*****.**", enterprise_address = "天河区", enterprise_name = "点赞科技", mobile = "18718463808"};
            //object data = new { contact_name = "agent" , enterprise_name="上海", enterprise_address = "天河区", city_name = "ceshi", contact_phone = "18718463808", email = "*****@*****.**", mobile = "18718463808"};
            _dadaApi._sourceid = "";
            string json   = _dadaApi.PostParamJson(data);
            string url    = _dadaApi._merchantapi;
            string result = WxHelper.DoPostJson(url, json);

            return(Json(new { isok = true, msg = result }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        public void GetFoodDadaOrderState <T>(ref List <T> list, int rid, int ordertype = (int)TmpType.小程序餐饮模板)
        {
            if (list == null || list.Count <= 0)
            {
                return;
            }
            List <string> orderids = new List <string>();

            foreach (T item in list)
            {
                int sendWay = Convert.ToInt32(item.GetType().GetProperty("GetWay").GetValue(item));
                if (sendWay == (int)miniAppOrderGetWay.达达配送)
                {
                    string orderid = item.GetType().GetProperty("Id").GetValue(item).ToString();
                    orderids.Add(orderid);
                }
            }
            string orderis = string.Join(",", orderids);

            if (!string.IsNullOrEmpty(orderis))
            {
                List <DadaOrderRelation> relist = DadaOrderRelationBLL.SingleModel.GetListByOrderIds(orderis, ordertype, rid);
                if (relist == null || relist.Count <= 0)
                {
                    return;
                }

                DadaRelation merchantrelation = DadaRelationBLL.SingleModel.GetModelByRid(rid);
                if (merchantrelation == null)
                {
                    return;
                }

                DadaMerchant merchantmodel = DadaMerchantBLL.SingleModel.GetModel(merchantrelation.merchantid);
                if (merchantmodel == null)
                {
                    return;
                }

                string dadaqids = "'" + string.Join("','", relist.Select(s => s.uniqueorderno)) + "'";
                if (string.IsNullOrEmpty(dadaqids))
                {
                    return;
                }

                List <DadaOrder> dadaorderlist = GetListByQOderId(dadaqids);
                if (dadaorderlist == null || dadaorderlist.Count <= 0)
                {
                    return;
                }

                foreach (T orderitem in list)
                {
                    int orderid = Convert.ToInt32(orderitem.GetType().GetProperty("Id").GetValue(orderitem).ToString());
                    DadaOrderRelation dadarelation = relist.Where(w => w.orderid == orderid).FirstOrDefault();
                    if (dadarelation != null)
                    {
                        DadaOrder dadaorder = dadaorderlist.Where(w => w.origin_id == dadarelation.uniqueorderno).FirstOrDefault();
                        if (dadaorder != null)
                        {
                            orderitem.GetType().GetProperty("dadastate").SetValue(orderitem, dadaorder.state);
                            orderitem.GetType().GetProperty("DadaOrderStateStr").SetValue(orderitem, Enum.GetName(typeof(DadaOrderEnum), dadaorder.state));
                            orderitem.GetType().GetProperty("sourceid").SetValue(orderitem, merchantmodel.sourceid);
                            orderitem.GetType().GetProperty("dadaorderid").SetValue(orderitem, dadarelation.uniqueorderno);
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 添加达达订单
        /// </summary>
        /// <param name="rid">权限表ID</param>
        /// <param name="userid">用户ID</param>
        /// <param name="orderid">订单ID</param>
        /// <param name="cityname">订单所在城市名</param>
        /// <param name="price">价格(分)</param>
        /// <param name="receivername">收货人姓名</param>
        /// <param name="receivertel">收货人电话</param>
        /// <param name="address">收货地址</param>
        /// <param name="lat">收货地址纬度</param>
        /// <param name="lnt">收货地址经度</param>
        /// <param name="desc">备注</param>
        /// <param name="ordertype">看枚举TmpType</param>
        /// <returns></returns>
        public string AddDadaOrder(DistributionApiModel model)
        {
            string       msg      = "";
            DadaRelation relation = DadaRelationBLL.SingleModel.GetModelByRid(model.aid);

            if (relation != null)
            {
                DadaMerchant merchant = DadaMerchantBLL.SingleModel.GetModel(relation.merchantid);
                if (merchant != null)
                {
                    DadaCity city = DadaCityBLL.SingleModel.GetModelName(model.cityname);
                    if (city == null)
                    {
                        msg = "物流到不了城市" + model.cityname;
                        return(msg);
                    }

                    DadaShop shop = DadaShopBLL.SingleModel.GetModelByMId(merchant.id);
                    if (shop == null)
                    {
                        msg = "物流到不了城市" + model.cityname;
                        return(msg);
                    }

                    TransactionModel tran      = new TransactionModel();
                    string           timestamp = _dadaapi.GetTimeStamp();
                    string           callback  = _dadaapi._ordercallback;
                    string           order_id  = model.userid + DateTime.Now.ToString("yyyyMMddHHmmss");
                    string           shopno    = shop.origin_shop_id;
                    float            buyprice  = model.buyprice / 100.0f;

                    DadaOrder data = new DadaOrder(order_id, city.cityCode, shopno, buyprice, model.accepterName, model.accepterTelePhone, model.address, model.lat, model.lnt, model.remark, timestamp, callback);
                    //data.id = Convert.ToInt32(base.Add(data));
                    tran.Add(base.BuildAddSql(data));

                    DadaOrderRelation orderrelation = new DadaOrderRelation();
                    orderrelation.dataid        = model.aid;
                    orderrelation.orderid       = model.orderid;
                    orderrelation.ordertype     = model.temptype;
                    orderrelation.uniqueorderno = order_id;

                    //orderrelation.id = Convert.ToInt32(DadaOrderRelationBLL.SingleModel.Add(orderrelation));
                    tran.Add(DadaOrderRelationBLL.SingleModel.BuildAddSql(orderrelation));

                    if (!ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray))
                    {
                        msg = "添加达达物流出错";
                    }
                }
                else
                {
                    msg = "找不到商户号";
                }
            }
            else
            {
                msg = "找不到管理表";
            }

            return(msg);
        }
Exemplo n.º 7
0
        public ActionResult SaveData()
        {
            string merchantid  = Context.GetRequest("merchantid", string.Empty);
            string companyname = Context.GetRequest("companyname", string.Empty);
            int    rid         = Context.GetRequestInt("rid", 0);
            string shopno      = Context.GetRequest("shopno", string.Empty);

            if (string.IsNullOrEmpty(merchantid))
            {
                return(Json(new { isok = false, msg = "商户号不能为空" }, JsonRequestBehavior.AllowGet));
            }
            if (string.IsNullOrEmpty(companyname))
            {
                return(Json(new { isok = false, msg = "企业名称不能为空" }, JsonRequestBehavior.AllowGet));
            }
            if (string.IsNullOrEmpty(shopno))
            {
                return(Json(new { isok = false, msg = "店铺编号不能为空" }, JsonRequestBehavior.AllowGet));
            }
            if (rid <= 0)
            {
                return(Json(new { isok = false, msg = "权限表ID不能小于0" }, JsonRequestBehavior.AllowGet));
            }

            DadaRelation dadarelation = DadaRelationBLL.SingleModel.GetModelByRid(rid);

            if (dadarelation != null)
            {
                return(Json(new { isok = false, msg = "该权限ID已经有关联商户号" }, JsonRequestBehavior.AllowGet));
            }

            DadaMerchant dadamerchant = DadaMerchantBLL.SingleModel.GetModelByMId(merchantid);

            if (dadamerchant != null)
            {
                return(Json(new { isok = false, msg = "该商户号已经存在" }, JsonRequestBehavior.AllowGet));
            }
            dadamerchant = new DadaMerchant()
            {
                sourceid = merchantid
            };

            DadaShop dadashop = DadaShopBLL.SingleModel.GetModelByShopNo(shopno);

            if (dadashop != null)
            {
                return(Json(new { isok = false, msg = "该门店已经存在" }, JsonRequestBehavior.AllowGet));
            }

            int mid = Convert.ToInt32(DadaMerchantBLL.SingleModel.Add(dadamerchant));

            if (mid > 0)
            {
                dadarelation = new DadaRelation()
                {
                    merchantid = mid, rid = rid, state = 0, addtime = DateTime.Now
                };
                int relationid = Convert.ToInt32(DadaRelationBLL.SingleModel.Add(dadarelation));

                dadashop = new DadaShop()
                {
                    origin_shop_id = shopno, merchantid = mid
                };
                int shopid = Convert.ToInt32(DadaShopBLL.SingleModel.Add(dadashop));
                if (relationid > 0 && shopid > 0)
                {
                    return(Json(new { isok = true, msg = "保存成功" }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new { isok = false, msg = "保存失败" }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 达达配送配置
        /// </summary>
        /// <returns></returns>

        public ActionResult DaDaPeiSongConfig(int aId, string act, int storeId, DadaMerchant model = null)
        {
            //int id = Context.GetRequestInt("id", 0);
            //int aId = Context.GetRequestInt("aId", 0);
            //int storeId = Context.GetRequestInt("storeId", 0);
            //string act = Context.GetRequest("act", string.Empty);
            //string mobile = Context.GetRequest("mobile", string.Empty);
            //string city_name = Context.GetRequest("city_name", string.Empty);
            //int source_id = Context.GetRequestInt("source_id", 0);
            //string origin_shop_id = Context.GetRequest("origin_shop_id", string.Empty);
            //string enterprise_name = Context.GetRequest("enterprise_name", string.Empty);

            //参数验证
            if (aId <= 0)
            {
                _result.msg = "参数错误";
                return(Json(_result));
            }
            //显示
            if (string.IsNullOrEmpty(act))
            {
                EditModel <DadaMerchant> em = new EditModel <DadaMerchant>();
                em.appId   = aId;
                em.storeId = storeId;
                em.aId     = aId;
                DadaMerchant dadamerchantmodel = DadaMerchantBLL.SingleModel.GetModelByRId(aId, storeId);
                if (dadamerchantmodel != null && dadamerchantmodel.id > 0)
                {
                    DadaShop dadashopmodel = DadaShopBLL.SingleModel.GetModelByMId(dadamerchantmodel.id);
                    if (dadashopmodel == null)
                    {
                        return(Content("店铺信息失效!"));
                    }
                    dadamerchantmodel.origin_shop_id = dadashopmodel.origin_shop_id;
                }
                List <DadaCity> citylist = DadaCityBLL.SingleModel.GetList();
                dadamerchantmodel.CityList = citylist;
                em.DataModel = dadamerchantmodel;

                return(View(em));
            }
            else
            {
                if (act == "edit")
                {
                    if (model == null)
                    {
                        _result.msg = "参数出错";
                        return(Json(_result));
                    }
                    if (string.IsNullOrEmpty(model.mobile))
                    {
                        _result.msg = "请输入商户手机号";
                        return(Json(_result));
                    }
                    if (string.IsNullOrEmpty(model.city_name) || model.city_name == "0")
                    {
                        _result.msg = "请选择城市";
                        return(Json(_result));
                    }
                    if (string.IsNullOrEmpty(model.sourceid))
                    {
                        _result.msg = "请输入您在达达注册的商户ID";
                        return(Json(_result));
                    }
                    if (string.IsNullOrEmpty(model.origin_shop_id))
                    {
                        _result.msg = "请输入您在达达添加的门店编号";
                        return(Json(_result));
                    }
                    if (string.IsNullOrEmpty(model.enterprise_name))
                    {
                        _result.msg = "请输入您在达达注册的商户企业全称";
                        return(Json(_result));
                    }
                    //添加
                    if (model.id == 0)
                    {
                        DadaMerchant merchantmodel = DadaMerchantBLL.SingleModel.GetModelByMId(model.sourceid);
                        if (merchantmodel != null)
                        {
                            _result.msg = "该商户ID已被绑定,请重新输入";
                            return(Json(_result));
                        }
                        DadaShop dadashopmodel = DadaShopBLL.SingleModel.GetModelByShopNo(model.origin_shop_id);
                        if (dadashopmodel != null)
                        {
                            _result.msg = "该门店编号已被绑定,请重新输入";
                            return(Json(_result));
                        }
                        bool success = DadaMerchantBLL.SingleModel.AddDadaMerchant(model, aId, storeId);
                        _result.msg  = success ? "保存成功" : "保存失败";
                        _result.code = success ? 1 : 0;
                    }
                    //修改
                    else
                    {
                        string msg          = "";
                        bool   updateResult = DadaMerchantBLL.SingleModel.UpdateDadaMerchant(model, ref msg);
                        _result.msg  = updateResult ? "保存成功" : "保存失败";
                        _result.code = updateResult ? 1 : 0;
                    }
                }
            }
            return(Json(_result));
        }