예제 #1
0
        private async Task <JsonResult> SendWaitMainStoneMsg(Order order)
        {
            var accountBindingManager = new AccountBindingManager();
            var accountbing           = await accountBindingManager.GetAccountBindingByCustomerId(order.CustomerId);

            if (accountbing == null)
            {
                return(Json(InvokedResult.Fail("404", "客户未绑定微信")));
            }

            SendMesHelp.SendNews(new NewsMes()
            {
                OpenId   = accountbing.WxAccount,
                Articles = new List <Article>()
                {
                    new Article()
                    {
                        Title       = "等待主石",
                        Description = string.Format("订单{0}进入等石阶段,请及时邮件主石!", order.Id),
                        Url         = "http://www.18k.hk/customer/order/list?OrderId=" + order.Id,
                        PicUrl      = "http://www.18k.hk/static/images/ddzs.jpg"
                    }
                }
            });


            var operationLogManager = new OrderOperationLogManager(User);
            await operationLogManager.AddLogAsync(OperationLogStatus.CuiShi, order.Id);

            return(Json(InvokedResult.SucceededResult));
        }
        public async Task <InvokedResult> UpdateUserFirmId(string openId, string firmId)
        {
            Requires.NotNullOrEmpty(openId, nameof(openId));
            Requires.NotNullOrEmpty(firmId, nameof(firmId));

            try
            {
                using (var handler = new HttpClientHandler())
                {
                    using (var httpClient = GetClient(handler))
                    {
                        var postContent = new StringContent(JsonConvert.SerializeObject(new { openId, firmId }),
                                                            Encoding.UTF8, "application/json");

                        var response = await httpClient.PostAsync("passport/UnionId/UpdateFirmId", postContent);

                        var result =
                            JsonConvert.DeserializeObject <WebApiResponse <string> >(await response.Content
                                                                                     .ReadAsStringAsync());
                        return(result.Success ? InvokedResult.SucceededResult : throw new Exception(result.Error.Description));
                    }
                }
            }
            catch (Exception ex)
            {
                m_Logger.LogError($"更新用户公司Id失败,userOpenId: {openId}:{ex.Message}");
                return(InvokedResult.Fail("UpdateFirmIdFailed", $"更新用户FirmId至Passport失败,userOpenId: {openId}"));
            }
        }
예제 #3
0
        private async Task <JsonResult> SendCustomerTobeConfirmMsg(Order order, OrderAttachment designImage, bool isLog = false)
        {
            var accountBindingManager = new AccountBindingManager();
            var accountbing           = await accountBindingManager.GetAccountBindingByCustomerId(order.CustomerId);

            if (accountbing == null)
            {
                return(Json(InvokedResult.Fail("404", "客户未绑定微信")));
            }


            SendMesHelp.SendNews(new NewsMes()
            {
                OpenId   = accountbing.WxAccount,
                Articles = new List <Article>()
                {
                    new Article()
                    {
                        Title       = "设计稿确认",
                        Description = string.Format("订单{0}已上传设计稿,请确认!", order.Id),
                        Url         = "http://www.18k.hk/customer/order/list?OrderId=" + order.Id,
                        PicUrl      = string.Format("http://www.18k.hk/orderimage/{0}.jpg", designImage.FileInfoId)
                    }
                }
            });

            if (isLog)
            {
                var operationLogManager = new OrderOperationLogManager(User);
                await operationLogManager.AddLogAsync(OperationLogStatus.CuiQueRen, order.Id);
            }

            return(Json(InvokedResult.SucceededResult));
        }
예제 #4
0
        private async Task <JsonResult> SendShipmentOrderMsg(ShipmentOrder shipmentOrder)
        {
            if (shipmentOrder.ShipmentOrderInfos.Any())
            {
                var accountBindingManager = new AccountBindingManager();
                var accountbing           = await accountBindingManager.GetAccountBindingByCustomerId(shipmentOrder.CustomerId);

                if (accountbing == null)
                {
                    return(Json(InvokedResult.Fail("404", "客户未绑定微信")));
                }

                SendMesHelp.SendNews(new NewsMes()
                {
                    OpenId   = accountbing.WxAccount,
                    Articles = new List <Article>()
                    {
                        new Article()
                        {
                            Title       = "订单已发货",
                            Description =
                                string.Format("订单{0}已于{1}出货!",
                                              string.Join(",", shipmentOrder.ShipmentOrderInfos.Select(r => r.Id)),
                                              DateTime.Now.ToShortDateString()),
                            Url    = "https://www.18k.hk/customer/order/list?status=2",
                            PicUrl = "https://www.18k.hk/static/images/ddzs.jpg"
                        }
                    }
                });
            }
            return(Json(InvokedResult.SucceededResult));
        }
예제 #5
0
        public async Task<InvokedResult> DeleteAsync(string id)
        {
            Requires.NotNull(id, "id");
            var file = await FindByIdAsync(id);
            if (file == null)
                return InvokedResult.Fail("404","附件不存在");

            DbContext.Set<FileInfo>().Remove(file);
            await DbContext.SaveChangesAsync();
            return InvokedResult.SucceededResult;
        }
        public async Task <InvokedResult> DeleteOrderSetStoneAsync(int id)
        {
            var orderMainStoneInfo = DbContext.Set <OrderMainStoneInfo>().FirstOrDefault(r => r.Id == id);

            if (orderMainStoneInfo == null)
            {
                return(InvokedResult.Fail("404", "主石不存在"));
            }

            DbContext.Set <OrderMainStoneInfo>().Remove(orderMainStoneInfo);
            await DbContext.SaveChangesAsync();

            return(InvokedResult.SucceededResult);
        }
        public async Task <InvokedResult> DeleteReconciliationAsync(string shipmentOrderId)
        {
            var remark         = shipmentOrderId + "出货";
            var reconciliation = DbContext.Set <Reconciliation>().FirstOrDefault(r => r.Remark == remark);

            if (reconciliation == null)
            {
                return(InvokedResult.Fail("404", "不存在该出货单的对账记录"));
            }

            DbContext.Set <Reconciliation>().Remove(reconciliation);
            await DbContext.SaveChangesAsync();

            return(InvokedResult.SucceededResult);
        }
예제 #8
0
        public async Task <InvokedResult> SaveDailyGoldPrice(DailyGoldPrice dailyGoldPrice)
        {
            var dbSet = DbContext.Set <DailyGoldPrice>();
            var existDailyGoldPrice = dbSet.FirstOrDefault(d => d.CompanyId == User.CompanyId && d.Date == dailyGoldPrice.Date && d.ColorFormId == dailyGoldPrice.ColorFormId && dailyGoldPrice.Id != d.Id);

            if (existDailyGoldPrice != null)
            {
                return(InvokedResult.Fail("DailyGoldPriceIsExist",
                                          $"{existDailyGoldPrice.ColorForm.Name}在{existDailyGoldPrice.Date}的金价已设置,不能重复添加"));
            }

            dbSet.AddOrUpdate(dailyGoldPrice);
            await DbContext.SaveChangesAsync();

            return(InvokedResult.SucceededResult);
        }
예제 #9
0
        public async Task <InvokedResult> DeleteGemCategoryAsync(int id)
        {
            if (id < 1)
            {
                throw new ArgumentOutOfRangeException();
            }

            var dbSet       = DbContext.Set <GemCategory>();
            var gemCategory = await dbSet.FirstOrDefaultAsync(c => c.Id == id);

            if (gemCategory == null)
            {
                return(InvokedResult.Fail("gemCategoryNoExists", "数据不存在"));
            }

            gemCategory.Deleted = true;
            dbSet.AddOrUpdate(gemCategory);
            await DbContext.SaveChangesAsync();

            return(InvokedResult.SucceededResult);
        }
예제 #10
0
        public async Task <InvokedResult> DeleteMainStoneAsync(int id)
        {
            if (id < 1)
            {
                throw new ArgumentOutOfRangeException();
            }

            var dbSet     = DbContext.Set <MainStone>();
            var mainStone = await dbSet.FirstOrDefaultAsync(c => c.Id == id);

            if (mainStone == null)
            {
                return(InvokedResult.Fail("mainStoneNoExists", "数据不存在"));
            }

            mainStone.Deleted = true;
            dbSet.AddOrUpdate(mainStone);
            await DbContext.SaveChangesAsync();

            return(InvokedResult.SucceededResult);
        }
예제 #11
0
        public async Task <InvokedResult> DeleteColorFormAsync(int id)
        {
            if (id < 1)
            {
                throw new ArgumentOutOfRangeException();
            }

            var dbSet     = DbContext.Set <ColorForm>();
            var colorForm = await dbSet.FirstOrDefaultAsync(c => c.Id == id);

            if (colorForm == null)
            {
                return(InvokedResult.Fail("ColorFormNoExists", "数据不存在"));
            }

            colorForm.Deleted = true;
            dbSet.AddOrUpdate(colorForm);
            await DbContext.SaveChangesAsync();

            return(InvokedResult.SucceededResult);
        }
예제 #12
0
        private async Task <InvokedResult> ChangeOrderStatus(string orderId, OrderStatus status, string currentUserId = "")
        {
            var manager = new OrderManager(User);
            var order   = await manager.GetOrderAsync(orderId);

            if (order == null)
            {
                return(InvokedResult.Fail("404", SaleManagentConstants.Errors.OrderNotFound));
            }

            if (!string.IsNullOrEmpty(currentUserId))
            {
                order.CurrentUserId = currentUserId;
            }
            order.OrderStatus = status;
            var result = await manager.UpdateOrderAsync(order);

            if (result.Succeeded)
            {
                var operationLogManager = new OrderOperationLogManager(User);
                await operationLogManager.AddLogAsync(order.OrderStatus, order.Id);
            }
            return(result);
        }