Skip to content

Commit 3d0dd22

Browse files
Version 10.0.05
1 parent 17b10e0 commit 3d0dd22

File tree

23 files changed

+630
-283
lines changed

23 files changed

+630
-283
lines changed

Src/Doc/VERSION.TXT

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15235,10 +15235,15 @@ Ver 1.2 Date 13/09/96
1523515235
���������� � ���������� backup ������ ������ � ������ (������ ������ ��������� � ��������� ��-�� ������
1523615236
������� �����).
1523715237
- {DEV} ��������� � ������ json.
15238-
08/05/2018 v10.0.05
15238+
12/05/2018 v10.0.05
1523915239
!- {�������� ���������} ������ (�������-��!) �������� ���������� �������� �� �����, � �������� � ������������
1524015240
��� ������� � ������������ � �������������� ������� ��������� �������.
1524115241
- {�������� ������} � �������� ���������� � �������� ����� � � �������� ������ ���� � ����������� �������� �� STATIC
1524215242
�� EDIT (read-only) � ����� ���� ����������� ���������� ��� ���������� � ����� ������.
15243+
- {����������� �������� ������} ��� ������� �������� ������ � ������ acs.log ������������ �������� ������ �� ������
15244+
��������������� ������ (�� ������, ���������� �����, ����� �����).
15245+
- {���������} ����������� ������� ������������ � �������������� �� ����� ���� ������� �������� ���������.
15246+
- {���������� �������} �������� � ����������� ��������� � ������.
1524315247
-FIX: {����������} ������ ��� �������������� ����������� ����� ��������� ���������������� ������ "������������ ����������� �����".
15248+
-FIX: {DEV} ��������� ������� ������ ������, ����������� ��� ������� json-�����.
1524415249

Src/Include/Pp.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13432,7 +13432,7 @@ struct CcAmountEntry {
1343213432
class CcAmountList : public TSVector <CcAmountEntry> { // @v9.8.4 TSArray-->TSVector
1343313433
public:
1343413434
CcAmountList();
13435-
CcAmountList & Clear();
13435+
CcAmountList & Z();
1343613436
int GetSign() const;
1343713437
int Search(int type, int32 addedID, uint * pPos) const;
1343813438
int SearchAddedID(int32 addedID, uint * pPos) const;
@@ -18676,22 +18676,20 @@ class PPAsyncCashSession : public CSessGrouping {
1867618676
// Temp Session {
1867718677
TempCCheckTbl * P_TmpCcTbl;
1867818678
TempCCheckLineTbl * P_TmpCclTbl;
18679-
CCheckPaymTbl * P_TmpCpTbl; // @v8.1.0
18679+
CCheckPaymTbl * P_TmpCpTbl;
1868018680
// }
1868118681
DeviceLoadingStat * P_Dls;
1868218682
private:
1868318683
int SLAPI GetLastSess(long cashNumber, LDATETIME dtm, long * pSessNumber, PPID * pSessID);
1868418684
int SLAPI SetLastSess(long cashNumber, long sessNumber, PPID sessID, LDATETIME dtm);
1868518685
int SLAPI GetCashSessID(LDATETIME dtm, long cashNumber, long sessNumber, int forwardSess, int temporary, PPID * pSessID);
1868618686
int SLAPI CalcSessionTotal(PPID sessID, CSessTotal *);
18687-
//int SLAPI GroupingSessList(const PPIDArray * pSessList, PPIDArray * pOutList, PPIDArray * pOutTempList, int use_ta);
18688-
int SLAPI ConvertTempSession(int forwardSess, PPIDArray * pSessList);
18689-
//int SLAPI ConvertSessListToBills(PPIDArray * pSessList, PPID locID, int use_ta);
18687+
int SLAPI ConvertTempSession(int forwardSess, PPIDArray & rSessList, void * pTotalLogData);
1869018688
int SLAPI FlashTempCcLines(const SVector *, LAssocArray * pHasExLineList);
1869118689

1869218690
LDATE Beg, End;
1869318691
long CnFlags; // Флаги узла PPCashNode(NodeID) если ~0, то не инициализированы
18694-
long CnExtFlags; // @v8.9.10 Расширенные флаги узла PPCashNode(NodeID) если ~0, то не инициализированы
18692+
long CnExtFlags; // Расширенные флаги узла PPCashNode(NodeID) если ~0, то не инициализированы
1869518693
PPGoodsConfig * P_GCfg;
1869618694

1869718695
struct LastSess {

Src/Include/Private/VERDATA.INC

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
//
22
// ..\INCLUDE\PRIVATE\VERDATA.INC
3-
// 2018-05-12T18:22:25
3+
// 2018-05-13T18:12:06
44
// Automaticaly generated file
55
// Don't modify!
66
//
77
0x24, 0x00, 0x00, 0x00, 0x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xdb, 0xf1, 0xb7, 0x8d, 0xc9, 0xd5, 0x3f, 0x90, 0xf7, 0x92, 0x31, 0xaf, 0x00, 0xfa, 0xcd, 0x82,
12+
0xf2, 0x80, 0x0d, 0x83, 0x1f, 0xd0, 0xa3, 0xda, 0x30, 0xc7, 0xd2, 0xcb, 0xb0, 0x30, 0x32, 0x7a, 0x02, 0x59, 0xdb, 0x8f, 0x56, 0x60, 0x9a, 0x88, 0xb1, 0x32, 0x16, 0xe5, 0x44, 0xc3, 0x17, 0x6a,
13+
0xbd, 0xe7, 0xe5, 0x8a, 0x3a, 0x50, 0xd4, 0xfe, 0x8f, 0xe9, 0x52, 0x1f, 0x15, 0x09, 0x80, 0x7a, 0xe0, 0xa7, 0x16, 0x81, 0x41, 0xb8, 0x84, 0xad, 0xde, 0x06, 0x68, 0x52, 0x7c, 0x51, 0xb8, 0xa7,
14+
0xa5, 0x91, 0xcf, 0x6c, 0x18, 0x62, 0x97, 0xff, 0x29, 0x2a, 0x99, 0x22, 0xb5, 0xe5, 0xcf, 0x08, 0xd5, 0x09, 0x40, 0xf2, 0x0e, 0x38, 0xf5, 0x83, 0xfe, 0x73, 0x0c, 0xc6, 0x35, 0xe4, 0x9e, 0xdf

Src/Include/SLIB.H

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4281,8 +4281,8 @@ char * FASTCALL chomp(char * pStr);
42814281
// Returns:
42824282
// pStr
42834283
//
4284-
char * SLAPI padleft(char * pStr, char pad, size_t n);
4285-
char * SLAPI padright(char * pStr, char pad, size_t n);
4284+
char * FASTCALL padleft(char * pStr, char pad, size_t n);
4285+
char * FASTCALL padright(char * pStr, char pad, size_t n);
42864286
char * SLAPI alignstr(char * pStr, size_t width, int adj);
42874287
// @v9.5.1 (obsolete) int SLAPI getTextHight(char * pStr, int width);
42884288
int SLAPI searchstr(const char * pStr, const SSrchParam & rParam, size_t * pBeg, size_t * pLen);
@@ -4570,9 +4570,9 @@ long FASTCALL diffdate(LDATE d, LDATE s);
45704570

45714571
char * FASTCALL _commfmt(long fmt, char * pBuf);
45724572
SString & FASTCALL _commfmt(long fmt, SString & rBuf);
4573-
char * SLAPI realfmt(double val, long fmt, char * pBuf);
4574-
char * SLAPI intfmt(long val, long fmt, char * pBuf);
4575-
char * SLAPI int64fmt(int64 val, long fmt, char * pBuf);
4573+
char * FASTCALL realfmt(double val, long fmt, char * pBuf);
4574+
char * FASTCALL intfmt(long val, long fmt, char * pBuf);
4575+
char * FASTCALL int64fmt(int64 val, long fmt, char * pBuf);
45764576
//
45774577
// Descr: форматирует длинное целое число val в строку pBuf
45784578
// Если numdigits > 0, то форматирутся с количеством символов равным numDigits
@@ -4582,8 +4582,8 @@ char * SLAPI int64fmt(int64 val, long fmt, char * pBuf);
45824582
// pBuf
45834583
//
45844584
char * FASTCALL longfmtz(long val, int numDigits, char * pBuf, size_t bufLen);
4585-
char * SLAPI uintfmt(ulong val, long fmt, char * pBuf);
4586-
char * SLAPI uint64fmt(uint64 val, long fmt, char * pBuf);
4585+
char * FASTCALL uintfmt(ulong val, long fmt, char * pBuf);
4586+
char * FASTCALL uint64fmt(uint64 val, long fmt, char * pBuf);
45874587
char * SLAPI decfmt(BCD_T val, int len, int prec, long fmt, char * pBuf);
45884588
char * SLAPI datefmt(const void *, long fmt, char *);
45894589
char * SLAPI timefmt(LTIME, long fmt, char *);

Src/Include/json.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,8 @@ struct json_t {
8383
};
8484
explicit json_t(int aType);
8585
~json_t();
86-
void FASTCALL AssignAllocatedText(RcString * pRcs)
87-
{
88-
assert(pRcs);
89-
if(pRcs) {
90-
Text = pRcs->P_Text;
91-
SAlloc::F(pRcs);
92-
}
93-
}
86+
void FASTCALL AssignAllocatedText(RcString * pRcs);
87+
9488
int Type; // the type of node
9589
//char * P_Text; // The text stored by the node. It stores UTF-8 strings and is used exclusively by the json_t::tSTRING and JSON_NUMBER node types
9690
SString Text;
@@ -214,7 +208,8 @@ void FASTCALL json_free_value(json_t ** value);
214208
// @param text a pointer to a char string that will hold the JSON document text.
215209
// @return a json_error code describing how the operation went
216210
//
217-
enum json_error json_tree_to_string(json_t * root, char **text);
211+
//enum json_error json_tree_to_string(json_t * root, char **text);
212+
int FASTCALL json_tree_to_string(const json_t * pRoot, SString & rBuf);
218213
//
219214
// Produces a JSON markup text document from a json_t document tree to a text stream
220215
// @param file a opened file stream

Src/Include/snet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,7 @@ class ScURL {
925925
int HttpPost(const char * pUrl, int mflags, HttpForm & rForm, SFile * pReplyStream);
926926
int HttpPost(const char * pUrl, int mflags, const StrStrAssocArray * pFields, SFile * pReplyStream);
927927
int HttpPost(const InetUrl & rUrl, int mflags, HttpForm & rForm, SFile * pReplyStream);
928+
int HttpPost(const InetUrl & rUrl, int mflags, const StrStrAssocArray * pHttpHeaderFields, const char * pBody, SFile * pReplyStream);
928929
int HttpGet(const char * pUrl, int mflags, SFile * pReplyStream);
929930
int HttpGet(const char * pUrl, int mflags, const StrStrAssocArray * pHttpHeaderFields, SFile * pReplyStream);
930931
int HttpGet(const InetUrl & rUrl, int mflags, const StrStrAssocArray * pHttpHeaderFields, SFile * pReplyStream);

Src/PPEquip/DreamKas.cpp

Lines changed: 170 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class ACS_DREAMKAS : public PPAsyncCashSession {
2121
PPID StatID;
2222
private:
2323
int SLAPI ConvertWareList(const char * pImpPath);
24+
int SLAPI ParseGoods(const json_t * pJsonObj, S_GUID & rUuid, SString & rName);
25+
int SLAPI ImportGoodsList(UUIDAssocArray & rList);
26+
int SLAPI SendGoods(json_t ** ppJson, uint & rCount, int update, int force);
2427
int SLAPI ExportGoods(AsyncCashGoodsIterator & rIter, const PPAsyncCashNode & rCnData, PPID gcAlcID);
2528
int SLAPI MakeAuthField(SString & rBuf);
2629

@@ -89,6 +92,142 @@ int SLAPI ACS_DREAMKAS::MakeAuthField(SString & rBuf)
8992
return ok;
9093
}
9194

95+
int SLAPI ACS_DREAMKAS::ParseGoods(const json_t * pJsonObj, S_GUID & rUuid, SString & rName)
96+
{
97+
rUuid.Z();
98+
rName.Z();
99+
int ok = 1;
100+
SString temp_buf;
101+
for(const json_t * p_cur = pJsonObj; p_cur; p_cur = p_cur->P_Next) {
102+
if(p_cur->Text.IsEqiAscii("id")) {
103+
if(p_cur->P_Child) {
104+
rUuid.FromStr(p_cur->P_Child->Text);
105+
}
106+
}
107+
else if(p_cur->Text.IsEqiAscii("name")) {
108+
if(p_cur->P_Child) {
109+
rName = (temp_buf = p_cur->P_Child->Text).Unescape();
110+
}
111+
}
112+
}
113+
if(rName.Empty() || rUuid.IsZero())
114+
ok = -1;
115+
return ok;
116+
}
117+
118+
int SLAPI ACS_DREAMKAS::ImportGoodsList(UUIDAssocArray & rList)
119+
{
120+
rList.clear();
121+
int ok = -1;
122+
json_t * p_json_doc = 0;
123+
SString temp_buf;
124+
SString goods_name;
125+
SString wait_msg_buf;
126+
ScURL c;
127+
InetUrl url("https://kabinet.dreamkas.ru/api/v2/products");
128+
StrStrAssocArray hdr_flds;
129+
const long max_chunk_count = 100;
130+
long query_offs = 0;
131+
long ret_count = 0;
132+
{
133+
SFileFormat::GetMime(SFileFormat::Json, temp_buf);
134+
hdr_flds.Add("Content-Type", temp_buf);
135+
THROW(MakeAuthField(temp_buf));
136+
hdr_flds.Add("Authorization", temp_buf);
137+
}
138+
PPLoadText(PPTXT_IMPGOODS, wait_msg_buf);
139+
do {
140+
SBuffer ack_buf;
141+
SFile wr_stream(ack_buf, SFile::mWrite);
142+
ret_count = 0;
143+
url.SetComponent(InetUrl::cQuery, temp_buf.Z().CatEq("limit", max_chunk_count).CatChar('&').CatEq("offset", query_offs));
144+
THROW_SL(c.HttpGet(url, ScURL::mfDontVerifySslPeer|ScURL::mfVerbose, &hdr_flds, &wr_stream));
145+
//
146+
{
147+
SBuffer * p_ack_buf = (SBuffer *)wr_stream;
148+
if(p_ack_buf) {
149+
const int avl_size = (int)p_ack_buf->GetAvailableSize();
150+
temp_buf.Z().CatN((const char *)p_ack_buf->GetBuf(), avl_size);
151+
if(json_parse_document(&p_json_doc, temp_buf.cptr()) == JSON_OK) {
152+
long seq_id = 0;
153+
S_GUID goods_uuid;
154+
json_t * p_next = 0;
155+
for(json_t * p_cur = p_json_doc; p_cur; p_cur = p_next) {
156+
p_next = p_cur->P_Next;
157+
switch(p_cur->Type) {
158+
case json_t::tARRAY:
159+
p_next = p_cur->P_Child;
160+
break;
161+
case json_t::tOBJECT:
162+
ret_count++;
163+
if(ParseGoods(p_cur->P_Child, goods_uuid, goods_name) > 0) {
164+
rList.Add(++seq_id, goods_uuid, 0);
165+
ok = 1;
166+
}
167+
break;
168+
}
169+
}
170+
}
171+
json_free_value(&p_json_doc);
172+
p_json_doc = 0;
173+
}
174+
}
175+
query_offs += ret_count;
176+
PPWaitMsg((temp_buf = wait_msg_buf).Space().Cat(query_offs));
177+
} while(ret_count > 0 && ret_count == max_chunk_count);
178+
CATCHZOK
179+
json_free_value(&p_json_doc);
180+
return ok;
181+
}
182+
183+
int SLAPI ACS_DREAMKAS::SendGoods(json_t ** ppJson, uint & rCount, int update, int force)
184+
{
185+
int ok = -1;
186+
if(rCount && (force || rCount >= 100)) {
187+
SString temp_buf;
188+
SString json_buf;
189+
ScURL c;
190+
SBuffer ack_buf;
191+
StrStrAssocArray hdr_flds;
192+
SFile wr_stream(ack_buf, SFile::mWrite);
193+
{
194+
SFileFormat::GetMime(SFileFormat::Json, temp_buf);
195+
hdr_flds.Add("Content-Type", temp_buf);
196+
THROW(MakeAuthField(temp_buf));
197+
hdr_flds.Add("Authorization", temp_buf);
198+
}
199+
InetUrl url("https://kabinet.dreamkas.ru/api/v2/products");
200+
const char * p_debug_file_name = update ? "dreamkas-export-upd-debug.json" : "dreamkas-export-add-debug.json";
201+
PPGetFilePath(PPPATH_OUT, p_debug_file_name, temp_buf);
202+
SFile f_out_test(temp_buf, SFile::mAppend);
203+
THROW_SL(json_tree_to_string(*ppJson, json_buf));
204+
if(!update) {
205+
THROW_SL(c.HttpPost(url, ScURL::mfDontVerifySslPeer|ScURL::mfVerbose, &hdr_flds, json_buf, &wr_stream));
206+
}
207+
else {
208+
THROW_SL(c.HttpPatch(url, ScURL::mfDontVerifySslPeer|ScURL::mfVerbose, &hdr_flds, json_buf, &wr_stream));
209+
}
210+
{
211+
SBuffer * p_ack_buf = (SBuffer *)wr_stream;
212+
if(p_ack_buf) {
213+
const int avl_size = (int)p_ack_buf->GetAvailableSize();
214+
temp_buf.Z().CatN((const char *)p_ack_buf->GetBuf(), avl_size);
215+
f_out_test.WriteLine(temp_buf.CR().CR());
216+
}
217+
}
218+
json_format_string(json_buf, temp_buf.Z());
219+
f_out_test.WriteLine(temp_buf);
220+
//
221+
json_free_value(ppJson);
222+
if(!force) {
223+
THROW_MEM(*ppJson = new json_t(json_t::tARRAY));
224+
}
225+
rCount = 0;
226+
}
227+
CATCHZOK
228+
return ok;
229+
}
230+
92231
int SLAPI ACS_DREAMKAS::ExportGoods(AsyncCashGoodsIterator & rIter, const PPAsyncCashNode & rCnData, PPID gcAlcID)
93232
{
94233
int ok = 1;
@@ -97,8 +236,17 @@ int SLAPI ACS_DREAMKAS::ExportGoods(AsyncCashGoodsIterator & rIter, const PPAsyn
97236
AsyncCashGoodsInfo gds_info;
98237
PPIDArray rmv_goods_list;
99238
PrcssrAlcReport::GoodsItem agi;
100-
json_t * p_iter_ary = new json_t(json_t::tARRAY);
101-
THROW_SL(p_iter_ary);
239+
UUIDAssocArray ex_goods_list;
240+
LongArray normal_bc_pos_list;
241+
LongArray etc_bc_pos_list;
242+
uint items_to_create_count = 0;
243+
uint items_to_update_count = 0;
244+
char * p_json_buf = 0;
245+
json_t * p_iter_ary_to_create = new json_t(json_t::tARRAY);
246+
json_t * p_iter_ary_to_update = new json_t(json_t::tARRAY);
247+
THROW_SL(p_iter_ary_to_create);
248+
THROW_SL(p_iter_ary_to_update);
249+
THROW(ImportGoodsList(ex_goods_list));
102250
while(rIter.Next(&gds_info) > 0) {
103251
if(gds_info.GoodsFlags & GF_PASSIV && rCnData.ExtFlags & CASHFX_RMVPASSIVEGOODS && gds_info.Rest <= 0.0) {
104252
rmv_goods_list.addUnique(gds_info.ID);
@@ -123,8 +271,8 @@ int SLAPI ACS_DREAMKAS::ExportGoods(AsyncCashGoodsIterator & rIter, const PPAsyn
123271
THROW_SL(json_insert_pair_into_object(p_iter_obj, "quantity", json_new_number(temp_buf.Z().Cat(1000))));
124272
THROW_SL(json_insert_pair_into_object(p_iter_obj, "price", json_new_number(temp_buf.Z().Cat((long)(gds_info.Price * 100.0)))));
125273
if(gds_info.P_CodeList) {
126-
LongArray normal_bc_pos_list;
127-
LongArray etc_bc_pos_list;
274+
normal_bc_pos_list.clear();
275+
etc_bc_pos_list.clear();
128276
for(uint i = 0; i < gds_info.P_CodeList->getCount(); i++) {
129277
const BarcodeTbl::Rec & r_bc_item = gds_info.P_CodeList->at(i);
130278
int d = 0;
@@ -156,48 +304,29 @@ int SLAPI ACS_DREAMKAS::ExportGoods(AsyncCashGoodsIterator & rIter, const PPAsyn
156304
THROW_SL(json_insert_pair_into_object(p_iter_obj, "vendorCodes", p_array));
157305
}
158306
}
159-
THROW_SL(json_insert_child(p_iter_ary, p_iter_obj));
160-
}
161-
}
162-
PPWaitPercent(rIter.GetIterCounter());
163-
}
164-
{
165-
PPGetFilePath(PPPATH_OUT, "dreamkas-export-debug.json", temp_buf);
166-
SFile f_out_test(temp_buf, SFile::mWrite);
167-
char * p_json_buf = 0;
168-
json_tree_to_string(p_iter_ary, &p_json_buf);
169-
{
170-
ScURL c;
171-
SBuffer ack_buf;
172-
InetUrl url("https://kabinet.dreamkas.ru/api/v2/products/id");
173-
SFile wr_stream(ack_buf, SFile::mWrite);
174-
ScURL::HttpForm hf;
175-
StrStrAssocArray hdr_flds;
176-
177-
{
178-
SFileFormat::GetMime(SFileFormat::Json, temp_buf);
179-
hdr_flds.Add("Content-Type", temp_buf);
180-
//
181-
THROW(MakeAuthField(temp_buf));
182-
hdr_flds.Add("Authorization", temp_buf);
183-
}
184-
THROW_SL(c.HttpPatch(url, ScURL::mfDontVerifySslPeer|ScURL::mfVerbose, &hdr_flds, p_json_buf, &wr_stream));
185-
//
186-
{
187-
SBuffer * p_ack_buf = (SBuffer *)wr_stream;
188-
if(p_ack_buf) {
189-
const int avl_size = (int)p_ack_buf->GetAvailableSize();
190-
temp_buf.Z().CatN((const char *)p_ack_buf->GetBuf(), avl_size);
191-
f_out_test.WriteLine(temp_buf.CR().CR());
307+
{
308+
long seq_id = 0;
309+
if(ex_goods_list.SearchVal(gds_info.Uuid, &seq_id, 0)) {
310+
THROW_SL(json_insert_child(p_iter_ary_to_update, p_iter_obj));
311+
items_to_update_count++;
312+
THROW(SendGoods(&p_iter_ary_to_update, items_to_update_count, 1, 0));
313+
}
314+
else {
315+
THROW_SL(json_insert_child(p_iter_ary_to_create, p_iter_obj));
316+
items_to_create_count++;
317+
THROW(SendGoods(&p_iter_ary_to_create, items_to_create_count, 0, 0));
318+
}
192319
}
193320
}
194321
}
195-
json_format_string(p_json_buf, temp_buf.Z());
196-
f_out_test.WriteLine(temp_buf);
197-
SAlloc::F(p_json_buf);
322+
PPWaitPercent(rIter.GetIterCounter());
198323
}
324+
THROW(SendGoods(&p_iter_ary_to_update, items_to_update_count, 1, 1));
325+
THROW(SendGoods(&p_iter_ary_to_create, items_to_create_count, 0, 1));
199326
CATCHZOK
200-
json_free_value(&p_iter_ary);
327+
json_free_value(&p_iter_ary_to_create);
328+
json_free_value(&p_iter_ary_to_update);
329+
ZFREE(p_json_buf);
201330
return ok;
202331
}
203332

0 commit comments

Comments
 (0)