public ActionResult Record(int aid = 0, int storeId = 0, int pageIndex = 1, int pageSize = 15) { if (aid <= 0 || storeId <= 0) { return(Content("参数错误")); } PinStore store = PinStoreBLL.SingleModel.GetModelByAid_Id(aid, storeId); if (store == null) { result.msg = "店铺信息错误"; return(Json(result)); } ViewModel <DrawCashApply> vm = new ViewModel <DrawCashApply>(); int recordCount = 0; vm.DataList = DrawCashApplyBLL.SingleModel.GetListByAid_UserId(aid, store.userId, pageIndex, pageSize, out recordCount); vm.TotalCount = recordCount; vm.aId = aid; vm.storeId = storeId; vm.PageIndex = pageIndex; vm.PageSize = pageSize; return(View(vm)); }
/// <summary> /// 申请通过处理 /// </summary> /// <param name="apply"></param> /// <param name="store"></param> /// <returns></returns> public bool ApplySuccess(PinRefundApply apply, PinStore store, ref string msg) { bool result = false; if (apply.type == 2 || apply.type == 3) { if (string.IsNullOrEmpty(store.setting.place) || string.IsNullOrEmpty(store.setting.phone) || string.IsNullOrEmpty(store.setting.name)) { msg = "请前往店铺配置设置您的退换货寄件信息"; return(result); } } PinGoodsOrderBLL orderBLL = new PinGoodsOrderBLL(); PinGoodsOrder order = orderBLL.GetModel(apply.orderId); if (order == null) { msg = "订单不存在"; return(result); } order.state = apply.orderState; order.returnCount += apply.count; order.state = order.returnCount == order.count ? order.state = (int)PinOrderState.交易取消 : order.state = apply.orderState; orderBLL.Update(order, "state,returncount,state"); PinGroupBLL.SingleModel.RollbackEntrantCount(order, ref msg); result = Update(apply, "state,updatetime"); return(result); }
/// <summary> /// 提交验证短信验证码 /// </summary> /// <param name="utoken"></param> /// <param name="postData"> /// { /// tel:"", /// code:"", /// appid:"" /// } /// </param> /// <returns></returns> public ReturnMsg ValidateSMS(PinStore store, string code = "") { C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(store.userId); if (userInfo == null) { result.msg = "用户信息错误!"; return(result); } XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModel(store.aId); if (xcx == null) { result.msg = "小程序信息错误!"; return(result); } if (string.IsNullOrEmpty(code)) { result.msg = "验证码不能为空!"; return(result); } string serverAuthCode = RedisUtil.Get <string>(userInfo.TelePhone); if (serverAuthCode != code) { result.msg = "验证码错误!"; return(result); } RedisUtil.Remove(userInfo.TelePhone); result.code = 1; result.msg = "验证成功"; return(result); }
/// <summary> /// 扫码监听 /// </summary> /// <returns></returns> public ActionResult CheckScan(string wxkey = "", int storeId = 0) { PinStore pinStore = (PinStore)Request.RequestContext.RouteData.Values["pinStore"]; if (pinStore == null) { result.msg = "信息错误,请重新登录" + storeId; return(Json(result)); } if (string.IsNullOrEmpty(wxkey)) { result.msg = "wxkey为空"; return(Json(result)); } ScanModel model = RedisUtil.Get <ScanModel>("wxbindSessionID:" + wxkey); if (model == null || model.userInfo == null) { result.msg = "未扫码"; return(Json(result)); } result.obj = new { userInfo = model.userInfo }; pinStore.wxOpenId = model.userInfo.openid; if (PinStoreBLL.SingleModel.Update(pinStore, "wxopenid")) { result.msg = "绑定成功"; result.code = 1; } else { result.msg = "绑定失败"; } return(Json(result)); }
/// <summary> /// 提现申请界面 /// </summary> /// <param name="aId"></param> /// <param name="storeId"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> // GET: PinAdmin/Cash public ActionResult Index(int aId = 0, int storeId = 0) { if (aId <= 0 || storeId <= 0) { return(Content("参数错误")); } PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid(aId); if (platform == null) { return(Content("平台信息错误")); } PinStore store = (PinStore)Request.RequestContext.RouteData.Values["pinStore"]; C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(store.userId); if (userInfo == null) { return(Content($"用户信息错误")); } PinAgent agent = PinAgentBLL.SingleModel.GetModelByUserId(userInfo.Id); int sumCash = DrawCashApplyBLL.SingleModel.GetSumCash(aId, store.userId); ViewBag.DrawCashSum = (sumCash * 0.01).ToString("0.00"); ViewData["platform"] = platform; ViewData["userInfo"] = userInfo; ViewData["agent"] = agent; return(View(store)); }
public ActionResult GetGoodsList(int aid = 0, int pageIndex = 1, int pageSize = 15) { if (aid <= 0) { result.msg = "参数错误"; return(Json(result)); } int recordCount = 0; List <PinGoods> goodsList = PinGoodsBLL.SingleModel.GetListByAid_State(aid, (int)PinEnums.GoodsState.架, pageIndex, pageSize, out recordCount); if (goodsList != null && goodsList.Count > 0) { string storeIds = string.Join(",", goodsList.Select(s => s.storeId).Distinct()); List <PinStore> pinStoreList = PinStoreBLL.SingleModel.GetListByIds(storeIds); goodsList.ForEach(goods => { PinStore store = pinStoreList?.FirstOrDefault(f => f.id == goods.storeId); if (store != null) { goods.storeName = store.storeName; } }); } result.code = 1; result.obj = new { list = goodsList, recordCount }; return(Json(result)); }
public ActionResult StoreEdit(PinStore store, string act = "") { if (store == null || store.aId <= 0 || store.id <= 0) { if (act != "save") { return(Content("参数错误")); } else { result.code = 0; result.msg = "参数错误"; return(Json(result)); } } PinStore model = PinStoreBLL.SingleModel.GetModelByAid_Id(store.aId, store.id); if (act != "save") { return(View(model)); } else { if (model == null) { result.code = 0; result.msg = "店铺不存在"; return(Json(result)); } if (DateTime.Compare(store.endDate, store.startDate) < 0) { result.code = 0; result.msg = "请输入合理的时间范围"; return(Json(result)); } model.storeName = store.storeName; model.logo = store.logo; model.startDate = store.startDate; model.endDate = store.endDate; model.state = store.state; model.rz = store.rz; model.loginName = store.loginName; if (!string.IsNullOrEmpty(store.password)) { model.password = DESEncryptTools.GetMd5Base32(store.password); } if (PinStoreBLL.SingleModel.Update(model, "storeName,logo,startDate,endDate,state,rz,loginName,password")) { result.code = 1; result.msg = "保存成功"; return(Json(result)); } else { result.code = 0; result.msg = "保存失败"; return(Json(result)); } } }
public ActionResult SearchUserInfo(int aid = 0, string nickName = "", int storeId = 0) { if (aid <= 0 || string.IsNullOrEmpty(nickName) || storeId <= 0) { result.code = 0; result.msg = "参数错误"; return(Json(result)); } XcxAppAccountRelation xcxRelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid); if (xcxRelation == null) { result.code = 0; result.msg = "小程序不存在"; return(Json(result)); } PinStore store = PinStoreBLL.SingleModel.GetModelByAid_Id(aid, storeId); if (store == null) { result.code = 0; result.msg = "门店不存在"; return(Json(result)); } C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModelByNickName(xcxRelation.AppId, nickName); result.code = 1; result.obj = userInfo; return(Json(result)); }
public ActionResult ResetPwd(string act = "", string loginname = "", string password = "", string authCode = "", int aid = 0) { if (!string.IsNullOrEmpty(act)) { if (act == "reset") { PinStore store = PinStoreBLL.SingleModel.GetStoreByPhone(loginname); if (store == null) { result.msg = "店铺不存在,请检查手机号码是否正确"; return(Json(result)); } string code = RedisUtil.Get <string>(loginname); if (code == "" || authCode == "" || code != authCode) { result.msg = "验证码错误"; return(Json(result)); } store.password = DESEncryptTools.GetMd5Base32(password); if (PinStoreBLL.SingleModel.Update(store, "password")) { result.msg = "密码重置成功,请登陆"; } else { result.msg = "重置失败,请重试"; } return(Json(result)); } } return(View()); }
public ActionResult Login(string act = "", string loginName = "", string password = "", string verify = "") { if (!string.IsNullOrEmpty(act)) { if (act == "login") { if (string.IsNullOrEmpty(loginName) || string.IsNullOrEmpty(password)) { result.msg = "用户名和密码不能为空"; return(Json(result)); } PinStore store = PinStoreBLL.SingleModel.GetAdminByLoginParams(loginName, password); if (store != null) { result.code = 1; result.obj = new { store.aId, storeId = store.id, }; result.msg = Utility.DESEncryptTools.DESEncrypt(store.id.ToString()); return(Json(result)); //Utility.CookieHelper.SetCookie("dzDishAdmin", Utility.DESEncryptTools.DESEncrypt(store.id.ToString()), WebConfigBLL.CookieDomain); } else { result.code = 0; result.msg = "用户名或密码错误"; } return(Json(result)); } } return(View()); }
/// <summary> /// 售后申请状态处理 /// </summary> /// <returns></returns> public ActionResult UpdateRefundApplyState(int aid = 0, int storeId = 0, int state = 0, int id = 0) { if (aid <= 0 || storeId <= 0 || id <= 0) { result.msg = "参数错误"; return(Json(result)); } PinRefundApply apply = PinRefundApplyBLL.SingleModel.GetModel(id); if (apply == null || apply.id == (int)RefundApplyState.除) { result.msg = "申请不存在"; return(Json(result)); } PinStore store = PinStoreBLL.SingleModel.GetModelByAid_Id(aid, storeId); if (store == null) { result.msg = "店铺信息错误"; return(Json(result)); } string msg = string.Empty; bool status = false; apply.state = state; apply.updateTime = DateTime.Now; switch (state) { case (int)RefundApplyState.已退款: status = orderBLL.RefundByApply(apply, ref msg); break; case (int)RefundApplyState.已重新发货: case (int)RefundApplyState.申请失败: status = PinRefundApplyBLL.SingleModel.ApplyFail(apply, ref msg); break; case (int)RefundApplyState.除: status = PinRefundApplyBLL.SingleModel.Update(apply, "state,updatetime"); break; case (int)RefundApplyState.申请成功: status = PinRefundApplyBLL.SingleModel.ApplySuccess(apply, store, ref msg); break; default: result.msg = "参数错误!"; return(Json(result)); } if (status) { result.code = 1; result.msg = "操作成功"; } else { result.msg = "操作失败"; } return(Json(result)); }
public ActionResult GetAuthCode(string telphone = "", string act = "") { if (!Regex.IsMatch(telphone, @"^1[3-9]+\d{9}$")) { result.msg = "手机号码格式不正确!"; return(Json(result)); } PinStore store = PinStoreBLL.SingleModel.GetStoreByPhone(telphone); if (store != null && act == "") { result.msg = "用户名已存在,请登陆"; return(Json(result)); } SendMsgHelper sendMsgHelper = new SendMsgHelper(); string authCode = RedisUtil.Get <string>(telphone); if (string.IsNullOrEmpty(authCode)) { authCode = EncodeHelper.CreateRandomCode(4); } bool sendResult = sendMsgHelper.AliSend(telphone, "{\"code\":\"" + authCode + "\",\"product\":\" " + Enum.GetName(typeof(SendTypeEnum), 11) + "\"}", "小未科技", 401); if (sendResult) { RedisUtil.Set <string>(telphone, authCode, TimeSpan.FromMinutes(5)); result.code = 1; result.msg = "验证码发送成功!"; } else { result.msg = "验证码发送失败,请稍后再试!"; } return(Json(result)); }
/// <summary> /// 订单取消发送订单取消通知模板消息 /// </summary> /// <param name="pinOrder"></param> public void SendTemplateMsg_PayCancel(PinGoodsOrder pinOrder) { PinStore store = PinStoreBLL.SingleModel.GetModelByAid_Id(pinOrder.aid, pinOrder.storeId); if (store == null && pinOrder.orderType == 0) { log4net.LogHelper.WriteError(GetType(), new Exception($"拼享惠发送订单取消模板消息失败,找不到店铺信息 aid:{pinOrder.aid}, storeid:{pinOrder.storeId}")); return; } //如果未支付,获取预支付码的formid是无效的,要取消 if (pinOrder.payState == (int)PayState.未付款) { C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(pinOrder.userId); if (userInfo == null) { log4net.LogHelper.WriteError(GetType(), new Exception($"拼享惠发送订单取消模板消息失败,找不到用户信息 userid:{pinOrder.userId}")); return; } TemplateMsg_UserParam userParam = TemplateMsg_UserParamBLL.SingleModel.GetModel($" Form_Id is not null and appId = '{userInfo.appId}' and Open_Id = '{userInfo.OpenId}' and State = 1 and LoseDateTime > now() and orderId={pinOrder.id} "); if (userParam != null) { userParam.State = -1; TemplateMsg_UserParamBLL.SingleModel.Update(userParam, "state"); } } //发给用户通知 object orderData = TemplateMsg_Miniapp.PinGetTemplateMessageData(SendTemplateMessageTypeEnum.拼享惠订单取消通知, order: pinOrder, store: store); TemplateMsg_Miniapp.SendTemplateMessage(pinOrder.userId, SendTemplateMessageTypeEnum.拼享惠订单取消通知, TmpType.拼享惠, orderData, $"pages/shopping/orderInfo/orderInfo?orderid={pinOrder.id}&storeid={pinOrder.storeId}"); }
/// <summary> ///通知设置 /// </summary> /// <param name="aId"></param> /// <param name="storeId"></param> /// <returns></returns> public ActionResult NoticeSetting(int aId = 0, int storeId = 0) { if (aId <= 0 || storeId <= 0) { return(Content("参数错误")); } string appId = Senparc.Weixin.Config.SenparcWeixinSetting.WeixinAppId;//公众号appid PinStore pinStore = (PinStore)Request.RequestContext.RouteData.Values["pinStore"]; if (pinStore == null) { return(Content("信息错误,请重新登录")); } UserInfoJson userInfo = null; if (!string.IsNullOrEmpty(pinStore.wxOpenId)) { userInfo = UserApi.Info(appId, pinStore.wxOpenId, Language.zh_CN); } string sessonid = new Random().Next(1, 3) + DateTime.Now.ToString("mmssfffff"); Session["wxbindqrcodekey"] = sessonid; if (null == RedisUtil.Get <ScanModel>("wxbindSessionID:" + sessonid)) { ScanModel model = new ScanModel(); RedisUtil.Set <ScanModel>("wxbindSessionID:" + sessonid, model, TimeSpan.FromDays(1)); } ViewBag.StoreId = storeId; return(View(userInfo)); }
public ActionResult GetAgentList(int aid = 0, int pageIndex = 1, int pageSize = 10, int state = -999, string phone = "", string nickName = "", string fnickName = "", string fphone = "") { if (aid <= 0 || pageIndex <= 0 || pageSize <= 0) { result.code = 0; result.msg = "参数错误"; return(Json(result)); } XcxAppAccountRelation xcxAppAccountRelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid); if (xcxAppAccountRelation == null) { result.code = 0; result.msg = "小程序不存在"; return(Json(result)); } int recordCount = 0; List <PinStore> storeList = new List <PinStore>(); List <PinAgent> agentList = PinAgentBLL.SingleModel.GetListByAid_State(xcxAppAccountRelation.AppId, aid, pageSize, pageIndex, out recordCount, phone: phone, nickName: nickName, fnickName: fnickName, fphone: fphone, state: -999); if (agentList != null && agentList.Count > 0) { foreach (var agent in agentList) { PinStore store = PinStoreBLL.SingleModel.GetModelByAid_UserId(agent.aId, agent.userId); if (store != null && store.state != -1) { store.goodsCount = PinGoodsBLL.SingleModel.GetCountByStoreId(store.id); store.agentInfo = agent; store.userId = agent.userId; } else { store = new PinStore() { storeName = "未开通店铺", userId = agent.userId }; store.agentInfo = agent; } store.agentFee = PinAgentBLL.SingleModel.GetAgentFee(store.agentInfo.id); C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(agent.userId); store.nickName = userInfo != null ? userInfo.NickName : string.Empty; if (agent.fuserId > 0) { store.fuserInfo = C_UserInfoBLL.SingleModel.GetModel(agent.fuserId); } storeList.Add(store); } } result.code = 1; result.obj = new { list = storeList, recordCount }; return(Json(result)); }
public ActionResult SendSMS(int aid = 0, int storeId = 0) { try { PinStore store = PinStoreBLL.SingleModel.GetModelByAid_Id(aid, storeId); if (store == null) { result.msg = "店铺不存在!"; return(Json(result)); } C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(store.userId); if (userInfo == null) { result.msg = "用户信息错误!"; return(Json(result)); } if (string.IsNullOrEmpty(userInfo.TelePhone) || !Regex.IsMatch(userInfo.TelePhone, @"^1[3-9]+\d{9}$")) { result.msg = "手机号码格式不正确!"; return(Json(result)); } XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModel(aid); if (xcx == null) { result.msg = "小程序信息错误!"; return(Json(result)); } SendMsgHelper sendMsgHelper = new SendMsgHelper(); string authCode = RedisUtil.Get <string>(userInfo.TelePhone); if (string.IsNullOrEmpty(authCode)) { authCode = Utility.EncodeHelper.CreateRandomCode(4); } bool sendResult = sendMsgHelper.AliSend(userInfo.TelePhone, "{\"code\":\"" + authCode + "\",\"product\":\" " + Enum.GetName(typeof(SendTypeEnum), 11) + "\"}", "小未科技", 401); if (sendResult) { RedisUtil.Set <string>(userInfo.TelePhone, authCode, TimeSpan.FromMinutes(5)); result.code = 1; result.msg = "验证码发送成功!"; } else { result.msg = "验证码发送失败,请稍后再试!"; } result.obj = authCode; return(Json(result)); } catch (Exception ex) { result.msg = "系统异常!" + ex.Message; return(Json(result));; } }
/// <summary> /// 拼享惠商家提现 /// </summary> /// <param name="aid"></param> /// <param name="storeId"></param> /// <param name="userId"></param> /// <param name="account"></param> /// <param name="accountName"></param> /// <param name="cash"></param> /// <param name="drawCashWay"></param> /// <returns>0失败 1成功</returns> public int PxhAddApply(PinStore store, int userId, string account, string accountName, int cash, int drawCashWay, int serviceFee, int applyType, int xwkjUserId = 0) { string filed = string.Empty; string useCash = string.Empty; if (applyType == (int)DrawCashApplyType.拼享惠平台交易) { filed = "cash"; store.cash -= cash; useCash = store.cashStr; } else { filed = "qrcodecash"; store.qrcodeCash -= cash; useCash = store.qrcodeCashStr; } TransactionModel tran = new TransactionModel(); MySqlParameter[] pone = null; tran.Add(PinStoreBLL.SingleModel.BuildUpdateSql(store, filed, out pone), pone); int code = 0; XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModel(store.aId); if (xcx == null) { log4net.LogHelper.WriteError(GetType(), new Exception($"拼享惠申请提现失败:小程序信息错误 aid:{store.aId}")); return(code); } string partner_trade_no = WxPayApi.GenerateOutTradeNo(); DrawCashApply apply = new DrawCashApply() { Aid = store.aId, appId = xwkjUserId == 0 ? xcx.AppId : WebSiteConfig.GongZhongAppId, userId = xwkjUserId == 0 ? userId : xwkjUserId, partner_trade_no = partner_trade_no, applyMoney = cash, serviceMoney = serviceFee, cashMoney = cash - serviceFee, useCash = useCash, AddTime = DateTime.Now, remark = "拼享惠商户申请提现", hostIP = Utility.WebHelper.GetIP(), applyType = applyType, account = account, accountName = accountName, drawCashWay = drawCashWay, OrderId = userId, }; tran.Add(BuildAddSql(apply)); code = base.ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray) ? 1 : 0; return(code); }
public override void OnAuthorization(AuthorizationContext filterContext) { //TODO 开发阶段屏蔽登陆验证 //return; if (filterContext.ActionDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true)) { return; } int storeId = Context.GetRequestInt("storeId", 0); if (storeId > 0) { string cookieSoreId = CookieHelper.GetCookie("dzPinAdmin"); //如果没有找到登陆cookie if (string.IsNullOrEmpty(cookieSoreId)) { filterContext.Result = new RedirectResult("/PinAdmin/main/login"); return; } int storeid = 0; int.TryParse(DESEncryptTools.DESDecrypt(cookieSoreId), out storeid); //如果登陆cookie无法解密 if (storeid <= 0) { filterContext.Result = new RedirectResult("/PinAdmin/main/login"); return; } //只能进对应的管理后台 if (storeid != storeId) { filterContext.Result = new RedirectResult("/PinAdmin/main/login"); return; } PinStore pinStore = PinStoreBLL.SingleModel.GetModel(storeid); //如果门店不存在 if (pinStore == null) { filterContext.Result = new RedirectResult("/PinAdmin/main/login"); return; } filterContext.RouteData.Values["pinStore"] = pinStore; } else { filterContext.Result = new RedirectResult("/PinAdmin/main/login"); return; } }
/// <summary> /// 订单配送通知模板消息 /// </summary> /// <param name="pinOrder"></param> public void SendTemplateMsg_Send(PinGoodsOrder pinOrder) { PinStore store = PinStoreBLL.SingleModel.GetModelByAid_Id(pinOrder.aid, pinOrder.storeId); if (store == null && pinOrder.orderType == 0) { log4net.LogHelper.WriteError(GetType(), new Exception($"拼享惠订单配送模板消息失败,找不到店铺信息 aid:{pinOrder.aid}, storeid:{pinOrder.storeId}")); return; } //发给用户通知 object orderData = TemplateMsg_Miniapp.PinGetTemplateMessageData(SendTemplateMessageTypeEnum.拼享惠订单配送通知, order: pinOrder, store: store); TemplateMsg_Miniapp.SendTemplateMessage(pinOrder.userId, SendTemplateMessageTypeEnum.拼享惠订单配送通知, TmpType.拼享惠, orderData, $"pages/shopping/orderInfo/orderInfo?orderid={pinOrder.id}&storeid={pinOrder.storeId}"); }
public ActionResult SaveStoreInfo(PinStore store, SettingModel setting) { if (!ModelState.IsValid) { result.code = 0; result.msg = this.ErrorMsg(); return(Json(result)); } if (store.aId <= 0 || store.id <= 0) { result.code = 0; result.msg = "参数错误"; return(Json(result)); } PinStore model = PinStoreBLL.SingleModel.GetModelByAid_Id(store.aId, store.id); if (model == null) { result.code = 0; result.msg = "门店不存在"; return(Json(result)); } model.kfUserIds = store.kfUserIds; SettingModel modelSetting = model.setting; modelSetting.autoWelcome = setting.autoWelcome; modelSetting.kfPhone = setting.kfPhone; modelSetting.openIm = setting.openIm; modelSetting.openKfPhone = setting.openKfPhone; modelSetting.voiceTips = setting.voiceTips; modelSetting.welcome = setting.welcome; modelSetting.openZq = setting.openZq; modelSetting.place = setting.place; modelSetting.name = setting.name; modelSetting.phone = setting.phone; model.settingJson = JsonConvert.SerializeObject(modelSetting); if (PinStoreBLL.SingleModel.Update(model, "settingJson,kfUserIds")) { result.code = 1; result.msg = "保存成功"; } else { result.code = 0; result.msg = "保存失败"; } return(Json(result)); }
/// <summary> /// 拼享惠商家提现:返回提现金额 /// </summary> /// <param name="apply"></param> /// <returns></returns> public bool ReturnPinStoreCash(DrawCashApply apply, TransactionModel tranModel = null) { bool isTran = tranModel != null; if (!isTran) { tranModel = new TransactionModel(); } //MySqlParameter[] pone = null; tranModel.Add(base.BuildUpdateSql(apply, "drawState,DrawTime,remark,state,UpdateTime")); //判断是否是拼享惠公众号提现 if (apply.appId == WebSiteConfig.GongZhongAppId) { apply.userId = apply.OrderId; } PinStore store = PinStoreBLL.SingleModel.GetModelByAid_UserId(apply.Aid, apply.userId); if (store == null) { log4net.LogHelper.WriteError(GetType(), new Exception($" 拼享惠商家提现:返回提现金额失败,找不到商家 aid:{apply.Aid} userId:{ apply.userId}")); return(false); } int money = apply.cashMoney + apply.serviceMoney; string fileds = string.Empty; switch (apply.applyType) { case (int)DrawCashApplyType.拼享惠平台交易: store.cash += money; fileds = "cash"; break; case (int)DrawCashApplyType.拼享惠扫码收益: store.qrcodeCash += money; fileds = "qrcodeCash"; break; default: return(false); } //pone = null; tranModel.Add(PinStoreBLL.SingleModel.BuildUpdateSql(store, fileds)); if (isTran) { return(true); } return(base.ExecuteTransactionDataCorect(tranModel.sqlArray, tranModel.ParameterArray)); }
public DeliveryFeeResult GetFreightInfo(PinGoods good, int buyCount, string province, string city) { PinStore store = PinStoreBLL.SingleModel.GetModelByAid_Id(good.aId, good.storeId); if (store == null) { return(new DeliveryFeeResult { InRange = true, Message = "店铺不存在" }); } if (!store.setting.freightSwitch) { return(new DeliveryFeeResult { InRange = true, Message = "未开启运费模板功能,默认零元运费" }); } DeliveryFeeSumMethond sumMethod; if (!Enum.TryParse(store.setting.freightSumRule.ToString(), out sumMethod)) { return(new DeliveryFeeResult { Message = "运费规则设置异常" }); } DeliveryProduct product = new DeliveryProduct { Count = buyCount, Id = good.id, Name = good.name, TemplateId = good.FreightTemplate, Weight = good.GetAttrbute().Weight, }; DeliveryFeeResult result = GetDeliveryFeeCommon(new List <DeliveryProduct> { product }, province, city, sumMethod); if (result.Fee > 0) { result.Message = $"[{sumMethod}]{result.Message}"; } return(result); }
/// <summary> /// 订单提成日志 /// </summary> /// <param name="store"></param> /// <param name="pinOrder"></param> /// <param name="tran"></param> /// <returns></returns> public bool AddAgentLog(PinStore store, int money, PinAgent agent, TransactionModel tran = null, string remark = "", int second = 0) { bool istran = tran != null; if (!istran) { tran = new TransactionModel(); } PinAgentIncomeLog log = new PinAgentIncomeLog() { aId = store.aId, agentId = agent.id,//store.agentId, sourceUid = store.userId, income = money, source = 1 }; log.remark = $"店铺:{store.storeName} 订单提现,{remark}"; log.beforeMoney = agent.cash; log.afterMoney = agent.cash + money; C_UserInfo fuserInfo = C_UserInfoBLL.SingleModel.GetModel(agent.userId); if (fuserInfo == null) { log.remark = $"代理付费日志出错:找不到代理用户信息 userid:{agent.userId}"; log4net.LogHelper.WriteError(GetType(), new Exception(log.remark)); tran.Add(BuildAddSql(log)); if (istran) { return(true); } return(ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray)); } string s = second == 1 ? "来自下下级" : string.Empty; log.remark += $",{fuserInfo.NickName}获得提成{s}{log.incomeStr}元"; tran.Add(BuildAddSql(log)); if (istran) { return(true); } return(ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray)); }
public ActionResult StoreSetting(int aid = 0, int storeId = 0, int Index = 0) { if (aid <= 0 || storeId <= 0) { return(Content("参数错误")); } PinStore pinStore = PinStoreBLL.SingleModel.GetModelByAid_Id(aid, storeId); if (pinStore != null && !string.IsNullOrEmpty(pinStore.kfUserIds)) { pinStore.kfUserInfo = C_UserInfoBLL.SingleModel.GetModel(Convert.ToInt32(pinStore.kfUserIds)); } //获取门店自提地点 ViewData["placeList"] = PickPlaceBLL.SingleModel.GetListByAid_StoreId(aid, storeId); ViewBag.Index = Index; return(View(pinStore)); }
public ActionResult TiXian(int id = 0, string openId = "", string phone = "", string testappid = "") { if (string.IsNullOrEmpty(testappid)) { testappid = _pxhAppId; } C_UserInfo userinfo = C_UserInfoBLL.SingleModel.GetModelByTelephone_appid(phone, testappid);//_pxhAppId if (userinfo == null) { return(Content("无效用户")); } if (id <= 0) { return(Content("无效用户id")); } userinfo.zbSiteId = id; XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModelByAppid(userinfo.appId); if (xcxrelation == null) { return(Content("无效模板")); } //获取登陆秘钥 string utoken = CheckLoginClass.GetLoginSessionKey("1", userinfo.OpenId); ViewBag.utoken = utoken; //是否为代理 PinAgent agent = PinAgentBLL.SingleModel.GetModelByUserId(userinfo.Id); ViewBag.isAgent = agent != null ? 1 : 0; //店铺 PinStore store = PinStoreBLL.SingleModel.GetModelByAid_UserId(xcxrelation.Id, userinfo.Id); ViewBag.storeId = store != null ? store.id : 0; return(View(userinfo)); }
public ActionResult SetBiaoGan(int aid = 0, int sId = 0, int state = -1) { if (aid <= 0 || sId <= 0) { result.code = 0; result.msg = "参数错误"; return(Json(result)); } PinStore store = PinStoreBLL.SingleModel.GetModelByAid_Id(aid, sId); if (store == null) { result.msg = "门店不存在或者已关闭"; return(Json(result)); } store.biaogan = state; result.code = PinStoreBLL.SingleModel.Update(store, "biaogan") ? 1 : 0; result.msg = result.code > 0 ? "操作成功" : "操作失败"; return(Json(result)); }
public ActionResult DelStore(int aid, int id) { if (aid <= 0 || id <= 0) { result.code = 0; result.msg = "参数错误"; return(Json(result)); } PinStore model = PinStoreBLL.SingleModel.GetModelByAid_Id(aid, id); if (model == null) { result.code = 0; result.msg = "店铺不存在"; return(Json(result)); } else { model.state = -1; C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(model.userId); if (userInfo == null) { result.code = 0; result.msg = "商家不存在"; return(Json(result)); } userInfo.StoreId = 0; if (PinStoreBLL.SingleModel.Update(model, "state") && C_UserInfoBLL.SingleModel.Update(userInfo, "storeId")) { result.code = 1; result.msg = "操作成功"; return(Json(result)); } else { result.code = 0; result.msg = "操作失败"; return(Json(result)); } } }
/// <summary> /// 取消微信绑定 /// </summary> /// <param name="storeId"></param> /// <returns></returns> public ActionResult CancelBind(int storeId = 0) { PinStore pinStore = (PinStore)Request.RequestContext.RouteData.Values["pinStore"]; if (pinStore == null) { result.msg = "信息错误,请重新登录" + storeId; return(Json(result)); } pinStore.wxOpenId = string.Empty; if (PinStoreBLL.SingleModel.Update(pinStore, "wxopenid")) { result.msg = "取消成功"; result.code = 1; } else { result.msg = "取消失败"; } return(Json(result)); }
public ActionResult EditBankCard(int aid = 0, int storeId = 0, string code = "", string bankcardName = "", string bankcardNum = "") { if (string.IsNullOrEmpty(bankcardName)) { result.msg = "请输入账户名称"; return(Json(result)); } if (string.IsNullOrEmpty(bankcardNum)) { result.msg = "请输入提现账号"; return(Json(result)); } PinStore store = PinStoreBLL.SingleModel.GetModelByAid_Id(aid, storeId); if (store == null) { result.msg = "店铺不存在!"; return(Json(result)); } ReturnMsg data = ValidateSMS(store, code); if (data.code != 1) { return(Json(data)); } store.bankcardName = bankcardName; store.bankcardNum = bankcardNum; if (PinStoreBLL.SingleModel.Update(store, "bankcardName,bankcardNum")) { result.code = 1; result.msg = "修改成功"; } else { result.msg = "修改失败"; } return(Json(result)); }
/// <summary> /// 我的桌面 /// </summary> /// <returns></returns> public ActionResult Welcome() { PinGoodsOrderBLL pinGoodsOrderBLL = new PinGoodsOrderBLL(); PinStore store = (PinStore)Request.RequestContext.RouteData.Values["pinStore"]; DateTime now = DateTime.Now; DateTime startDate = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0); DateTime endDate = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59); Dictionary <string, object> model = new Dictionary <string, object>(); ////今日总收入 =所有订单金额-交易取消订单金额-交易失败订单金额 int todayMoney = pinGoodsOrderBLL.GetEarningsByDate(store.id, startDate, endDate); model.Add("todayMoney", (todayMoney * 0.01).ToString("0.00")); ////今日订单==所有订单-交易取消订单-交易失败订单 int saleCount = pinGoodsOrderBLL.GetSaleCountByDate(store.id, startDate, endDate); model.Add("saleCount", saleCount); ////总收入=订单总收入 int onlineIncome = pinGoodsOrderBLL.GetEarningsByDate(store.id); model.Add("onlineIncome", (onlineIncome * 0.01).ToString("0.00")); ////总订单数=订单表总数+微信买单总数+余额消费记录总数-余额支付订单数 int allOrderCount = pinGoodsOrderBLL.GetSaleCountByDate(store.id); model.Add("allOrderCount", allOrderCount); ////已上架商品数 int goodsCount = PinGoodsBLL.SingleModel.GetCountByStoreId(store.id); model.Add("goodsCount", goodsCount); return(View(model)); }