/// <summary> /// 生成UU配送订单 /// </summary> /// <returns></returns> public string AddUUOrder(DistributionApiModel model) { string msg = ""; UUCustomerRelation customerRelation = UUCustomerRelationBLL.SingleModel.GetModelByAid(model.aid, model.storeid, 0); if (customerRelation == null) { msg = "请先配置UU配送"; return(msg); } UUOrderFee feeResult = GetUUFee(model.storeid, model.aid, model.address, ref msg); if (msg.Length > 0) { return(msg); } string orderNum = CommonCore.GetOrderNumByUserId(model.userid.ToString()); string appid = UUApi._appid; string timestamp = UUApi.GetTimestamp(); //店铺信息 ShopInfo shopInfo = GetStoreAddressPoint(customerRelation.AId, customerRelation.StoreId, model.temptype); //生成订单实体类对象 UUOrder data = new UUOrder(appid, timestamp, customerRelation.OpenId, feeResult.price_token, feeResult.total_money, feeResult.need_paymoney, model.accepterName, model.accepterTelePhone, model.remark, UUApi._notisUrl, customerRelation.AId, customerRelation.StoreId, model.temptype, model.ordertype, model.orderid, orderNum); TransactionModel tran = new TransactionModel(); tran.Add(base.BuildAddSql(data)); if (!ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray)) { msg = "添加UU配送订单出错"; } return(msg); }
/// <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> /// <param name="dtype"></param> /// <returns></returns> public int Getpeisongfei(string cityName, string appid, string openid, string lat, string lnt, string accepterName, string accepterPhone, string address, ref string msg, int getWay, int storeId = 0, int aid = 0, int orderPrice = 0) { int fee = 0; try { switch (getWay) { case (int)miniAppOrderGetWay.达达配送: fee = new DadaOrderBLL().GetDadaFee(cityName, appid, openid, accepterName, accepterPhone, address, lat, lnt, ref msg); break; case (int)miniAppOrderGetWay.快跑者配送: fee = KPZOrderBLL.SingleModel.GetKPZFee(storeId, aid, address, lat, lnt, orderPrice, ref msg); fee = fee * 100; break; case (int)miniAppOrderGetWay.UU配送: UUOrderFee uuResult = UUOrderBLL.SingleModel.GetUUFee(storeId, aid, address, ref msg); fee = uuResult != null? uuResult.Fee:0; break; } } catch (Exception) { msg = "无效配送,请检查配送团队是否正常";//快跑者配送团队欠费是获取不到运费的 } return(fee); }
/// <summary> /// 获取UU配送运费 /// </summary> /// <param name="storeId"></param> /// <param name="aid"></param> /// <param name="lat"></param> /// <param name="lnt"></param> /// <param name="orderPrice"></param> /// <returns></returns> public UUOrderFee GetUUFee(int storeId, int aid, string toAddress, ref string msg) { msg = "获取运费出错"; UUOrderFee feeResult = new UUOrderFee(); UUCustomerRelation customerRelation = UUCustomerRelationBLL.SingleModel.GetModelByAid(aid, storeId, 0); if (customerRelation == null) { msg = "UU配送:未设置UU配置"; return(feeResult); } XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid); if (xcxrelation == null) { msg = "UU配送:权限模板不存在"; return(feeResult); } XcxTemplate xcxtemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId); if (xcxtemplate == null) { msg = "UU配送:小程序模板不存在"; return(feeResult); } //店铺信息 ShopInfo shopinfo = GetStoreAddressPoint(aid, storeId, xcxtemplate.Type); UUGetPriceResult result = UUApi.GetOrderPrice(customerRelation.OpenId, shopinfo.ShopAddress, "", toAddress, "", shopinfo.CityName, shopinfo.CountyName); if (result == null) { LogHelper.WriteInfo(this.GetType(), "UU配送:返回结果为null,"); return(feeResult); } if (result.return_code != "ok") { LogHelper.WriteInfo(this.GetType(), $"UU配送配送:请求参数,aid【{aid}】storeid【{storeId}】" + JsonConvert.SerializeObject(result)); msg = result.return_msg; return(feeResult); } else { decimal maxFee = Math.Max(Convert.ToDecimal(result.total_money), Convert.ToDecimal(result.need_paymoney)); int fee = Convert.ToInt32(maxFee * 100); feeResult.Fee = fee; feeResult.price_token = result.price_token; feeResult.total_money = result.total_money; feeResult.need_paymoney = result.need_paymoney; msg = ""; return(feeResult); } }