Esempio n. 1
0
        public IEnumerable <ReasonItem> GetReason([FromBody] ReasonRequest requestParams)
        {
            IEnumerable <ReasonItem> result = null;

            switch (requestParams.Type)
            {
            case 1:
                result = OrderChangeRefundSale.GetChangeReason(requestParams.StoreId, requestParams.MachineSn, requestParams.CID, requestParams.DeviceSn);
                break;

            case 2:
                result = OrderChangeRefundSale.GetRefundReason(requestParams.StoreId, requestParams.MachineSn, requestParams.CID, requestParams.DeviceSn);
                break;

            default:
                throw new PosException("无法获取原因列表!");
            }
            return(result);
        }
Esempio n. 2
0
        public object Pay([FromBody] PayRequest requestParams)
        {
            if (requestParams == null || requestParams.Payway == null || requestParams.Payway.Count() == 0)
            {
                throw new PosException("未知支付方式!");
            }
            string key = string.Format("{0}-{1}-{2}-{3}", requestParams.StoreId, requestParams.MachineSn, requestParams.CID, requestParams.DeviceSn);

            lock (lockobjforadd)
            {
                if (!lockobjs.ContainsKey(key))
                {
                    lockobjs = lockobjs.ToList().Concat(new List <KeyValuePair <string, object> >()
                    {
                        new KeyValuePair <string, object>(key, new object())
                    }).ToDictionary(o => o.Key, o => o.Value);
                }
            }
            var    dict    = lockobjs;//防止并发
            var    lockkv  = dict.First(o => o.Key == key);
            object lockobj = new object();

            if (!lockkv.Equals(default(KeyValuePair <string, object>)) && lockkv.Value != null)
            {
                lockobj = lockkv.Value;
            }

            DateTime createDt = DateTime.Now;

            lock (lockobj)
            {
                switch (requestParams.Mode)
                {
                case PayAction.RefundAll:    //退单
                    return(DoPay(requestParams.CID, requestParams.StoreId, requestParams.MachineSn, requestParams.DeviceSn, Guid.NewGuid().ToString("N"), requestParams, createDt, (o) =>
                    {
                        OrderChangeRefundSale.RefundAll(requestParams.StoreId, requestParams.MachineSn, requestParams.CID, requestParams.Reason, requestParams.OldOrderSn, requestParams.OrderAmount, requestParams.DeviceSn, o, createDt);
                    }));

                case PayAction.Refund:    //退货
                    var orderRefund = OrderChangeFactory.Factory(requestParams.StoreId, requestParams.MachineSn, requestParams.CID, AfterSaleMode.Refunding, requestParams.DeviceSn);
                    return(DoPay(requestParams.CID, requestParams.StoreId, requestParams.MachineSn, requestParams.DeviceSn, orderRefund.PaySn, requestParams, createDt, (o) =>
                    {
                        orderRefund.SaveRecord(requestParams.StoreId, requestParams.MachineSn, requestParams.CID, requestParams.Reason, requestParams.OrderAmount, requestParams.Receivable, o, requestParams.DeviceSn);
                    }));

                case PayAction.Change:    //换货支付
                    var orderChange = OrderChangeFactory.Factory(requestParams.StoreId, requestParams.MachineSn, requestParams.CID, AfterSaleMode.Changing, requestParams.DeviceSn);
                    return(DoPay(requestParams.CID, requestParams.StoreId, requestParams.MachineSn, requestParams.DeviceSn, orderChange.PaySn, requestParams, createDt, (o) =>
                    {
                        orderChange.SaveRecord(requestParams.StoreId, requestParams.MachineSn, requestParams.CID, requestParams.Reason, requestParams.OrderAmount, requestParams.Receivable, o, requestParams.DeviceSn);
                    }));

                case PayAction.Sale:    //销售支付

                    var shoppingcart = ShoppingCartFactory.Factory(requestParams.StoreId, requestParams.MachineSn, requestParams.CID, requestParams.DeviceSn);
                    var orderList    = shoppingcart.GetOrdeList();
                    if (orderList == null || orderList.Count() == 0)
                    {
                        throw new PosException("该商品已结算,遇到网络异常,请手动按 Q 清空购物车!");
                    }
                    try
                    {
                        return(DoPay(requestParams.CID, requestParams.StoreId, requestParams.MachineSn, requestParams.DeviceSn, shoppingcart.OrderSN, requestParams, createDt, (o) =>
                        {
                            shoppingcart.Record(o.ApiCodes, requestParams.OrderAmount, requestParams.Receivable, requestParams.DeviceSn, createDt);
                        }));
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                }
            }
            return(createDt);
        }
Esempio n. 3
0
 public string GetRefundAllOrderSn([FromBody] BaseApiParams requestParams)
 {
     return(OrderChangeRefundSale.GetRefundAllCustomOrderSn(requestParams.StoreId, requestParams.MachineSn, requestParams.CID));
 }