protected void Describe(XmlContent xc) { xc.ELEM(Key, delegate { for (int i = 0; i < actions.Count; i++) { var act = actions.EntryAt(i).Value; xc.Put(act.Key, ""); } }, delegate { if (works != null) { for (int i = 0; i < works.Count; i++) { var wrk = works.EntryAt(i).Value; wrk.Describe(xc); } } varwork?.Describe(xc); } ); }
/// <summary> /// WCPay notify, placed here due to non-authentic context. /// </summary> public async Task notify(ActionContext ac) { XElem xe = await ac.ReadAsync <XElem>(); long orderid; decimal cash; if (Notified(xe, out orderid, out cash)) { string mgrwx = null; using (var dc = NewDbContext()) { var shopid = (string)dc.Scalar("UPDATE orders SET cash = @1, accepted = localtimestamp, status = @2 WHERE id = @3 AND status <= @2 RETURNING shopid", (p) => p.Set(cash).Set(Order.ACCEPTED).Set(orderid)); if (shopid != null) { mgrwx = (string)dc.Scalar("SELECT mgrwx FROM shops WHERE id = @1", p => p.Set(shopid)); } } // return xml XmlContent cont = new XmlContent(true, 1024); cont.ELEM("xml", null, () => { cont.ELEM("return_code", "SUCCESS"); cont.ELEM("return_msg", "OK"); }); if (mgrwx != null) { await PostSendAsync(mgrwx, "【买家付款】订单编号:" + orderid + ",金额:" + cash + "元"); } ac.Give(200, cont); } else { ac.Give(400); } }