/// <summary> /// 获取达达订单对象 /// </summary> /// <param name="merchantid">商户表ID</param> /// <param name="userid">用户ID</param> /// <param name="order_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> /// <returns></returns> public DadaOrder GetDadaOrderModel(int merchantid, int userid, int orderid, string cityname, float price, string receivername, string receivertel, string address, double lat, double lnt, string desc, ref string msg) { DadaOrder data = new DadaOrder(); DadaCity city = DadaCityBLL.SingleModel.GetModelName(cityname); if (city == null) { msg = "物流到不了城市" + cityname; return(new DadaOrder()); } DadaShop shop = DadaShopBLL.SingleModel.GetModelByMId(merchantid); if (shop == null) { msg = "没有找到店铺:" + merchantid; return(new DadaOrder()); } TransactionModel tran = new TransactionModel(); string timestamp = _dadaapi.GetTimeStamp(); string callback = _dadaapi._ordercallback; string order_id = userid + DateTime.Now.ToString("yyyyMMddHHmmss"); string shopno = shop.origin_shop_id; data = new DadaOrder(order_id, city.cityCode, shopno, price, receivername, receivertel, address, lat, lnt, desc, timestamp, callback); return(data); }
public bool UpdateDadaMerchant(DadaMerchant model, ref string msg) { TransactionModel tran = new TransactionModel(); DadaMerchant merchantmodel = base.GetModel(model.id); if (merchantmodel == null) { msg = "商户号数据失效了,请刷新重试"; return(false); } merchantmodel.city_name = model.city_name; merchantmodel.enterprise_name = model.enterprise_name; merchantmodel.mobile = model.mobile; merchantmodel.sourceid = model.sourceid.ToString(); tran.Add(base.BuildUpdateSql(merchantmodel, "city_name,enterprise_name,mobile,sourceid")); DadaShop dadashopmodel = DadaShopBLL.SingleModel.GetModelByMId(model.id); if (dadashopmodel == null) { msg = "达达店铺数据失效了,请刷新重试"; return(false); } dadashopmodel.origin_shop_id = model.origin_shop_id; tran.Add(DadaShopBLL.SingleModel.BuildUpdateSql(dadashopmodel, "origin_shop_id")); bool success = base.ExecuteTransaction(tran.sqlArray); return(success); }
public bool AddDadaMerchant(DadaMerchant model, int aid, int storeid = 0) { TransactionModel tran = new TransactionModel(); DadaMerchant merchantmodel = new DadaMerchant(); merchantmodel.city_name = model.city_name; merchantmodel.enterprise_name = model.enterprise_name; merchantmodel.mobile = model.mobile; merchantmodel.sourceid = model.sourceid.ToString(); tran.Add(base.BuildAddSql(merchantmodel)); DadaRelation dadarelationmodel = new DadaRelation(); dadarelationmodel.addtime = DateTime.Now; dadarelationmodel.rid = aid; dadarelationmodel.StoreId = storeid; tran.Add(Utils.BuildAddSqlS(dadarelationmodel, "merchantid", "(select LAST_INSERT_ID())", DadaRelationBLL.SingleModel.TableName, DadaRelationBLL.SingleModel.arrProperty)); DadaShop dadashopmodel = new DadaShop(); dadashopmodel.origin_shop_id = model.origin_shop_id; tran.Add(Utils.BuildAddSqlS(dadashopmodel, "merchantid", $"(select merchantid from DadaRelation where rid={aid} and storeid={storeid} LIMIT 1)", DadaShopBLL.SingleModel.TableName, DadaShopBLL.SingleModel.arrProperty)); bool success = base.ExecuteTransaction(tran.sqlArray); return(success); }
/// <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); }
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)); }
/// <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)); }