示例#1
0
文件: OrderSvc.cs 项目: HkSuen/House
        public wy_wx_pay GetWxPay(OrderDto oder)
        {
            v_pay_record record = oder.Record;
            var          pay    = new wy_wx_pay();

            pay.ID                    = CommonFiled.guid;
            pay.APP_ID                = CommonFiled.appID;
            pay.ORDER_ID              = CommonFiled.ABC + CommonFiled.orderId;
            pay.RECORD_ID             = record.RECORD_ID;
            pay.HOUSE_ID              = oder.Houseinfo.FWID;
            pay.USER_ID               = oder.Shopinfo.CZ_SHID; //用户ID
            pay.OPEN_ID               = record.OPEN_ID;
            pay.FEE_TYPES             = Convert.ToInt32(record.JFLX);
            pay.TOTAL_FEE             = record.JFJE.HasValue ? Convert.ToInt32(record.JFJE.Value * 100) : 0;
            pay.REMARK                = $"自助缴费_{Fee.Types.SingleOrDefault(c => c.Value == Convert.ToInt32(record.JFLX)).Key}";
            pay.STATUS                = 0;
            pay.CREATE_TIME           = DateTime.Now;
            pay.MECH_ID               = CommonFiled.MchId(record.JFLX);
            pay.NONCE_STR             = CommonFiled.guid;
            pay.PREPAY_TIME           = DateTime.Now;
            pay.PREPAY_ENDTIME        = DateTime.Now.AddHours(2);
            pay.TRADE_TYPE            = CommonFiled.JSAPI;
            pay.HOUSE_NAME            = oder.Houseinfo.FWMC;
            pay.HOUSE_ADDRESS         = oder.Houseinfo.ZLWZ;
            pay.HOUSE_AREA            = oder.Houseinfo.JZMJ;
            pay.HOUSE_SERVICEEFFCTIVE = pay.FEE_TYPES != 0 ? "" :
                                        $"{toDate(oder.Record.YXQS,"yyyy/MM/dd")}-{toDate(oder.Record.YXQZ,"yyyy/MM/dd")}";
            //物业费单价
            pay.HOUSE_SERVICE_UNITPRICE = Convert.ToDecimal(oder.Costs.WYDJ);
            pay.USER_NAME         = oder.Shopinfo.ZHXM;
            pay.SHOP_NAME         = oder.Shopinfo.SHOP_NAME;
            pay.TOTAL_FEE_CH      = CommonFiled.CmycurD(Convert.ToDecimal((pay.TOTAL_FEE / 100.00)));
            pay.MECH_NAME         = CommonFiled.MchName(pay.FEE_TYPES);
            pay.TYPES_ID          = pay.FEE_TYPES == 0 ? "" : (pay.FEE_TYPES == 1 ? oder.Houseinfo.WATER_NUMBER : oder.Houseinfo.ELE_NUMBER);
            pay.TYPES_ID_ELE_COLL = oder.Houseinfo.CID;
            return(pay);
        }
示例#2
0
        public JsonResult CreateOrder(string recordId, string houseId, string UId, int WNum, double EPrice, string Type)
        {
            if (string.IsNullOrEmpty(houseId) || string.IsNullOrEmpty(UId))
            {
                return(Data(ResultCode.PARAMS_IS_NULL, null, ResultCode.PARAMS_IS_NULL.GetEnumDescription()));
            }
            //1.订单查询有无此数据,无数据默认创建新数据
            wy_wx_pay pay = null;

            if (!string.IsNullOrEmpty(recordId))
            {
                pay = this._order.FindSingle(recordId, houseId, UId, OpenID); //自助缴费订单,每次都是新订单
            }
            //原订单失效,异步更改状态
            bool UpdateTime = pay != null && DateTime.Now > pay.PREPAY_ENDTIME;

            if (pay == null || UpdateTime)
            {
                if (UpdateTime) //异步更新过期订单信息,并生成新的订单信息
                {
                    Task.Run(() =>
                    {
                        pay.STATUS = 1;
                        this._order.Update(pay);
                    });
                }
                //获取提醒订单信息
                OrderDto PayRecord = null;
                if (string.IsNullOrEmpty(recordId))
                {
                    PayRecord = this._order.GetWxPay(UId, houseId);
                }
                else
                {
                    PayRecord = this._order.GetWxPay(UId, recordId, houseId);
                }
                //校验是否为自助缴费订单
                if (PayRecord.Record == null || PayRecord.Record.RECORD_ID == null)
                {
                    PayRecord.Record = new v_pay_record()
                    {
                        OPEN_ID   = OpenID,
                        JFLX      = Type,
                        JFJE      = EPrice,      //默认物业费
                        RECORD_ID = SelfPayOrder //默认0为自助订单,非缴费提醒
                    };
                }
                pay         = this._order.GetWxPay(PayRecord);
                pay.USER_IP = UserIP;
                //存储水量以及电量
                if (pay.FEE_TYPES != 0) //非物业费
                {
                    //非物业默认记录电的价格
                    pay.UNIT_PRICE   = Convert.ToInt32(this._order.GetUnitPrice(CommonFiled.UnitPriceElectricSetKey) * 100);
                    pay.AMOUNT       = Convert.ToInt32(EPrice);
                    pay.TOTAL_FEE    = Convert.ToInt32(pay.UNIT_PRICE * pay.AMOUNT);
                    pay.TOTAL_FEE_CH = CommonFiled.CmycurD(Convert.ToDecimal((pay.UNIT_PRICE * pay.AMOUNT) / 100.00));
                    if (pay.FEE_TYPES == 1)
                    {
                        // 为水的时候需要记录单价
                        pay.UNIT_PRICE   = Convert.ToInt32(this._order.GetUnitPrice(CommonFiled.UnitPriceWaterKey) * 100);
                        pay.AMOUNT       = WNum;
                        pay.TOTAL_FEE    = Convert.ToInt32(pay.UNIT_PRICE * pay.AMOUNT);
                        pay.TOTAL_FEE_CH = CommonFiled.CmycurD(Convert.ToDecimal((pay.UNIT_PRICE * pay.AMOUNT) / 100.00));
                    }
                }
                if (pay.TOTAL_FEE <= 0) //如果订单生成为0元,直接视为无效订单,禁止生成。
                {
                    return(Data(ResultCode.PARAMS_IS_INVALID));
                }
                //将订单存到数据库
                if (this._order.Inert(pay) <= 0)
                {
                    return(Data(ResultCode.DATA_IS_WRONG));
                }
                ;
            }
            // 这里需要过滤订单信息
            return(Data(ResultCode.SCCUESS, new { sign = this._order.GetPayParamsByWxModel(pay) }));
        }