public void Update(ProductTraceLogEntity pEntity, bool pIsUpdateNullField, IDbTransaction pTran)
 {
     _currentDAO.Update(pEntity, pIsUpdateNullField, pTran);
 }
 /// <summary>
 /// 在事务内创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Create(ProductTraceLogEntity pEntity, IDbTransaction pTran)
 {
     _currentDAO.Create(pEntity, pTran);
 }
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Update(ProductTraceLogEntity pEntity, IDbTransaction pTran)
 {
     Update(pEntity, true, pTran);
 }
 /// <summary>
 /// 分页根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public PagedQueryResult <ProductTraceLogEntity> PagedQueryByEntity(ProductTraceLogEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex)
 {
     return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex));
 }
 /// <summary>
 /// 创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Create(ProductTraceLogEntity pEntity)
 {
     _currentDAO.Create(pEntity);
 }
 /// <summary>
 /// 根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public ProductTraceLogEntity[] QueryByEntity(ProductTraceLogEntity pQueryEntity, OrderBy[] pOrderBys)
 {
     return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys));
 }
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="pEntity"></param>
 public void Delete(ProductTraceLogEntity pEntity)
 {
     _currentDAO.Delete(pEntity);
 }
 public void Update(ProductTraceLogEntity pEntity, bool pIsUpdateNullField)
 {
     _currentDAO.Update(pEntity, pIsUpdateNullField);
 }
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Update(ProductTraceLogEntity pEntity)
 {
     Update(pEntity, true);
 }
示例#10
0
        public string CheckProduct()
        {
            string content  = string.Empty;
            var    respData = new CheckProductRespData();

            #region 解析请求字符串
            var reqObj = reqContent.DeserializeJSONTo <CheckProductReqData>();

            if (reqObj.special == null)
            {
                respData.code        = "101";
                respData.description = "没有特殊参数";
                return(respData.ToJSON().ToString());
            }
            if (reqObj.special.traceCode == null || reqObj.special.traceCode.Equals(""))
            {
                respData.code        = "102";
                respData.description = "识别码不能为空";
                return(respData.ToJSON().ToString());
            }
            #endregion

            #region //判断客户ID是否传递
            if (!string.IsNullOrEmpty(reqObj.common.customerId))
            {
                customerId = reqObj.common.customerId;
            }
            var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1");
            #endregion

            //产品二维码是否已被扫过
            ProductTraceLogBLL      productTraceLogBLL         = new ProductTraceLogBLL(loggingSessionInfo);
            ProductTraceLogEntity[] productTraceLogEntityArray = productTraceLogBLL.Query(new IWhereCondition[] {
                new EqualsCondition()
                {
                    FieldName = "TraceCode", Value = reqObj.special.traceCode
                }
            }
                                                                                          , new OrderBy[] { new OrderBy()
                                                                                                            {
                                                                                                                FieldName = "CreateTime", Direction = OrderByDirections.Desc
                                                                                                            } });

            Loggers.Debug(new DebugLogInfo()
            {
                Message = "产品二维码是否已被扫过:" + reqObj.special.traceCode + ", " + productTraceLogEntityArray.ToJSON()
            });

            ProductTraceLogEntity productTraceLogEntity = new ProductTraceLogEntity();
            productTraceLogEntity.TraceCode     = reqObj.special.traceCode;
            productTraceLogEntity.VipId         = reqObj.common.userId;
            productTraceLogEntity.RequestIP     = requestIP;
            productTraceLogEntity.RequestDevice = reqObj.common.openId;

            //准备返回数据
            CheckProductRespData checkProductRespData = new CheckProductRespData();
            checkProductRespData.content = new CheckProductRespContentData();

            #region 第一次被扫描
            if (productTraceLogEntityArray == null || productTraceLogEntityArray.Length == 0)
            {
                SaturnReturn  saturnReturn  = new SaturnReturn();
                SaturnProduct saturnProduct = new SaturnProduct();

                #region 从赛腾获取数据
                try
                {
                    SaturnService.PlatformSystemSoapClient service = new SaturnService.PlatformSystemSoapClient();
                    string result = service.SaturnGetProductDetails(reqObj.special.traceCode, "clientCode", "deviceNum", "billID", "BE656D55-D7A8-43F1-A865-67B93FE7EB7A");

                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "从赛腾获取数据, result = " + result
                    });

                    saturnReturn  = result.DeserializeJSONTo <SaturnReturn>();
                    saturnProduct = saturnReturn.product[0];
                }
                catch (Exception ex)
                {
                    respData.code        = "201";
                    respData.description = "从赛腾获取数据失败";
                    respData.exception   = ex.ToString();
                    Loggers.Exception(
                        new ExceptionLogInfo()
                    {
                        ErrorMessage = "从赛腾获取数据失败,错误原因" + ex.Message, UserID = reqObj.common.userId
                    });
                }
                #endregion

                #region 处理返回数据
                switch (saturnReturn.result)
                {
                case 1:
                    //设置验证日志中的产品有效性
                    productTraceLogEntity.IsValid        = 1;
                    checkProductRespData.content.isValid = "1";

                    int point = 0;
                    //获取产品信息
                    ItemService         itemService = new ItemService(loggingSessionInfo);
                    System.Data.DataRow itemDetail  = itemService.GetvwAllItemDetailByItemCode(reqObj.special.traceCode.Substring(2, 14), reqObj.common.customerId);

                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "获取产品信息: itemDetail = " + itemDetail.ToJSON()
                    });

                    if (itemDetail != null)
                    {
                        //获取本次产品积分
                        int.TryParse(itemDetail["ScanCodeIntegral"].ToString(), out point);
                        checkProductRespData.content.currentPoint = point.ToString();

                        //增加积分
                        VipIntegralBLL vipIntegralBLL = new VipIntegralBLL(loggingSessionInfo);
                        //扫描二维码积分的sourceid=19
                        vipIntegralBLL.ProcessPoint(19, reqObj.common.customerId, reqObj.common.userId, reqObj.special.traceCode, null, null, point, "验伪得积分");

                        //会员目前积分
                        VipBLL    vipBLL    = new VipBLL(loggingSessionInfo);
                        VipEntity vipEntity = vipBLL.GetByID(reqObj.common.userId);
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = "vipEntity.Integration: " + vipEntity.Integration.ToJSON()
                        });

                        if (vipEntity.Integration == null)
                        {
                            checkProductRespData.content.totalPoint = "0";
                        }
                        else
                        {
                            checkProductRespData.content.totalPoint = vipEntity.Integration.Value.ToString("f0");
                        }

                        //产品详细信息
                        checkProductRespData.content.imageURL      = itemDetail["imageUrl"].ToString();
                        checkProductRespData.content.productName   = itemDetail["item_name"].ToString();
                        checkProductRespData.content.productFormat = itemDetail["Specification"].ToString();
                        checkProductRespData.content.wineDegree    = itemDetail["SKUDegree"].ToString();
                        checkProductRespData.content.factoryName   = itemDetail["FactoryName"].ToString();
                    }
                    break;

                default:
                    //设置返回值中的产品有效性
                    checkProductRespData.content.isValid = "0";
                    //设置验证日志中的产品有效性
                    productTraceLogEntity.IsValid = 0;
                    break;
                }
                #endregion
            }
            #endregion
            #region 重复扫描
            else
            {
                //是真品
                if (productTraceLogEntityArray[0].IsValid.Value == 1)
                {
                    checkProductRespData.content.isValid = "1";
                    productTraceLogEntity.IsValid        = 1;

                    ItemService         itemService = new ItemService(loggingSessionInfo);
                    System.Data.DataRow itemDetail  = itemService.GetvwAllItemDetailByItemCode(productTraceLogEntityArray[0].TraceCode.Substring(2, 14), reqObj.common.customerId);
                    int point = 0;

                    if (itemDetail != null)
                    {
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = "重复扫描, 获取产品信息: itemDetail = " + itemDetail.ToJSON()
                        });

                        try
                        {
                            int.TryParse((itemDetail["ScanCodeIntegral"] ?? "").ToString(), out point);
                            checkProductRespData.content.currentPoint = point.ToString();;

                            checkProductRespData.content.imageURL      = (itemDetail["imageUrl"] ?? "").ToString();
                            checkProductRespData.content.productName   = (itemDetail["item_name"] ?? "").ToString();
                            checkProductRespData.content.productFormat = (itemDetail["Specification"] ?? "").ToString();
                            checkProductRespData.content.wineDegree    = (itemDetail["SKUDegree"] ?? "").ToString();
                            checkProductRespData.content.factoryName   = (itemDetail["FactoryName"] ?? "").ToString();

                            checkProductRespData.content.traceCount    = productTraceLogEntityArray.Length.ToString();
                            checkProductRespData.content.lastTraceTime = productTraceLogEntityArray[0].CreateTime.ToString();
                        }
                        catch (Exception ex)
                        {
                            respData.code        = "202";
                            respData.description = "提取产品信息失败";
                            respData.exception   = ex.ToString();
                            Loggers.Exception(
                                new ExceptionLogInfo()
                            {
                                ErrorMessage = "提取产品信息失败,错误原因" + ex.Message
                            });
                        }
                    }
                }
                //非真品
                else
                {
                    productTraceLogEntity.IsValid = 0;

                    checkProductRespData.content.isValid = "0";
                }
            }
            #endregion

            if (respData.code != "201")
            {
                productTraceLogBLL.Create(productTraceLogEntity);
                checkProductRespData.code = "200";
            }

            respData = checkProductRespData;

            content = respData.ToJSON();
            Loggers.Debug(new DebugLogInfo()
            {
                Message = "返回数据,content=" + content
            });
            return(content);
        }