|
@@ -56,8 +56,43 @@ function M.addMain(msg_body)
|
|
|
pushAddMainMsg(msg_body)
|
|
|
return true
|
|
|
end
|
|
|
+--此主体将书库的书都发布到小程序书籍
|
|
|
+function M.syncMain(msg_body)
|
|
|
+ local isok ,key = tools.checkData({"id"},msg_body)
|
|
|
+ if not isok then
|
|
|
+ return false,string.format("缺少字段: %s.", key)
|
|
|
+ end
|
|
|
+ local sql = string.format("select * from `tg_main` where id = %d LIMIT 1 ",msg_body.id)
|
|
|
+ local res = mysqldbx.query(sql)
|
|
|
+ syncMainAppletProduct(res[1])
|
|
|
+ return true,{}
|
|
|
+end
|
|
|
+
|
|
|
+function syncMainAppletProduct(main_info)
|
|
|
+ local tg_platform_id = main_info.tg_platform_id
|
|
|
+ local app_id = main_info.app_id
|
|
|
+ local sql = string.format("SELECT * FROM video_product where book_platform = %d ",tg_platform_id)
|
|
|
+ local video_product_list = mysqldtaskbx.Singleton().query(sql)
|
|
|
|
|
|
|
|
|
+ function isHaveAppletProdut(product_id)
|
|
|
+ local s = string.format("SELECT * FROM video_applet_product where dy_small_applet_app_id = '%s' and product_id = '%s' and main_id = %d and book_platform = %d LIMIT 1",app_id,product_id,main_info.id,tg_platform_id)
|
|
|
+ local r = mysqldtaskbx.Singleton().query(sql)
|
|
|
+ return #r>0
|
|
|
+ end
|
|
|
+
|
|
|
+ local need_create_link_list = {}
|
|
|
+ local verify_list = {}
|
|
|
+ for i = 1, #video_product_list, 1 do
|
|
|
+ local product = video_product_list[i]
|
|
|
+ if not isHaveAppletProdut(product.product_id) and not verify_list[product.product_id] then
|
|
|
+ verify_list[product.product_id] = true
|
|
|
+ table.insert(need_create_link_list,#need_create_link_list+1,{product_name=product.product_name,product_id=product.product_id,book_platform=product.book_platform})
|
|
|
+ end
|
|
|
+ end
|
|
|
+ skynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="syncMain",data={list=need_create_link_list,main_info=main_info}}))
|
|
|
+end
|
|
|
+
|
|
|
function pushAddMainMsg(msg_body)
|
|
|
local sql = string.format("select * from `tg_main` where main_name = '%s' and app_id = '%s' LIMIT 1 ",msg_body.main_name,msg_body.app_id)
|
|
|
local isok,res;
|