// GET: Pin/TongJi public ActionResult Index(string act = "", int aId = 0, DateTime?q_begin_time = null, DateTime?q_end_time = null) { PinGoodsOrderBLL goodsOrderBLL = new PinGoodsOrderBLL(); string sql = $"SELECT sum(money) as money,DATE_FORMAT(addtime,'%Y-%m-%d') as addtime from pingoodsorder where state>0 and ordertype=0 and aid={aId} "; string whereSql = ""; string groupSql = "group by DATE_FORMAT(addtime,'%Y-%m-%d') order by DATE_FORMAT(addtime,'%Y-%m-%d') desc"; if (act == "7day") { sql = sql + groupSql + " limit 7 "; } else if (act == "30day") { sql = sql + groupSql + " limit 30 "; } else { if (q_end_time > q_begin_time) { whereSql = $" and addtime BETWEEN '{q_begin_time?.ToString("yyyy-MM-dd")} 00:00:00' and '{q_end_time?.ToString("yyyy-MM-dd")} 23:59:59' "; } sql = sql + whereSql + groupSql + " limit 30 "; } List <PinGoodsOrder> list = goodsOrderBLL.GetListBySql(sql); if (list != null && list.Count > 0) { ViewBag.NameList = string.Join(",", list.Select(p => $"'{p.addtime.ToString("yyyy-MM-dd")}'")); ViewBag.ValueList = string.Join(",", list.Select(p => p.money / 100)); } return(View()); }
public ActionResult Index(int aid = 0, int storeId = 0, string orderId = "", string storeName = "", string goodsName = "", int orderState = -999, string consignee = "", string phone = "", int sendWay = -999, int groupState = -999, int groupId = 0, string startDate = "", string endDate = "", int pageIndex = 0, int pageSize = 20, string act = "") { PinGoodsOrderBLL pinGoodsOrderBLL = new PinGoodsOrderBLL(); if (act == "getNewOrder") { bool isSuccess = pinGoodsOrderBLL.havingNewOrder(storeId, DateTime.Now.AddSeconds(-10)); //检查是否有新订单(10秒前到现在) result.code = isSuccess ? 1 : 0; result.msg = isSuccess ? "存在新订单" : "没有新订单"; return(Json(result)); } if (aid <= 0 || storeId <= 0) { return(Content($"参数错误 aid:{aid},storeId:{storeId}")); } ViewModel <PinGoodsOrder> vm = new ViewModel <PinGoodsOrder>(); int recordCount = 0; vm.DataList = pinGoodsOrderBLL.GetListByCondition(aid, storeId, orderId, storeName, goodsName, orderState, consignee, phone, sendWay, groupState, groupId, startDate, endDate, pageIndex, pageSize, out recordCount); if (vm.DataList != null && vm.DataList.Count > 0) { string groupIds = string.Join(",", vm.DataList.Select(s => s.groupId).Distinct()); List <PinGroup> pinGroupList = PinGroupBLL.SingleModel.GetListByIds(groupIds); vm.DataList.ForEach(order => { order.groupInfo = pinGroupList?.FirstOrDefault(f => f.id == order.groupId); if (order.sendway == (int)PinEnums.SendWay.到店自取) { PickPlace place = PickPlaceBLL.SingleModel.GetModel(Convert.ToInt32(order.address)); if (place != null) { order.storeName = place.name; order.address = place.address; } else { order.address = string.Empty; } } }); } vm.TotalCount = recordCount; vm.aId = aid; vm.storeId = storeId; ViewBag.OrderId = orderId; ViewBag.StoreName = storeName; ViewBag.goodsName = goodsName; ViewBag.OrderState = orderState; ViewBag.Consignee = consignee; ViewBag.Phone = phone; ViewBag.SendWay = sendWay; ViewBag.GroupState = groupState; ViewBag.GroupId = groupId; ViewBag.StartDate = startDate; ViewBag.EndDate = endDate; return(View(vm)); }
/// <summary> /// 用户拼团成功返现 /// </summary> /// <param name="id">提现账号id(PlatUserCash)</param> /// <param name="drawcashmoney">提现金额(分)</param> /// <returns></returns> public string PxhUserApplyDrawCash(PinGoodsOrder order, int userId, string appid) { PinGoodsOrderBLL pinGoodsOrderBLL = new PinGoodsOrderBLL(); TransactionModel tran = new TransactionModel(); if (userId <= 0) { return("用户ID不能为0"); } if (order.returnMoney <= 0) { return("返现金额不能为0"); } if (string.IsNullOrEmpty(appid)) { return("appid不能为空"); } int serviceFee = 0;//服务费 string partner_trade_no = WxPayApi.GenerateOutTradeNo(); DrawCashApply apply = new DrawCashApply() { Aid = order.aid, appId = appid, partner_trade_no = partner_trade_no, userId = userId, applyMoney = order.returnMoney, serviceMoney = serviceFee, cashMoney = order.returnMoney - serviceFee, useCash = "0", BeforeApplyMoney = 0, AddTime = DateTime.Now, remark = "拼享惠拼团成功用户申请返现", hostIP = WebHelper.GetIP(), state = 0, drawState = (int)DrawCashState.未开始提现, applyType = (int)DrawCashApplyType.拼享惠用户返现, drawCashWay = (int)DrawCashWay.微信提现, OrderId = order.id, }; tran.Add(base.BuildAddSql(apply)); order.isReturnMoney = 1; tran.Add(pinGoodsOrderBLL.BuildUpdateSql(order, "isReturnMoney")); if (!base.ExecuteTransactionDataCorect(tran.sqlArray)) { return("申请提现失败"); } return(""); }
/// <summary> /// 更新用户拼团成功提现结果 /// </summary> /// <param name="code">0提现失败 1提现成功</param> /// <param name="drawCashApplyId"></param> /// <param name="result">附加信息</param> /// <returns></returns> public string UpdatePxhUserDrawCashResult(int code, DrawCashApply drawCashApply, string result, int state = 0) { TransactionModel tranModel = new TransactionModel(); C_UserInfo usercash = C_UserInfoBLL.SingleModel.GetModel(drawCashApply.userId); if (usercash == null) { return("没有找到用户提现账号"); } //if (drawCashApply.drawState != (int)DrawCashState.提现中) //{ // return "无效状态"; //} if (code == 1) { drawCashApply.drawState = 2; drawCashApply.DrawTime = DateTime.Now; drawCashApply.remark += $" ;本次提现成功{DateTime.Now}"; } else { PinGoodsOrderBLL pinGoodsOrderBLL = new PinGoodsOrderBLL(); PinGoodsOrder order = pinGoodsOrderBLL.GetModel(drawCashApply.OrderId); if (order == null) { return("没有找到拼享惠订单"); } order.isReturnMoney = 0; tranModel.Add(pinGoodsOrderBLL.BuildUpdateSql(order, "isReturnMoney")); //表示提现失败 //tranModel.Add($"update PinGoodsOrder set isReturnMoney=0 where id={order.id}"); drawCashApply.drawState = -1; if (state == (int)ApplyState.审核不通过) { drawCashApply.state = state; } drawCashApply.DrawTime = DateTime.Now; drawCashApply.remark = $" ;本次提现失败{DateTime.Now},原因{result}"; } tranModel.Add(base.BuildUpdateSql(drawCashApply, "state,drawState,DrawTime,remark")); bool success = base.ExecuteTransactionDataCorect(tranModel.sqlArray); return(success ? "" : "执行更新拼享惠用户提现结果失败"); }
/// <summary> /// 退款 /// </summary> /// <param name="aid"></param> /// <param name="storeId"></param> /// <param name="orderId"></param> /// <returns></returns> public ActionResult Refund(int aid = 0, int storeId = 0, int orderId = 0) { if (aid <= 0 || storeId <= 0 || orderId <= 0) { result.msg = "参数错误"; return(Json(result)); } PinGoodsOrderBLL pinGoodsOrderBLL = new PinGoodsOrderBLL(); PinGoodsOrder order = pinGoodsOrderBLL.GetModelByAid_StoreId_Id(aid, storeId, orderId); if (order == null) { result.msg = "订单错误"; return(Json(result)); } string msg = string.Empty; result.code = pinGoodsOrderBLL.Refund(order, ref msg); result.msg = 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)); }
/// <summary> /// 切换订单状态 /// </summary> /// <param name="aid"></param> /// <param name="storeId"></param> /// <param name="state"></param> /// <param name="orderIds"></param> /// <param name="attachData">物流信息</param> /// <returns></returns> public ActionResult UpdateState(int aid = 0, int storeId = 0, int state = -999, string orderIds = "", string attachData = "") { if (aid <= 0 || storeId <= 0 || string.IsNullOrEmpty(orderIds)) { result.msg = "参数错误"; return(Json(result)); } PinGoodsOrderBLL pinGoodsOrderBLL = new PinGoodsOrderBLL(); List <PinGoodsOrder> orders = pinGoodsOrderBLL.GetListByIds(aid, storeId, orderIds, $"{(int)PinEnums.PinOrderState.交易取消},{(int)PinEnums.PinOrderState.交易失败},{(int)PinEnums.PinOrderState.交易成功}"); if (orders == null || orders.Count <= 0) { result.msg = "找不到可操作订单"; return(Json(result)); } switch (state) { case (int)PinEnums.PinOrderState.待发货: result.code = pinGoodsOrderBLL.SendGoods(orders, attachData); break; case (int)PinEnums.PinOrderState.交易成功: result.code = pinGoodsOrderBLL.OrderSuccess(orders); break; case (int)PinEnums.PinOrderState.交易取消: result.code = pinGoodsOrderBLL.CancelOrder(orders); break; default: result.msg = "参数错误"; return(Json(result)); } result.msg = result.code == 1 ? "操作成功" : "操作失败"; return(Json(result)); }
public ActionResult ComplaintList(int aid = 0, int pageIndex = 1, int pageSize = 15, string outTradeNo = "", string userName = "", string storeName = "", int orderState = -999, DateTime?startDate = null, DateTime?endDate = null, int state = -999, int sId = -999) { ViewModel <PinComplaint> model = new ViewModel <PinComplaint>(); int recordCount = 0; model.DataList = PinComplaintBLL.SingleModel.GetListByCondition(aid, pageIndex, pageSize, outTradeNo, userName, sId, storeName, orderState, startDate, endDate, state, out recordCount); if (model.DataList != null && model.DataList.Count > 0) { PinGoodsOrderBLL pinGoodsOrderBLL = new PinGoodsOrderBLL(); string userIds = string.Join(",", model.DataList.Select(s => s.userId).Distinct()); List <C_UserInfo> userInfoList = C_UserInfoBLL.SingleModel.GetListByIds(userIds); string orderIds = string.Join(",", model.DataList.Select(s => s.orderId).Distinct()); List <PinGoodsOrder> pinGoodsOrderList = pinGoodsOrderBLL.GetListByIds(orderIds); string groupIds = string.Join(",", pinGoodsOrderList?.Select(s => s.groupId).Distinct()); List <PinGroup> pinGroupList = PinGroupBLL.SingleModel.GetListByIds(groupIds); string storeIds = string.Join(",", model.DataList.Select(s => s.storeId).Distinct()); List <PinStore> pinStoreList = PinStoreBLL.SingleModel.GetListByIds(storeIds); model.DataList.ForEach(item => { item.userInfo = userInfoList?.FirstOrDefault(f => f.Id == item.userId); item.order = pinGoodsOrderList?.FirstOrDefault(f => f.id == item.orderId); if (item.order != null && item.order.groupId > 0) { item.order.groupInfo = pinGroupList?.FirstOrDefault(f => f.id == item.order.groupId); } item.store = pinStoreList?.FirstOrDefault(f => f.id == item.storeId); }); } ViewBag.aid = aid; ViewBag.outTradeNo = outTradeNo; ViewBag.storeName = storeName; ViewBag.orderState = orderState; if (sId != -999) { ViewBag.storeId = sId; } string startStr = string.Empty; if (startDate != null) { startStr = ((DateTime)startDate).ToString("yyyy-MM-dd"); } string endStr = string.Empty; if (endDate != null) { endStr = ((DateTime)endDate).ToString("yyyy-MM-dd"); } ViewBag.startDate = startStr; ViewBag.endDate = endStr; ViewBag.state = state; ViewBag.userName = userName; model.TotalCount = recordCount; model.PageSize = pageSize; model.PageIndex = pageIndex; return(View(model)); }