Explorar o código

240719-1403-Kim

EricKIm hai 4 meses
pai
achega
dbd9c4cfd4

+ 48 - 0
Ditem.json

@@ -0,0 +1,48 @@
+type SchDitem struct {
+	Id             string `xorm:"not null pk default '' comment('상품링크코드:유일코드') VARCHAR(1)"`
+	CreatedOn      int64  `xorm:"default 0 comment('작성일자') BIGINT(20)"`
+	UpdatedOn      int64  `xorm:"not null default 0 comment('수정일자') BIGINT(11)"`
+	BrandUid       string `xorm:"not null default 'no-brand' comment('브랜드유일키') VARCHAR(64)"`
+	IgroupCode     string `xorm:"not null comment('상품카테고리 코드') VARCHAR(21)"`
+	IgroupName     string `xorm:"not null comment('상품카테고리명') VARCHAR(21)"`
+	ItemCode       string `xorm:"not null comment('상품코드') VARCHAR(21)"`
+	ItemName       string `xorm:"not null comment('상품명') VARCHAR(82)"`
+	CountUnit      string `xorm:"not null comment('수량단위(EA등)') VARCHAR(5)"`
+	CargoType      string `xorm:"not null comment('화물구분:택배,소포,등기') VARCHAR(5)"`
+	ShipType       string `xorm:"not null comment('배송구분:일반배송,오늘출발 등') VARCHAR(5)"`
+	LocationType   string `xorm:"not null default '0' comment('배송유형:0국내, 1해외') CHAR(1)"`
+	ExposeEdate    string `xorm:"not null default '0' comment('노출시작일') CHAR(1)"`
+	ExposeSdate    string `xorm:"not null default '0' comment('노출 종료일') CHAR(1)"`
+	ShipFeeType    string `xorm:"not null comment('배송비구분:무료,고정비,조건별,수량별,구간별') VARCHAR(5)"`
+	IsShipGrouping string `xorm:"not null comment('묶음배송 가능') VARCHAR(5)"`
+	ShipPayment    string `xorm:"not null comment('배송비지불방식:0선불,1착불,2선택') VARCHAR(5)"`
+	ShipFee        string `xorm:"not null comment('무료,고정배송비경우 금액') DECIMAL(18,4)"`
+	FeeCondAmt     string `xorm:"not null comment('무료조건금액') DECIMAL(18,4)"`
+	ListPrc        string `xorm:"not null default 0.0000 comment('소매정가') DECIMAL(18,4)"`
+	SalesPrc       string `xorm:"default 0.0000 comment('판매가') DECIMAL(18,4)"`
+	CurrStkQty     string `xorm:"not null default 999999.0000 comment('현재고') DECIMAL(18,4)"`
+	CsTelno        string `xorm:"not null comment('서비스센터 전화번화') VARCHAR(5)"`
+	CsDesc         string `xorm:"not null comment('서비스센터 설명문') VARCHAR(5)"`
+	Maker          string `xorm:"not null comment('제조사') VARCHAR(5)"`
+	ShortDesc      string `xorm:"not null default '' comment('짧은설명-html') TEXT"`
+	ItemDesc       string `xorm:"comment('품목설명-html') TEXT"`
+	Model          string `xorm:"not null comment('모델명') VARCHAR(5)"`
+	MixQty         string `xorm:"default 0.0000 comment('구매최소량') DECIMAL(18,4)"`
+	MaxQty         string `xorm:"default 0.0000 comment('구매최대량') DECIMAL(18,4)"`
+	SeoKeys        string `xorm:"default 0.0000 comment('구매최대량') DECIMAL(18,4)"`
+	TaxType        string `xorm:"not null comment('과세,영세,면세') VARCHAR(5)"`
+	OriginCode     string `xorm:"not null comment('원산지국가코드') VARCHAR(5)"`
+	Status         string `xorm:"not null default '0' comment('판매상태: 0판매중, 1품절, 2:단종, 3:중지') CHAR(1)"`
+	Importer       string `xorm:"not null comment('수입사') VARCHAR(5)"`
+	IsAdultOnly    string `xorm:"not null comment('성인용품') VARCHAR(5)"`
+	Opt1Caption    string `xorm:"not null comment('옵션명1') VARCHAR(5)"`
+	Opt1Values     string `xorm:"not null comment('옵션값1') VARCHAR(5)"`
+	Opt2Caption    string `xorm:"not null comment('옵션명2') VARCHAR(5)"`
+	Opt2Values     string `xorm:"not null comment('옵션값2') VARCHAR(5)"`
+	Opt3Caption    string `xorm:"not null comment('옵션명3') VARCHAR(5)"`
+	Opt3Values     string `xorm:"not null comment('옵션값3') VARCHAR(5)"`
+	OptPrices      string `xorm:"not null comment('옵션별 추가금액') VARCHAR(5)"`
+	OptStkQtys     string `xorm:"not null comment('옵션별 재고수량') VARCHAR(5)"`
+	OptStatuses    string `xorm:"not null comment('옵션별 상태') VARCHAR(5)"`
+	OptUsables     string `xorm:"not null comment('옵션별 사용여부') VARCHAR(5)"`
+}

+ 2 - 0
elastic-qry/delete/erp_buyer.es

@@ -0,0 +1,2 @@
+# 인덱스 삭제
+DELETE /erp_buyer

+ 2 - 0
elastic-qry/delete/erp_sorder.es

@@ -0,0 +1,2 @@
+# 인덱스 삭제
+DELETE /erp_sorder

+ 2 - 0
elastic-qry/delete/sch_ditem.es

@@ -0,0 +1,2 @@
+# 인덱스 삭제
+DELETE /erp_sorder

+ 1 - 0
elastic-qry/get/index_list.es

@@ -0,0 +1 @@
+GET /_cat/indices

+ 4 - 0
elastic-qry/get/sch_ditem-list.es

@@ -0,0 +1,4 @@
+GET _sql?format=json
+{
+"query": "SELECT * FROM sch_ditem"
+}

+ 9 - 0
elastic-qry/sort/ditem.es

@@ -0,0 +1,9 @@
+PUT sch_ditem/_mapping
+{
+  "properties": {
+    "id": { 
+      "type":     "text",
+      "fielddata": true
+    }
+  }
+}

+ 15 - 0
function-in-db/functions/_curr_month.sql

@@ -0,0 +1,15 @@
+DROP FUNCTION IF EXISTS _curr_month;
+DELIMITER //
+
+create function _curr_month ( _date varchar(8) )
+returns VARCHAR(6)
+
+begin
+   declare ret varchar(6);
+	   set ret = concat(substring(_date, 1,4),substring(_date, 5,2));
+   RETURN ret;
+end; //
+
+DELIMITER ;
+
+select _curr_month('20220101')

+ 1 - 0
function-in-db/functions/_prev_month.sql

@@ -1,3 +1,4 @@
+DROP FUNCTION IF EXISTS _prev_month;
 DELIMITER //
 
 create function _prev_month ( _date varchar(8) )

+ 136 - 0
function-in-db/procedures/stock-io/lt1-stock-io-sum-bal-bf-turbo.sql

@@ -0,0 +1,136 @@
+truncate table dbt_list_type1;
+
+drop procedure if exists lt1_stock_io_sum_bal;
+DELIMITER //
+create procedure lt1_stock_io_sum_bal( _listToken varchar(21), _sdate varchar(8), _edate varchar(8), 
+_s1 varchar(32), _e1 varchar(32), _s2 varchar(32), _e2 varchar(32), 
+_s3 varchar(32), _e3 varchar(32), _s4 varchar(32), _e4 varchar(32), 
+_where varchar(386), _having varchar(386), _orderby varchar(64), 
+_branch int, _storage int)
+
+BEGIN
+
+Declare _sbal_date varchar(8);
+Declare _ebal_date varchar(8);
+
+Declare _sbet1 varchar(64);
+Declare _ebet1 varchar(64);
+Declare _sbet2 varchar(64);
+Declare _ebet2 varchar(64);
+Declare _sbet3 varchar(64);
+Declare _ebet3 varchar(64);
+
+
+if _is_first_date(_sdate) then
+	set _sbal_date = '19000101';
+	set _ebal_date = '19000101';
+else
+	set _sbal_date = _sdate;
+	set _ebal_date = _edate;
+end if;
+
+if _s1 != '' and _e1 != '' then
+	set _sbet1 = _s1;
+	set _ebet1 = _e1;
+else
+	set _sbet1 = '!';
+	set _ebet1 = '힣';
+end if;
+
+if _s2 != '' and _e2 != '' then
+	set _sbet2 = _s2;
+	set _ebet2 = _e2;
+else
+	set _sbet2 = '!';
+	set _ebet2 = '힣';
+end if;
+
+
+if _s3 != '' and _e3 != '' then
+	set _sbet3 = _s3;
+	set _ebet3 = _e3;
+else
+	set _sbet3 = '!';
+	set _ebet3 = '힣';
+end if;
+
+-- 전월 재고 --
+-- bad_qty 는 Delta 만 보여줌.
+insert into dbt_list_sum
+	( created_on, list_token, h_id, id, c1, c2, c3,
+     d1, d2, d3, d4, d5,
+     c4, c5, order_by )
+
+select unix_timestamp(), _listToken, mx.id, mx.id, item_code, item_name, sub_name,
+     bal_qty, 0, 0, 0, 0,
+   	igroup_name, igroup_code, item_code
+
+from ( select id, item_code, item_name, sub_name, igroup_id
+		from dbr_item as itm
+		where item_code between _sbet2 and _ebet2
+            and isnt_stkio = '0' and is_material = '0'
+	) as mx
+    inner join ( select item_id, bal_qty  
+		from dbr_bal_item
+		where yyyy_mm = _prev_month(_sdate) and storage_id = _storage
+	) as bal on mx.id = bal.item_id
+
+    inner join ( select id, igroup_code, igroup_name
+		from dbr_igroup
+		where igroup_code between _sbet1 and _ebet1
+	) as igr on mx.igroup_id = igr.id
+
+order by item_code asc;
+
+-- 당월 수불 합계 --
+insert into dbt_list_sum
+	( created_on, list_token, h_id, id, c1, c2, c3,
+     d1, d2, d3,
+     d4, d5,
+     c4, c5, order_by )
+
+select unix_timestamp(), _listToken, mx.id, mx.id, item_code, item_name, sub_name,
+     0, sum(io_qty*cast((stock_status+1)/2 as int)), sum(io_qty*cast(-1*(stock_status-1)/2 as int)),
+     0, sum(io_qty*badstk_status),
+   	igroup_name, igroup_code, item_code
+
+from ( select id, item_code, item_name, sub_name, igroup_id
+		from dbr_item as itm
+		where item_code between _sbet2 and _ebet2
+            and isnt_stkio = '0' and is_material = '0'
+	) as mx
+    inner join ( select item_id, io_qty, stock_status, badstk_status
+		from dbr_stock_io  as stk
+            inner join dbr_deal_type as deal on deal.id = stk.deal_type_id
+		where io_date between _sdate and _edate
+			and storage_id = _storage
+	) as stk on mx.id = stk.item_id
+
+    inner join ( select id, igroup_code, igroup_name
+		from dbr_igroup
+		where igroup_code between _sbet1 and _ebet1
+	) as igr on mx.igroup_id = igr.id
+group by stk.item_id
+order by item_code asc;
+
+-- dbt_list_type1 으로 집계 --
+insert into dbt_list_type1
+	( created_on, list_token, h_id, id, c1, c2, c3,
+		d1, d2, d3, d4, d5,
+		c4, c5, order_by)
+select min(unix_timestamp()), min(_listToken), min(id), min(id), min(c1), min(c2), min(c3),
+	sum(d1),
+	sum(d2),
+	sum(d3),
+    sum(d1) + sum(d2) - sum(d3),
+	sum(d5),
+	min(c4), min(c5), min(order_by)
+from dbt_list_sum as mx
+where list_token = _listToken
+group by mx.id
+having min(mx.id) is not null
+order by order_by asc;
+
+END;
+//
+DELIMITER ;

+ 10 - 73
function-in-db/procedures/stock-io/lt1-stock-io-sum-bal.sql

@@ -54,82 +54,19 @@ else
 	set _ebet3 = '힣';
 end if;
 
--- 전월 재고 --
--- bad_qty 는 Delta 만 보여줌.
-insert into dbt_list_sum
-	( created_on, list_token, h_id, id, c1, c2, c3,
-     d1, d2, d3, d4, d5,
-     c4, c5, order_by )
-
-select unix_timestamp(), _listToken, mx.id, mx.id, item_code, item_name, sub_name,
-     bal_qty, 0, 0, 0, 0,
-   	igroup_name, igroup_code, item_code
-
-from ( select id, item_code, item_name, sub_name, igroup_id
-		from dbr_item as itm
-		where item_code between _sbet2 and _ebet2
-            and isnt_stkio = '0' and is_material = '0'
-	) as mx
-    inner join ( select item_id, bal_qty  
-		from dbr_bal_item
-		where yyyy_mm = _prev_month(_sdate) and storage_id = _storage
-	) as bal on mx.id = bal.item_id
-
-    inner join ( select id, igroup_code, igroup_name
-		from dbr_igroup
-		where igroup_code between _sbet1 and _ebet1
-	) as igr on mx.igroup_id = igr.id
-
-order by item_code asc;
-
--- 당월 수불 합계 --
-insert into dbt_list_sum
-	( created_on, list_token, h_id, id, c1, c2, c3,
-     d1, d2, d3,
-     d4, d5,
-     c4, c5, order_by )
-
-select unix_timestamp(), _listToken, mx.id, mx.id, item_code, item_name, sub_name,
-     0, sum(io_qty*cast((stock_status+1)/2 as int)), sum(io_qty*cast(-1*(stock_status-1)/2 as int)),
-     0, sum(io_qty*badstk_status),
-   	igroup_name, igroup_code, item_code
-
-from ( select id, item_code, item_name, sub_name, igroup_id
-		from dbr_item as itm
-		where item_code between _sbet2 and _ebet2
-            and isnt_stkio = '0' and is_material = '0'
-	) as mx
-    inner join ( select item_id, io_qty, stock_status, badstk_status
-		from dbr_stock_io  as stk
-            inner join dbr_deal_type as deal on deal.id = stk.deal_type_id
-		where io_date between _sdate and _edate
-			and storage_id = _storage
-	) as stk on mx.id = stk.item_id
-
-    inner join ( select id, igroup_code, igroup_name
-		from dbr_igroup
-		where igroup_code between _sbet1 and _ebet1
-	) as igr on mx.igroup_id = igr.id
-group by stk.item_id
-order by item_code asc;
-
--- dbt_list_type1 으로 집계 --
 insert into dbt_list_type1
 	( created_on, list_token, h_id, id, c1, c2, c3,
 		d1, d2, d3, d4, d5,
-		c4, c5, order_by)
-select min(unix_timestamp()), min(_listToken), min(id), min(id), min(c1), min(c2), min(c3),
-	sum(d1),
-	sum(d2),
-	sum(d3),
-    sum(d1) + sum(d2) - sum(d3),
-	sum(d5),
-	min(c4), min(c5), min(order_by)
-from dbt_list_sum as mx
-where list_token = _listToken
-group by mx.id
-having min(mx.id) is not null
-order by order_by asc;
+        d6, c4, c5, order_by )
+select unix_timestamp(), _listToken, item_id, item_id, item_code, item_name, sub_name,
+    begin_bal_qty, in_sum_qty, out_sum_qty, end_bal_qty, (bad_end_bal_qty - bad_begin_bal_qty),
+    bad_end_bal_qty, igroup_name, igroup_code, item_code
+from dbr_bal_item as mx
+    inner join dbr_item as itm on itm.id = mx.item_id
+    inner join dbr_igroup as igr  on igr.id = itm.igroup_id
+where yyyy_mm = _prev_month(_sdate) and storage_id = _storage
+	and igroup_code between _sbet1 and _ebet1
+order by item_code asc;
 
 END;
 //

+ 122 - 0
function-in-db/procedures/stock-io/pl1_stock_io_ledger_detail-bf-turbo.sql

@@ -0,0 +1,122 @@
+truncate table dbt_list_type1;
+truncate table dbt_list_sum;
+drop procedure if exists pl1_stock_io_ledger_detail;
+
+DELIMITER //
+create procedure pl1_stock_io_ledger_detail( _listToken varchar(21), _sdate varchar(8), _edate varchar(8), 
+_s1 varchar(32), _e1 varchar(32), _s2 varchar(32), _e2 varchar(32), 
+_s3 varchar(32), _e3 varchar(32), _s4 varchar(32), _e4 varchar(32), 
+_where varchar(386), _having varchar(386), _orderby varchar(64), 
+_branch int, _storage int, _target int)
+
+BEGIN
+
+Declare _sbal_date varchar(8);
+Declare _ebal_date varchar(8);
+
+Declare _first_bal decimal(20,4);
+Declare _first_bad_bal decimal(20,4);
+Declare _first_bal_caption varchar(20);
+
+-- Declare _first_id int;
+-- Declare _last_id int;
+
+Declare _line_id int;
+Declare _line_badstk_status varchar(64);
+Declare _line_in decimal(20,4) default "0.0000";
+Declare _line_out decimal(20,4) default "0.0000";
+Declare _line_bal decimal(20,4) default "0.0000";
+Declare _line_bad_bal decimal(20,4) default "0.0000";
+Declare _in_sum decimal(20,4) default "0.0000";
+Declare _out_sum decimal(20,4) default "0.0000";
+
+Declare _company_name varchar(64);
+
+Declare _item_code varchar(21);
+Declare _item_sub_name varchar(128);
+
+Declare _not_found boolean;
+Declare _line_cur cursor for -- c5:badstk_status
+    select t_id, c5, d2, d3 from dbt_list_type1 where list_token = _listToken 
+	order by order_by asc;
+Declare continue handler for 
+        not found set _not_found = true;
+
+if _is_first_date(_sdate) then
+	set _sbal_date = '19000101';
+	set _ebal_date = '19000101';
+else
+	set _sbal_date = _sdate;
+	set _ebal_date = _edate;
+end if;
+
+-- insert for first_bal
+select ifnull(last_mbal.bal_qty,0) + ifnull(stk_bal.io_qty,0) , 
+		ifnull(last_mbal.bad_bal_qty,0) + ifnull(stk_bal.bad_io_qty,0) ,'이월재고' 
+	into _first_bal, _first_bad_bal, _first_bal_caption
+	from
+		dbr_item as mxv
+		left join
+		( select item_id, bal_qty, bad_bal_qty
+		from dbr_bal_item
+		where yyyy_mm = _prev_month(_sdate) and storage_id = _storage
+		) as last_mbal
+		on mxv.id = last_mbal.item_id
+
+		left join
+		( select stk.item_id, sum(io_qty*stock_status) AS io_qty, sum(io_qty*badstk_status) AS bad_io_qty
+		from dbr_stock_io  as stk
+			inner join dbr_deal_type as deal on deal.id = stk.deal_type_id
+		where io_date between _first_date(_sbal_date) and _prev_date(_ebal_date)
+			and storage_id = _storage
+		group by stk.item_id
+		) as stk_bal
+		on mxv.id = stk_bal.item_id
+
+where mxv.id = _target;
+
+insert into dbt_list_type1 ( created_on, list_token, c3, d4, d5, order_by)
+	values ( unix_timestamp(), _listToken, _first_bal_caption, _first_bal, _first_bad_bal, '19000101');
+
+-- insert for stock_io
+insert into dbt_list_type1
+	( created_on, list_token, c1, c2, c3, c4, c5, d1, d2, d3, order_by)
+select unix_timestamp(), _listToken, io_date, deal_code, concat(slip_no,' / ', stk.seq_no )slip_no, company_name, badstk_status,
+		io_prc, stk.io_qty*cast((stock_status+1)/2 as int), stk.io_qty*cast(-1*(stock_status-1)/2 as int),
+		concat( io_date, '-', -1*stock_status,'-', slip_no, '-', seq_no)
+from dbr_stock_io  as stk
+	inner join dbr_company as cmp on cmp.id = stk.company_id
+	inner join dbr_deal_type as deal on deal.id = stk.deal_type_id
+where io_date between _sdate and _edate and storage_id = _storage and stk.item_id = _target;
+
+-- compute line_bal
+set _line_bal = _first_bal;
+set _line_bad_bal = _first_bad_bal;
+open _line_cur;
+	loop1: loop
+		fetch _line_cur into _line_id, _line_badstk_status, _line_in, _line_out;
+		if _not_found then leave loop1; end if;
+
+		set _in_sum = _in_sum + ifnull(_line_in,0);
+		set _out_sum = _out_sum + ifnull(_line_out,0);
+
+		if _line_badstk_status = '0' then
+			set _line_bal = ifnull(_line_bal,0) + ifnull(_line_in,0) - ifnull(_line_out,0);
+		else 
+			set _line_bad_bal = ifnull(_line_bad_bal,0) + ifnull(_line_in,0) - ifnull(_line_out,0);
+		end if;
+
+		update dbt_list_type1 set d4 = _line_bal, d5 = _line_bad_bal  where t_id = _line_id;
+	end loop loop1;
+close _line_cur;
+
+-- write list_sum
+select item_code, concat(item_name,' / ',sub_name ) into _item_code, _item_sub_name from dbr_item where id = _target;
+insert into dbt_list_sum
+	( created_on, list_token, c1, c2, c3, c4, d1, d2, d3, d4)
+	values (unix_timestamp(), _listToken, _item_code, _item_sub_name, _sdate, _edate, 
+	_first_bal, _in_sum, _out_sum, _line_bal);
+
+END;
+//
+DELIMITER ;

+ 14 - 33
function-in-db/procedures/stock-io/pl1_stock_io_ledger_detail.sql

@@ -22,7 +22,7 @@ Declare _first_bal_caption varchar(20);
 -- Declare _last_id int;
 
 Declare _line_id int;
-Declare _line_badstk_status varchar(64);
+Declare _line_badstk_status varchar(1);
 Declare _line_in decimal(20,4) default "0.0000";
 Declare _line_out decimal(20,4) default "0.0000";
 Declare _line_bal decimal(20,4) default "0.0000";
@@ -50,43 +50,23 @@ else
 	set _ebal_date = _edate;
 end if;
 
--- insert for first_bal
-select ifnull(last_mbal.bal_qty,0) + ifnull(stk_bal.io_qty,0) , 
-		ifnull(last_mbal.bad_bal_qty,0) + ifnull(stk_bal.bad_io_qty,0) ,'이월재고' 
-	into _first_bal, _first_bad_bal, _first_bal_caption
-	from
-		dbr_item as mxv
-		left join
-		( select item_id, bal_qty, bad_bal_qty
-		from dbr_bal_item
-		where yyyy_mm = _prev_month(_sdate) and storage_id = _storage
-		) as last_mbal
-		on mxv.id = last_mbal.item_id
-
-		left join
-		( select stk.item_id, sum(io_qty*stock_status) AS io_qty, sum(io_qty*badstk_status) AS bad_io_qty
-		from dbr_stock_io  as stk
-			inner join dbr_deal_type as deal on deal.id = stk.deal_type_id
-		where io_date between _first_date(_sbal_date) and _prev_date(_ebal_date)
-			and storage_id = _storage
-		group by stk.item_id
-		) as stk_bal
-		on mxv.id = stk_bal.item_id
-
-where mxv.id = _target;
+-- insert for begin_bals
+select begin_bal_qty, bad_begin_bal_qty
+	into _first_bal, _first_bad_bal
+from dbr_bal_item
+where yyyy_mm = substring(_sdate, 1, 6) and storage_id = _storage and item_id = _target;
 
 insert into dbt_list_type1 ( created_on, list_token, c3, d4, d5, order_by)
-	values ( unix_timestamp(), _listToken, _first_bal_caption, _first_bal, _first_bad_bal, '19000101');
+	values ( unix_timestamp(), _listToken, '이월재고', _first_bal, _first_bad_bal, '19000101');
 
 -- insert for stock_io
-insert into dbt_list_type1
-	( created_on, list_token, c1, c2, c3, c4, c5, d1, d2, d3, order_by)
-select unix_timestamp(), _listToken, io_date, deal_code, concat(slip_no,' / ', stk.seq_no )slip_no, company_name, badstk_status,
-		io_prc, stk.io_qty*cast((stock_status+1)/2 as int), stk.io_qty*cast(-1*(stock_status-1)/2 as int),
-		concat( io_date, '-', -1*stock_status,'-', slip_no, '-', seq_no)
+insert into dbt_list_type1 ( created_on, list_token, 
+	c1, c2, c3, c4, c5, 
+	d1, d2, d3, order_by)
+select unix_timestamp(), _listToken, 
+	io_date, deal_name, concat(slip_no,' / ', stk.seq_no ), company_name, if(stk.bad_in_qty+stk.bad_out_qty = 0, '0', '1'),
+	io_prc, stk.in_qty, stk.out_qty, concat( io_date, '-', slip_no, '-', seq_no)
 from dbr_stock_io  as stk
-	inner join dbr_company as cmp on cmp.id = stk.company_id
-	inner join dbr_deal_type as deal on deal.id = stk.deal_type_id
 where io_date between _sdate and _edate and storage_id = _storage and stk.item_id = _target;
 
 -- compute line_bal
@@ -107,6 +87,7 @@ open _line_cur;
 		end if;
 
 		update dbt_list_type1 set d4 = _line_bal, d5 = _line_bad_bal  where t_id = _line_id;
+
 	end loop loop1;
 close _line_cur;
 

+ 1 - 2
function-in-db/triggers/item_before_delete.sql

@@ -3,7 +3,6 @@ DELIMITER //
 create trigger item_before_delete before delete on dbr_item
     for each row begin
         delete from dbr_item_thm where id = old.id;
-        delete from pro_item_revsum where id = old.id;
     end
 //
-DELIMITER ;
+DELIMITER ;

+ 6 - 0
table-controls/SimpleSelect.sql

@@ -0,0 +1,6 @@
+select
+	concat( "pt.post_code='", mx.post_code, "'") as value,
+    type_title as caption
+from
+	pro_post_type as mx
+where sort='400';

+ 2 - 21
table-controls/function-snipet.sql

@@ -17,24 +17,5 @@ WHERE table_schema = 'weberp_db';
 
 describe dbr_user_perm;
 
-delete from dbr_company where email = 'sales@dabory.com';
-delete from pro_member where email = 'sales@dabory.com';
-
-delete from dbr_company where email = 'admin@dabory.com';
-delete from pro_member where email = 'admin@dabory.com';
-
-delete from dbr_company where email = 'dev1@dabory.com';
-delete from pro_member where email = 'dev1@dabory.com';
-delete from dbr_company where email = 'dev2@dabory.com';
-delete from pro_member where email = 'dev2@dabory.com';
-
-delete from dbr_company where email = 'dev1.dabory@gmail.com';
-delete from pro_member where email = 'dev1.dabory@gmail.com';
-delete from dbr_company where email = 'dev2.dabory@gmail.com';
-delete from pro_member where email = 'dev2.dabory@gmail.com';
-
-delete from dbr_company where email = 'wngur6076@naver.com';
-delete from pro_member where email = 'wngur6076@naver.com';
-
-delete from dbr_company where email = 'kimhi65@naver.com';
-delete from pro_member where email = 'kimhi65@naver.com';
+delete from dbr_company where email = 'wngur6065@naver.com';
+delete from pro_member where email = 'wngur6065@naver.com';

+ 6 - 1
table-controls/setup-추가.sql

@@ -1 +1,6 @@
-INSERT INTO `dbr_setup` (`id`, `created_on`, `updated_on`, `setup_type`, `branch_id`, `setup_code`, `brand_code`, `lang_type`, `seq_no`, `setup_name`, `component`, `parameter`, `is_on_use`, `is_default`, `is_brand_select`, `setup_json`) VALUES (NULL, '1694742450', '1694742450', 'pro', '0', 'popup-slider', 'main', '', '0', '팝업슬라이더-메인페이지', 'popup-setup.form-a.popup-slider-form', '/popup/popup-setup/form-a/popup-slider', '1', '0', '0', '')
+[아래형태가 표준이다.]
+
+delete from dbr_setup where setup_code = 'shipping-notice';
+INSERT INTO `dbr_setup` (`id`, `created_on`, `updated_on`, `setup_type`, `branch_id`, `setup_code`, `brand_code`, `lang_type`, `seq_no`, `setup_name`, `component`, `parameter`, `is_on_use`, `is_default`, `is_brand_select`, `setup_json`, `ip`) VALUES (NULL, '1694742450', '1694742450', 'shop', '0', 'shipping-notice', 'stand-alone', '', '1', '배송/교환/반품안내-독립몰', 'popup-setup.form-b.shipping-notice-form', '/popup/popup-setup/form-a/shipping-notice', '1', '0', '0', '', '');
+
+INSERT INTO `dbr_setup` (`id`, `created_on`, `updated_on`, `setup_type`, `branch_id`, `setup_code`, `brand_code`, `lang_type`, `seq_no`, `setup_name`, `component`, `parameter`, `is_on_use`, `is_default`, `is_brand_select`, `setup_json`, `ip`) VALUES (NULL, '1694742450', '1694742450', 'shop', '0', 'shipping-notice', 'marketplace', '', '1', '배송/교환/반품안내-입접몰', 'popup-setup.form-b.shipping-notice-form', '/popup/popup-setup/form-a/shipping-notice', '1', '0', '0', '', '');

+ 2 - 8
table-controls/z-소트-뱃지-생성.sql

@@ -1,15 +1,9 @@
 
 [create sort_menu]
 truncate table dbr_sort_menu;
-INSERT INTO `dbr_sort_menu` (`id`, `created_on`, `updated_on`, `menu_code`, `sort_type`, `bgcolor_code`, `dash_page_url`, `component`, `parameter`, `icon`, `is_enabled`) VALUES
-(1, 1692935876, 1692935876, '100000', 'optical_pos', '00004d', '/dabory/erp', 'optical_pos', '', 'fas fa-glasses', '1'),
-(2, 1692935876, 1692935876, '200000', 'shop', '1a3300', '/dabory/erp', '', '', 'fas fa-shopping-cart', '1'),
-(3, 1692935876, 1692935876, '300000', 'homepage', '4d1a00', '/dabory/erp', '', '', 'fas fa-home', '1'),
-(4, 1692935876, 1692935876, '500000', 'groupware', '4d3300', '/dabory/erp', '', '', 'fas fa-layer-group', '1'),
-(5, 1692935876, 1692935876, '600000', 'erp', '260d0d', '/dabory/erp', '', '', 'fas fa-sitemap', '1'),
-(6, 1692935876, 1692935876, '700000', 'kkcrm', '1a2738', '/dabory/erp', '', '', 'fas fa-comment-dollar', '1'),
-(7, 1692935876, 1692935876, '700000', 'dbr_main', '263806', '/dabory/erp', '', '', 'fas fa-glasses', '1');
 
+REPLACE INTO `dbr_sort_menu` (`id`, `created_on`, `updated_on`, `menu_code`, `sort_type`, `bgcolor_code`, `dash_page_url`, `component`, `parameter`, `icon`, `is_enabled`, `mgt_type`) VALUES 
+(1001, '1699861794', '1699861794', '100000', 'myapp_shop', '034514', '/dabory/myapp', '', '', 'fas fa-shopping-cart', '1', 'member')
 
 [create item_badge]
 truncate table pro_item_badge;

+ 50 - 0
table-controls/ㅎㅎ-test.sql

@@ -0,0 +1,50 @@
+drop table if exists sch_ditem;
+CREATE TABLE `sch_ditem` (
+ `id` varchar(1) NOT NULL DEFAULT '' COMMENT '상품링크코드:유일코드',
+ `created_on` bigint(20) DEFAULT 0  COMMENT '작성일자',
+ `updated_on` bigint(11) NOT NULL DEFAULT 0 COMMENT '수정일자',
+ `brand_uid` varchar(64) NOT NULL DEFAULT 'no-brand' COMMENT '브랜드유일키',
+ `igroup_code` varchar(21) NOT NULL COMMENT '상품카테고리 코드',
+ `igroup_name` varchar(21) NOT NULL COMMENT '상품카테고리명',
+ `item_code` varchar(21) NOT NULL COMMENT '상품코드',
+ `item_name` varchar(82) NOT NULL COMMENT '상품명',
+ `count_unit` varchar(5) NOT NULL COMMENT '수량단위(EA등)',
+ `cargo_type` varchar(5) NOT NULL COMMENT '화물구분:택배,소포,등기',
+ `ship_type` varchar(5) NOT NULL COMMENT '배송구분:일반배송,오늘출발 등',
+ `location_type` char(1) NOT NULL DEFAULT '0' COMMENT '배송유형:0국내, 1해외',
+ `expose_edate` char(1) NOT NULL DEFAULT '0' COMMENT '노출시작일',
+ `expose_sdate` char(1) NOT NULL DEFAULT '0' COMMENT '노출 종료일',
+ `ship_fee_type` varchar(5) NOT NULL COMMENT '배송비구분:무료,고정비,조건별,수량별,구간별',
+ `is_ship_grouping` varchar(5) NOT NULL COMMENT '묶음배송 가능',
+ `ship_payment` varchar(5) NOT NULL COMMENT '배송비지불방식:0선불,1착불,2선택',
+ `ship_fee` decimal(18,4) NOT NULL COMMENT '무료,고정배송비경우 금액',
+ `fee_cond_amt` decimal(18,4) NOT NULL COMMENT '무료조건금액',
+ `list_prc` decimal(18,4) NOT NULL DEFAULT 0.0000 COMMENT '소매정가',
+ `sales_prc` decimal(18,4) DEFAULT 0.0000 COMMENT '판매가',
+ `curr_stk_qty` decimal(18,4) NOT NULL DEFAULT 999999.0000 COMMENT '현재고',
+ `cs_telno` varchar(5) NOT NULL COMMENT '서비스센터 전화번화',
+ `cs_desc` varchar(5) NOT NULL COMMENT '서비스센터 설명문',
+ `maker` varchar(5) NOT NULL COMMENT '제조사',
+ `short_desc` text NOT NULL DEFAULT '' COMMENT '짧은설명-html',
+ `item_desc` text DEFAULT NULL COMMENT '품목설명-html',
+ `model` varchar(5) NOT NULL COMMENT '모델명',
+ `mix_qty` decimal(18,4) DEFAULT 0.0000 COMMENT '구매최소량',
+ `max_qty` decimal(18,4) DEFAULT 0.0000 COMMENT '구매최대량',
+ `seo_keys` decimal(18,4) DEFAULT 0.0000 COMMENT '구매최대량',
+ `tax_type` varchar(5) NOT NULL COMMENT '과세,영세,면세',
+ `origin_code` varchar(5) NOT NULL COMMENT '원산지국가코드',
+ `status` char(1) NOT NULL DEFAULT '0' COMMENT '판매상태: 0판매중, 1품절, 2:단종, 3:중지',
+ `importer` varchar(5) NOT NULL COMMENT '수입사',
+ `is_adult_only` varchar(5) NOT NULL COMMENT '성인용품',
+ `opt1_caption` varchar(5) NOT NULL COMMENT '옵션명1',
+ `opt1_values` varchar(5) NOT NULL COMMENT '옵션값1',
+ `opt2_caption` varchar(5) NOT NULL COMMENT '옵션명2',
+ `opt2_values` varchar(5) NOT NULL COMMENT '옵션값2',
+ `opt3_caption` varchar(5) NOT NULL COMMENT '옵션명3',
+ `opt3_values` varchar(5) NOT NULL COMMENT '옵션값3',
+ `opt_prices` varchar(5) NOT NULL COMMENT '옵션별 추가금액',
+ `opt_stk_qtys` varchar(5) NOT NULL COMMENT '옵션별 재고수량',
+ `opt_statuses` varchar(5) NOT NULL COMMENT '옵션별 상태',
+ `opt_usables` varchar(5) NOT NULL COMMENT '옵션별 사용여부',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

+ 21 - 3
table-controls/테이블-DBUpdate-gen-wallet.sql

@@ -1,10 +1,10 @@
 SELECT * FROM `dbr_company` WHERE email like '%bseyewear1@gmail.com%'
 SELECT * FROM `pro_member` WHERE email like '%dabory%'
 
-delete FROM `pro_member` WHERE email like 'bseyewear@naver.com'
+delete FROM `dbr_company` WHERE email = 'hk0698@naver.com';
+delete FROM `pro_member` WHERE email = 'hk0698@naver.com';
 
-delete FROM `pro_member` WHERE email like 'vietdinh1912@gmail.com'
-delete FROM `users` WHERE email like 'Vietpv94@gmail.com'
+email = 'xxnt7765@naver.com';
 
 
 ALTER TABLE `dbr_user_menu` ADD `guest_app_id` INT(11) NOT NULL DEFAULT '0' AFTER `is_skipped`;
@@ -184,3 +184,21 @@ ALTER TABLE `dbr_sorder`
   ADD `ship_fee` decimal(20,4) DEFAULT 0.0000 COMMENT '배송비' AFTER `is_locked`,
   ADD `ship_method` varchar(32) DEFAULT NULL COMMENT '배송방식' AFTER `is_locked`,
   ADD `ship_contact` varchar(64) DEFAULT NULL COMMENT '연락처명' AFTER `is_locked`;
+
+
+drop table if exists pro_time_sales;
+CREATE TABLE `pro_time_sales` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `created_on` bigint(20) DEFAULT 0,
+ `updated_on` bigint(20) DEFAULT 0,
+ `time_sales_no` varchar(21) NOT NULL DEFAULT '' COMMENT '타임세일번호',
+ `sales_date` char(8) NOT NULL DEFAULT '' COMMENT '입력일자',
+ `item_id` int(10) unsigned NOT NULL COMMENT '품목ID',
+ `time_price` decimal(18,4) NOT NULL DEFAULT 0.0000 COMMENT '할인가격',
+ `start_on` bigint(20) NOT NULL DEFAULT 0 COMMENT '타임세일 시작일시',
+ `end_on` bigint(20) NOT NULL DEFAULT 0 COMMENT '타임세일 종료일시',
+ `status` char(1) NOT NULL COMMENT '표시않음',
+ `main_page_on` char(1) NOT NULL DEFAULT '0' COMMENT '메인노출',
+ `ip` varchar(20) NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

+ 17 - 14
table-controls/테이블필드확인.sql

@@ -1,14 +1,13 @@
-SELECT * FROM `dbr_company` WHERE email = 'opticlibre@naver.com';
-SELECT * FROM `pro_member` WHERE email = 'opticlibre@naver.com';
-SELECT * FROM `pro_member_ext` WHERE id = 168;
 
-delete FROM `pro_member` WHERE email = 'dev1.dabory@gmail.com';
-delete FROM `pro_member` WHERE email = 'dev1.dabory@gmail.com';
-delete FROM `pro_member_ext` WHERE id = 149;
+SELECT * FROM `dbr_company` WHERE email = 'baeksanoptical@naver.com';
+SELECT * FROM `pro_member` WHERE email = 'baeksanoptical@naver.com';
+SELECT * FROM `pro_member_ext` WHERE id = 363;
+
+SELECT * FROM `dbr_company` WHERE email = 'xxnt7765@naver.com';
+SELECT * FROM `pro_member` WHERE email = 'hk0698@naver.com';
+SELECT * FROM `pro_member_ext` WHERE id = 356;
+
 
-SELECT * FROM `dbr_company` WHERE email = 'dev1.dabory@gmail.com';
-SELECT * FROM `pro_member` WHERE email = 'dev1.dabory@gmail.com';
-SELECT * FROM `pro_member_ext` WHERE id = 149;
 
 ALTER TABLE `dbr_user_menu` ADD `guest_app_id` INT(11) NOT NULL DEFAULT '0' AFTER `is_skipped`;
 
@@ -16,15 +15,10 @@ ALTER TABLE `bcs_circulatiing`
   CHANGE `circulatiing_supply` `circulating_supply` DECIMAL (34, 0) DEFAULT 0 NOT NULL;
 
 RENAME TABLE `bcs_circulatiing` TO `bcs_circulating`;
-
-
 ALTER TABLE `dbr_porder_bd` 
   ADD `memo` TEXT NULL DEFAULT NULL AFTER `confirm_date`,
   ADD `column2` varchar(69) DEFAULT NULL AFTER `confirm_date`,
   ADD `column1` varchar(69) DEFAULT NULL AFTER `confirm_date`;
-
-
-
 delete FROM `dbr_setup` WHERE setup_code = 'office-info';
 INSERT INTO dbr_setup (branch_id, setup_code, brand_code, setup_name, component, parameter, is_on_use, is_brand_select, setup_json )
 VALUES (0, 'office-info', '', '사무실정보', 'popup-setup.form-a.office-info-form', '/popup-setup/form-a/office-info', '1', '0', '{\"OfcCode\":\"baeksan-optical\",\"OfcPlace\":\"2\",\"OfcName\":\"3\",\"OfcTaxNo\":\"4\",\"OfcEmail\":\"5\",\"OfcTelNo\":\"6\",\"OfcFaxNo\":\"7\",\"OfcMobile\":\"8\",\"OfcZipCode\":\"9\",\"OfcPresident\":\"10\",\"OfcAddress\":\"11\",\"OfcBizType\":\"12\",\"OfcDealItem\":\"13\"}');
@@ -32,6 +26,10 @@ VALUES (0, 'office-info', '', '사무실정보', 'popup-setup.form-a.office-info
 update dbr_setup set component = 'popup-setup.form-a.media-library-form' where setup_code='media-body'
 
 
+delete FROM `dbr_setup` WHERE setup_code = 'seo-html';
+INSERT INTO `dbr_setup` (`id`, `created_on`, `updated_on`, `setup_type`, `branch_id`, `setup_code`, `brand_code`, `lang_type`, `seq_no`, `setup_name`, `component`, `parameter`, `is_on_use`, `is_default`, `is_brand_select`, `setup_json`) VALUES (0, '1694742450', '1697622735', 'pro', '0', 'seo-html', 'common', '', '0', 'SEO-공통(전체페이지 사이트 검증)', 'popup-setup.form-a.seo-html-form', '/popup/popup-setup/form-a/seo-html', '1', '0', '0', '');
+INSERT INTO `dbr_setup` (`id`, `created_on`, `updated_on`, `setup_type`, `branch_id`, `setup_code`, `brand_code`, `lang_type`, `seq_no`, `setup_name`, `component`, `parameter`, `is_on_use`, `is_default`, `is_brand_select`, `setup_json`) VALUES (0, '1694742450', '1697622735', 'pro', '0', 'seo-html', 'main', '', '0', 'SEO-메인페이지', 'popup-setup.form-a.seo-html-form', '/popup/popup-setup/form-a/seo-html', '1', '0', '0', '');
+
 drop table if exists dbt_list_type1;
 CREATE TABLE `dbt_list_type1` (
  `t_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
@@ -569,3 +567,8 @@ INSERT INTO pro_item_revsum ( id, created_on, updated_on)
 SELECT id, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
 FROM dbr_item
 where 1;
+
+UPDATE `pro_member` SET created_on = 1652423581 WHERE created_on = 0 or (created_on is null and id <> 1);
+UPDATE `users` SET created_on = 1652423581 WHERE created_on = 0 or (created_on is null and id <> 1);
+UPDATE `pro_member` SET member_date = DATE_FORMAT(FROM_UNIXTIME(created_on), '%Y%m%d') WHERE 1;
+UPDATE `users` SET users_date = DATE_FORMAT(FROM_UNIXTIME(created_on), '%Y%m%d') WHERE 1;

+ 68 - 0
z-tmp-집계표.sql

@@ -0,0 +1,68 @@
+drop procedure if exists fnc_curr_item_bal;
+DELIMITER //
+create procedure fnc_curr_item_bal( _curr_date varchar(8), _storage int, _target int)
+
+BEGIN
+
+Declare _curr_bal decimal(20,4) default "0.0000";
+Declare _curr_bad decimal(20,4) default "0.0000";
+Declare _sum_stkio decimal(20,4) default "0.0000";
+Declare _sum_bad decimal(20,4) default "0.0000";
+
+Declare _bal_date varchar(8);
+
+if _is_first_date(_curr_date) then
+	set _bal_date = '19000101';
+else
+	set _bal_date = _curr_date;
+end if;
+
+
+select bal_qty, bad_bal_qty
+into _curr_bal, _curr_bad
+from dbr_bal_item
+where item_id = _target
+    and yyyy_mm = _prev_month(_curr_date) and storage_id = _storage;
+
+select sum(io_qty*stock_status), sum(io_qty*badstk_status)
+into _sum_stkio, _sum_bad
+from ( select item_id, io_qty, stock_status, badstk_status
+    from dbr_stock_io  as stk
+        inner join dbr_deal_type as deal on deal.id = stk.deal_type_id
+    where item_id = _target
+        and io_date between _first_date(_bal_date) and _bal_date
+        and storage_id = _storage
+    ) stkio
+group by stkio.item_id;
+
+select _curr_bal + _sum_stkio as c1, _curr_bad + _sum_bad as c2;
+
+END;
+//
+DELIMITER ;
+
+call fnc_curr_item_bal('20230228', 1, 1) ;
+
+
+
+
+
+
+
+ALTER TABLE `crm_account` CHANGE `account_name` `order_by` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '';
+ALTER TABLE `crm_account_item` CHANGE `item_name` `order_by` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '';
+
+
+select bal_amt
+from dbr_bal_reward
+where buyer_id = 10
+    and yyyy_mm = _prev_month('20230228') and branch_id = 1;
+
+
+select sum(reward_amt*reward_status)
+from dbr_reward_bd  as rwd
+    inner join dbr_deal_type as deal on deal.id = deal_type_id
+where buyer_id = 10
+    and avail_date between '20230201' and '20230228'
+    and branch_id = 1
+group by buyer_id;

+ 30 - 0
z-tmp.sql

@@ -0,0 +1,30 @@
+drop table if exists crm_kkcoupon;
+CREATE TABLE `crm_kkcoupon` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `created_on` bigint(20) NOT NULL DEFAULT 0 COMMENT '요청일시',
+ `updated_on` bigint(20) NOT NULL DEFAULT 0 COMMENT '마지막변경일시',
+ `coupon_on` bigint(20) NOT NULL DEFAULT 0 COMMENT '쿠폰발행일자',
+ `created_date` char(8) NOT NULL DEFAULT '' COMMENT '요청발생일자',
+ `coupon_date` char(8) NOT NULL DEFAULT '' COMMENT '쿠폰발행일자',
+ `coupon_no` varchar(21) NOT NULL DEFAULT '' COMMENT '쿠폰 일련번호',
+ `coupon_code` varchar(64) NOT NULL DEFAULT '' COMMENT '할인쿠폰코드',
+ `target_uri` varchar(1024) NOT NULL COMMENT '상품페이지URI',
+ `product_id` int(10) unsigned NOT NULL DEFAULT 1 COMMENT '상품id',
+ `init_dcrate` decimal(6,4) NOT NULL DEFAULT 0.0000 COMMENT '최초할인율',
+ `final_dcrate` decimal(6,4) NOT NULL DEFAULT 0.0000 COMMENT '최종할인율',
+ `buy_prc` decimal(20,4) NOT NULL DEFAULT 0.0000 COMMENT '구매가격',
+ `buy_qty` decimal(20,4) NOT NULL DEFAULT 0.0000 COMMENT '구매수량',
+ `buyer_member_id` int(10) unsigned NOT NULL DEFAULT 1 COMMENT '구매회원',
+ `seller_member_id` int(10) unsigned NOT NULL DEFAULT 1 COMMENT '판매회원',
+ `buyer_email` varchar(69) NOT NULL DEFAULT '' COMMENT '구매자이메일',
+ `seller_email` varchar(69) NOT NULL DEFAULT '' COMMENT '판매자이메일',
+ `sort` varchar(20) NOT NULL DEFAULT '' COMMENT '조건:블로그작성(0), 리뷰작성(1), 대량구매(2)',
+ `sort_desc` varchar(20) NOT NULL DEFAULT '' COMMENT '할인조건 직접입력',
+ `status` char(1) NOT NULL DEFAULT '' COMMENT '상황:요청(0),판매대응(1),구매재응(2),완료(3),판매거부(4),구매거부(5)',
+ `is_closed` char(1) NOT NULL DEFAULT '' COMMENT '종결처리',
+ `is_first_request` char(1) NOT NULL DEFAULT '' COMMENT '고객의 첫번째 요청여부',
+ `ip` varchar(20) NOT NULL DEFAULT '',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
+

+ 56 - 0
z-ㅎㅎㅎ.sql

@@ -0,0 +1,56 @@
+drop table if exists dbr_stock_io;
+CREATE TABLE `dbr_stock_io` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `created_on` bigint(20) DEFAULT 0,
+ `updated_on` bigint(20) DEFAULT 0,
+ `linked_md5` varchar(32) NOT NULL COMMENT '상위연결 md5(sales_bd등 실제트랜잭션)',
+ `storage_id` int(10) unsigned NOT NULL,
+ `item_id` int(10) unsigned NOT NULL DEFAULT 0,
+ `io_date` char(8) NOT NULL,
+ `sort_no` tinyint(4) NOT NULL DEFAULT 1 COMMENT 'deal_type에서 복사:매입-매출 역순으로 sort됨.로 되어야함)',
+ `slip_no` varchar(21) NOT NULL COMMENT '수불장 순서는 io_date, sort_no, slip_no, seq_no 순서로',
+ `seq_no` tinyint(4) NOT NULL,
+ `slip_bd_id` int(10) unsigned NOT NULL,
+ `linked_table` varchar(21) NOT NULL DEFAULT '' COMMENT 'sales-bd, purch-bd',
+ `in_qty` decimal(20,4) NOT NULL DEFAULT 0.0000 COMMENT '입고량',
+ `out_qty` decimal(20,4) NOT NULL DEFAULT 0.0000 COMMENT '출고량',
+ `io_prc` decimal(20,4) NOT NULL DEFAULT 0.0000,
+ `io_supply` decimal(20,4) NOT NULL DEFAULT 0.0000,
+ `io_vat` decimal(20,4) NOT NULL DEFAULT 0.0000,
+ `io_sum` decimal(20,4) NOT NULL DEFAULT 0.0000,
+ `bad_in_qty` decimal(20,4) NOT NULL DEFAULT 0.0000 COMMENT '불량입고',
+ `bad_out_qty` decimal(20,4) NOT NULL DEFAULT 0.0000 COMMENT '불량출고',
+ `deal_name` varchar(21) NOT NULL DEFAULT '' COMMENT '거래구분명[비정규화]',
+ `company_name` varchar(32) NOT NULL DEFAULT '' COMMENT '업체명[비정규화]',
+ `material_cost_prc` decimal(20,4) NOT NULL DEFAULT 0.0000,
+ `labor_cost_prc` decimal(20,4) DEFAULT 0.0000,
+ `expense_cost_prc` decimal(20,4) DEFAULT 0.0000,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `linked_md5` (`linked_md5`),
+ KEY `item_id` (`item_id`),
+ KEY `storage_id` (`storage_id`),
+ KEY `io_date` (`io_date`)
+) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+drop table if exists dbr_bal_item;
+CREATE TABLE `dbr_bal_item` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `created_on` bigint(20) DEFAULT 0,
+ `updated_on` bigint(20) DEFAULT 0,
+ `yyyy_mm` varchar(6) NOT NULL DEFAULT '' COMMENT '원장년월(총계:999999)',
+ `storage_id` int(10) unsigned NOT NULL DEFAULT 0,
+ `item_id` int(11) NOT NULL DEFAULT 1 COMMENT '품목ID',
+ `init_bal_qty` decimal(20,4) NOT NULL DEFAULT 0.0000 COMMENT '초기 재고',
+ `begin_bal_qty` decimal(20,4) NOT NULL DEFAULT 0.0000 COMMENT '이월재고',
+ `in_sum_qty` decimal(20,4) NOT NULL DEFAULT 0.0000 COMMENT '입고합계량',
+ `out_sum_qty` decimal(20,4) NOT NULL DEFAULT 0.0000 COMMENT '출고합계량',
+ `end_bal_qty` decimal(20,4) NOT NULL DEFAULT 0.0000 COMMENT '마감재고',
+ `bad_init_bal_qty` decimal(20,4) NOT NULL DEFAULT 0.0000 COMMENT '불량초기재고',
+ `bad_begin_bal_qty` decimal(20,4) NOT NULL DEFAULT 0.0000 COMMENT '불량이월재고',
+ `bad_in_sum_qty` decimal(20,4) NOT NULL DEFAULT 0.0000 COMMENT '불량입고합계량',
+ `bad_out_sum_qty` decimal(20,4) NOT NULL DEFAULT 0.0000 COMMENT '불량출고합계량',
+ `bad_end_bal_qty` decimal(20,4) NOT NULL DEFAULT 0.0000 COMMENT '불량마감재고',
+ `ip` varchar(21) NOT NULL DEFAULT '',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `month_storage_item` (`yyyy_mm`,`storage_id`,`item_id`),
+ KEY `item_id` (`item_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

+ 1 - 0
z-매입원장.sql

@@ -0,0 +1 @@
+

+ 165 - 0
z-매입집계표.sql

@@ -0,0 +1,165 @@
+-- 전월 재고 --
+-- 당월 수불 합계 --
+insert into dbt_list_sum
+	( created_on, list_token, h_id, id, c1, c2, c3,
+     d1, d2, d3,
+     d4, d5,
+     c4, c5, order_by )
+
+select unix_timestamp(), 'a', mx.id, mx.id, item_code, item_name, sub_name,
+     0, sum(io_qty*cast((stock_status+1)/2 as int)), sum(io_qty*cast(-1*(stock_status-1)/2 as int)),
+     0, sum(io_qty*badstk_status),
+   	igroup_name, igroup_code, item_code
+
+from ( select id, item_code, item_name, sub_name, igroup_id
+		from dbr_item as itm
+		where item_code between '!' and '駾'
+            and isnt_stkio = '0' and is_material = '0'
+	) as mx
+    inner join ( select item_id, io_qty, stock_status, badstk_status
+		from dbr_stock_io  as stk
+            inner join dbr_deal_type as deal on deal.id = stk.deal_type_id
+		where io_date between '20230201' and '20230231'
+			and storage_id = 1
+	) as stk on mx.id = stk.item_id
+
+    inner join ( select id, igroup_code, igroup_name
+		from dbr_igroup
+		where igroup_code between '!' and '駾'
+	) as igr on mx.igroup_id = igr.id
+group by stk.item_id
+order by item_code asc;
+
+-- dbt_list_type1 으로 집계 --
+insert into dbt_list_type1
+	( created_on, list_token, h_id, id, c1, c2, c3,
+		d1, d2, d3, d4, d5,
+		c4, c5, order_by)
+select min(unix_timestamp()), min('a'), min(id), min(id), min(c1), min(c2), min(c2),
+	sum(d1),
+	sum(d2),
+	sum(d3),
+    sum(d1) + sum(d2) - sum(d3),
+	sum(d5),
+	min(c4), min(c5), min(order_by)
+from dbt_list_sum as mx
+where list_token = 'a'
+group by mx.id
+having min(mx.id) is not null
+order by order_by asc;
+=======
+=======
+>>>>>>> 62bdebd054e19dd2c2ce53384ce4fe759d13dd29
+insert into dbt_list_type1
+	( created_on, list_token, h_id, id, c1, c2, c3,
+    d1, d2, d3, d4, d5,
+    c4, c5 )
+
+select unix_timestamp(), 'a', mx.id, mx.id, item_code, item_name, sub_name,
+    bal_qty, 0, 0, 0, 0,
+  	igroup_name, igroup_code
+<<<<<<< HEAD
+=======
+
+from ( select id, item_code, item_name, sub_name, igroup_id
+        from dbr_item as itm
+  	    where itm.item_code between '!' and '駾'
+        	and ( isnt_stkio = '0' or is_material = '0' )
+    ) as mx
+
+	inner join (
+        select item_id, bal_qty
+		from dbr_bal_item
+		where yyyy_mm = _prev_month('20230201') and storage_id = 1
+	) as last_mbal on last_mbal.item_id = mx.id
+
+	inner join (
+        select id, igroup_code, igroup_name from dbr_igroup as igr
+        where igr.igroup_code between '!' and '駾'
+    ) as igr on igr.id = mx.igroup_id
+
+order by item_code asc;
+
+-- 당월 수불합계 --
+insert into dbt_list_type1
+	( created_on, list_token, h_id, id, c1, c2, c3,
+    d1, d2, d3, d4, d5,
+    c4, c5 )
+
+select unix_timestamp(), 'a', mx.id, mx.id, item_code, item_name, sub_name,
+    0, sum(io_qty*cast((stock_status+1)/2 as int)), sum(io_qty*cast(-1*(stock_status-1)/2 as int)), 0,
+    sum(io_qty*badstk_status),
+  	igroup_name, igroup_code
+
+from ( select id, item_code, item_name, sub_name, igroup_id
+        from dbr_item as itm
+  	    where itm.item_code between '!' and '駾'
+        	and ( isnt_stkio = '0' or is_material = '0' )
+    ) as mx
+
+	inner join ( select item_id, deal_type_id, io_qty
+		from dbr_stock_io
+		where io_date between '20230201' and '20230231'
+        	and storage_id = 1
+    ) as stk on stk.item_id = mx.id
+
+	inner join ( select id, igroup_code, igroup_name from dbr_igroup as igr
+        where igr.igroup_code between '!' and '駾'
+    ) as igr on igr.id = mx.igroup_id
+
+    inner join dbr_deal_type as deal on deal.id = stk.deal_type_id
+
+order by item_code asc;
+>>>>>>> 62bdebd054e19dd2c2ce53384ce4fe759d13dd29
+
+from ( select id, item_code, item_name, sub_name, igroup_id
+        from dbr_item as itm
+  	    where itm.item_code between '!' and '駾'
+        	and ( isnt_stkio = '0' or is_material = '0' )
+    ) as mx
+
+	inner join (
+        select item_id, bal_qty
+		from dbr_bal_item
+		where yyyy_mm = _prev_month('20230201') and storage_id = 1
+	) as last_mbal on last_mbal.item_id = mx.id
+
+	inner join (
+        select id, igroup_code, igroup_name from dbr_igroup as igr
+        where igr.igroup_code between '!' and '駾'
+    ) as igr on igr.id = mx.igroup_id
+
+order by item_code asc;
+
+-- 당월 수불합계 --
+insert into dbt_list_type1
+	( created_on, list_token, h_id, id, c1, c2, c3,
+    d1, d2, d3, d4, d5,
+    c4, c5 )
+
+select unix_timestamp(), 'a', mx.id, mx.id, item_code, item_name, sub_name,
+    0, sum(io_qty*cast((stock_status+1)/2 as int)), sum(io_qty*cast(-1*(stock_status-1)/2 as int)), 0,
+    sum(io_qty*badstk_status),
+  	igroup_name, igroup_code
+
+from ( select id, item_code, item_name, sub_name, igroup_id
+        from dbr_item as itm
+  	    where itm.item_code between '!' and '駾'
+        	and ( isnt_stkio = '0' or is_material = '0' )
+    ) as mx
+
+	inner join ( select item_id, deal_type_id, io_qty
+		from dbr_stock_io
+		where io_date between '20230201' and '20230231'
+        	and storage_id = 1
+    ) as stk on stk.item_id = mx.id
+
+	inner join ( select id, igroup_code, igroup_name from dbr_igroup as igr
+        where igr.igroup_code between '!' and '駾'
+    ) as igr on igr.id = mx.igroup_id
+
+    inner join dbr_deal_type as deal on deal.id = stk.deal_type_id
+
+order by item_code asc;
+
+>>>>>>> a12a75b5e2b8584ff6dcd2fe635e566613dfec2c

+ 165 - 0
z-매출원장-.sql

@@ -0,0 +1,165 @@
+-- 전월 재고 --
+-- 당월 수불 합계 --
+insert into dbt_list_sum
+	( created_on, list_token, h_id, id, c1, c2, c3,
+     d1, d2, d3,
+     d4, d5,
+     c4, c5, order_by )
+
+select unix_timestamp(), 'a', mx.id, mx.id, item_code, item_name, sub_name,
+     0, sum(io_qty*cast((stock_status+1)/2 as int)), sum(io_qty*cast(-1*(stock_status-1)/2 as int)),
+     0, sum(io_qty*badstk_status),
+   	igroup_name, igroup_code, item_code
+
+from ( select id, item_code, item_name, sub_name, igroup_id
+		from dbr_item as itm
+		where item_code between '!' and '駾'
+            and isnt_stkio = '0' and is_material = '0'
+	) as mx
+    inner join ( select item_id, io_qty, stock_status, badstk_status
+		from dbr_stock_io  as stk
+            inner join dbr_deal_type as deal on deal.id = stk.deal_type_id
+		where io_date between '20230201' and '20230231'
+			and storage_id = 1
+	) as stk on mx.id = stk.item_id
+
+    inner join ( select id, igroup_code, igroup_name
+		from dbr_igroup
+		where igroup_code between '!' and '駾'
+	) as igr on mx.igroup_id = igr.id
+group by stk.item_id
+order by item_code asc;
+
+-- dbt_list_type1 으로 집계 --
+insert into dbt_list_type1
+	( created_on, list_token, h_id, id, c1, c2, c3,
+		d1, d2, d3, d4, d5,
+		c4, c5, order_by)
+select min(unix_timestamp()), min('a'), min(id), min(id), min(c1), min(c2), min(c2),
+	sum(d1),
+	sum(d2),
+	sum(d3),
+    sum(d1) + sum(d2) - sum(d3),
+	sum(d5),
+	min(c4), min(c5), min(order_by)
+from dbt_list_sum as mx
+where list_token = 'a'
+group by mx.id
+having min(mx.id) is not null
+order by order_by asc;
+=======
+=======
+>>>>>>> 62bdebd054e19dd2c2ce53384ce4fe759d13dd29
+insert into dbt_list_type1
+	( created_on, list_token, h_id, id, c1, c2, c3,
+    d1, d2, d3, d4, d5,
+    c4, c5 )
+
+select unix_timestamp(), 'a', mx.id, mx.id, item_code, item_name, sub_name,
+    bal_qty, 0, 0, 0, 0,
+  	igroup_name, igroup_code
+<<<<<<< HEAD
+=======
+
+from ( select id, item_code, item_name, sub_name, igroup_id
+        from dbr_item as itm
+  	    where itm.item_code between '!' and '駾'
+        	and ( isnt_stkio = '0' or is_material = '0' )
+    ) as mx
+
+	inner join (
+        select item_id, bal_qty
+		from dbr_bal_item
+		where yyyy_mm = _prev_month('20230201') and storage_id = 1
+	) as last_mbal on last_mbal.item_id = mx.id
+
+	inner join (
+        select id, igroup_code, igroup_name from dbr_igroup as igr
+        where igr.igroup_code between '!' and '駾'
+    ) as igr on igr.id = mx.igroup_id
+
+order by item_code asc;
+
+-- 당월 수불합계 --
+insert into dbt_list_type1
+	( created_on, list_token, h_id, id, c1, c2, c3,
+    d1, d2, d3, d4, d5,
+    c4, c5 )
+
+select unix_timestamp(), 'a', mx.id, mx.id, item_code, item_name, sub_name,
+    0, sum(io_qty*cast((stock_status+1)/2 as int)), sum(io_qty*cast(-1*(stock_status-1)/2 as int)), 0,
+    sum(io_qty*badstk_status),
+  	igroup_name, igroup_code
+
+from ( select id, item_code, item_name, sub_name, igroup_id
+        from dbr_item as itm
+  	    where itm.item_code between '!' and '駾'
+        	and ( isnt_stkio = '0' or is_material = '0' )
+    ) as mx
+
+	inner join ( select item_id, deal_type_id, io_qty
+		from dbr_stock_io
+		where io_date between '20230201' and '20230231'
+        	and storage_id = 1
+    ) as stk on stk.item_id = mx.id
+
+	inner join ( select id, igroup_code, igroup_name from dbr_igroup as igr
+        where igr.igroup_code between '!' and '駾'
+    ) as igr on igr.id = mx.igroup_id
+
+    inner join dbr_deal_type as deal on deal.id = stk.deal_type_id
+
+order by item_code asc;
+>>>>>>> 62bdebd054e19dd2c2ce53384ce4fe759d13dd29
+
+from ( select id, item_code, item_name, sub_name, igroup_id
+        from dbr_item as itm
+  	    where itm.item_code between '!' and '駾'
+        	and ( isnt_stkio = '0' or is_material = '0' )
+    ) as mx
+
+	inner join (
+        select item_id, bal_qty
+		from dbr_bal_item
+		where yyyy_mm = _prev_month('20230201') and storage_id = 1
+	) as last_mbal on last_mbal.item_id = mx.id
+
+	inner join (
+        select id, igroup_code, igroup_name from dbr_igroup as igr
+        where igr.igroup_code between '!' and '駾'
+    ) as igr on igr.id = mx.igroup_id
+
+order by item_code asc;
+
+-- 당월 수불합계 --
+insert into dbt_list_type1
+	( created_on, list_token, h_id, id, c1, c2, c3,
+    d1, d2, d3, d4, d5,
+    c4, c5 )
+
+select unix_timestamp(), 'a', mx.id, mx.id, item_code, item_name, sub_name,
+    0, sum(io_qty*cast((stock_status+1)/2 as int)), sum(io_qty*cast(-1*(stock_status-1)/2 as int)), 0,
+    sum(io_qty*badstk_status),
+  	igroup_name, igroup_code
+
+from ( select id, item_code, item_name, sub_name, igroup_id
+        from dbr_item as itm
+  	    where itm.item_code between '!' and '駾'
+        	and ( isnt_stkio = '0' or is_material = '0' )
+    ) as mx
+
+	inner join ( select item_id, deal_type_id, io_qty
+		from dbr_stock_io
+		where io_date between '20230201' and '20230231'
+        	and storage_id = 1
+    ) as stk on stk.item_id = mx.id
+
+	inner join ( select id, igroup_code, igroup_name from dbr_igroup as igr
+        where igr.igroup_code between '!' and '駾'
+    ) as igr on igr.id = mx.igroup_id
+
+    inner join dbr_deal_type as deal on deal.id = stk.deal_type_id
+
+order by item_code asc;
+
+>>>>>>> a12a75b5e2b8584ff6dcd2fe635e566613dfec2c

+ 1 - 0
z-소트메뉴생성-tmp.sql

@@ -0,0 +1 @@
+drop table if exists pro_domain;

+ 41 - 0
z-소트메뉴생성.sql

@@ -0,0 +1,41 @@
+
+[create sort_menu]
+truncate table dbr_sort_menu;
+REPLACE INTO `dbr_sort_menu` (`id`, `created_on`, `updated_on`, `menu_code`, `sort_type`, `bgcolor_code`, `dash_page_url`, `icon`, `is_enabled`)
+VALUES (1, '0', '0', '100000', 'kkcrm', '1a2738', '/dabory/erp', 'fas fa-comment-dollar', '1');
+
+REPLACE INTO `dbr_sort_menu` (`id`, `created_on`, `updated_on`, `menu_code`, `sort_type`, `bgcolor_code`, `dash_page_url`, `icon`, `is_enabled`)
+VALUES (2, '0', '0', '200000', 'shop', '1a3300', '/dabory/erp', 'fas fa-shopping-cart', '1');
+
+REPLACE INTO `dbr_sort_menu` (`id`, `created_on`, `updated_on`, `menu_code`, `sort_type`, `bgcolor_code`, `dash_page_url`, `icon`, `is_enabled`)
+VALUES (3, '0', '0', '300000', 'homepage', '4d1a00', '/dabory/erp', 'fas fa-home', '1');
+
+REPLACE INTO `dbr_sort_menu` (`id`, `created_on`, `updated_on`, `menu_code`, `sort_type`, `bgcolor_code`, `dash_page_url`, `icon`, `is_enabled`)
+VALUES (4, '0', '0', '400000', 'erp', '260d0d', '/dabory/erp', 'fas fa-sitemap', '1');
+
+REPLACE INTO `dbr_sort_menu` (`id`, `created_on`, `updated_on`, `menu_code`, `sort_type`, `bgcolor_code`, `dash_page_url`, `icon`, `is_enabled`)
+VALUES (5, '0', '0', '500000', 'groupware', '4d3300', '/dabory/erp', 'fas fa-layer-group', '1');
+
+REPLACE INTO `dbr_sort_menu` (`id`, `created_on`, `updated_on`, `menu_code`, `sort_type`, `bgcolor_code`, `dash_page_url`, `icon`, `is_enabled`)
+VALUES (6, '0', '0', '600000', 'optical_pos', '00004d', '/dabory/erp', 'fas fa-glasses', '1');
+
+REPLACE INTO `dbr_sort_menu` (`id`, `created_on`, `updated_on`, `menu_code`, `sort_type`, `bgcolor_code`, `dash_page_url`, `icon`, `is_enabled`)
+VALUES (7, '0', '0', '700000', 'dbr_main', '263806', '/dabory/erp', 'fas fa-glasses', '1');
+
+
+[create spd_struct]
+REPLACE INTO `spd_struct` (`id`, `created_on`, `updated_on`, `sort`, `struct_code`, `solution_code`, `seq_no`, `component`, `parameter`, `struct_json`, `status`) VALUES (1, '0', '0', '0', 'unknown', 'unknown', '1', '', '', NULL, '');
+REPLACE INTO `spd_struct` (`id`, `created_on`, `updated_on`, `sort`, `struct_code`, `solution_code`, `seq_no`, `component`, `parameter`, `struct_json`, `status`) VALUES (2, '0', '0', '0', 'woo-type', 'WooCommerce', '1', 'popup-struct.form-a.woo-type-form', '/popup-struct/form-a/woo-type', NULL, '');
+
+[create pro_member_perm]
+REPLACE INTO `pro_member_perm` (`id`, `created_on`, `updated_on`, `perm_no`, `perm_date`, `perm_name`, `perm_desc`) VALUES ('3', '1611569505', '1613191833',
+REPLACE INTO `dbr_sort_menu` (`id`, `created_on`, `updated_on`, `menu_code`, `sort_type`, `bgcolor_code`, `dash_page_url`, `icon`, `is_enabled`)
+VALUES (7, '0', '0', '700000', 'dabory_main', '263806', '/dabory/erp', 'fas fa-glasses', '1');
+
+
+[create item_badge]
+truncate table pro_item_badge;
+REPLACE INTO `pro_item_badge` (`id`, `created_on`, `updated_on`, `sort`, `badge_name`, `lang_type`, `device_type`, `badge_type`, `badge_image`, `x_pos`, `y_pos`, `is_hide`) VALUES (1, '0', '0', '1', '신제품', 'ko', 'desktop', '1', '', '3', '3', '0');
+REPLACE INTO `pro_item_badge` (`id`, `created_on`, `updated_on`, `sort`, `badge_name`, `lang_type`, `device_type`, `badge_type`, `badge_image`, `x_pos`, `y_pos`, `is_hide`) VALUES (2, '0', '0', '1', '10%할인', 'ko', 'desktop', '1', '', '3', '3', '0');
+REPLACE INTO `pro_item_badge` (`id`, `created_on`, `updated_on`, `sort`, `badge_name`, `lang_type`, `device_type`, `badge_type`, `badge_image`, `x_pos`, `y_pos`, `is_hide`) VALUES (3, '0', '0', '1', '경품할인', 'ko', 'desktop', '1', '', '3', '3', '0');
+REPLACE INTO `pro_item_badge` (`id`, `created_on`, `updated_on`, `sort`, `badge_name`, `lang_type`, `device_type`, `badge_type`, `badge_image`, `x_pos`, `y_pos`, `is_hide`) VALUES (4, '0', '0', '1', '타임세일', 'ko', 'desktop', '1', '', '3', '3', '0');

+ 7 - 0
z-적립금-settle.sql

@@ -0,0 +1,7 @@
+select 
+	sum(reward_amt*cast((reward_status+1)/2 as int)) as in_reward, 
+	sum(reward_amt*cast(-1*(reward_status-1)/2 as int)) as out_reward
+from dbr_reward_bd
+where 
+	and branch_id = ? and buyer_id = ?
+	and avail_date between  '20240307' and '20240307';