|
@@ -371,30 +371,47 @@ function M.sync_match_book_id(msg_body)
|
|
|
if not isok then
|
|
|
return false,string.format("缺少字段: %s.", key)
|
|
|
end
|
|
|
- local sql = string.format("UPDATE video_product SET match_book = '%s' WHERE product_id = '%s' ",msg_body.match_book,msg_body.product_id)
|
|
|
+ local sql = ""
|
|
|
+ sql = string.format("SELECT id FROM video_product where product_id = '%s' LIMIT 1 ",msg_body.match_book)
|
|
|
+ local res = mysqldtaskbx.Singleton().query(sql)
|
|
|
+ if #res<=0 then
|
|
|
+ return true,{status=0,msg="请先创建对应的匹配书籍:"..msg_body.match_book}
|
|
|
+ end
|
|
|
+ sql = string.format("UPDATE video_product SET match_book = '%s' WHERE product_id = '%s' ",msg_body.match_book,msg_body.product_id)
|
|
|
mysqldtaskbx.Singleton().query(sql)
|
|
|
return true, {}
|
|
|
end
|
|
|
|
|
|
--添加书籍数据
|
|
|
function M.add_book_data(msg_body)
|
|
|
- local isok ,key = tools.checkData({"author","album_link","fee_unit","default_price","default_pay_section","publish_time","status","product_parent_id","tg_platform_id","product_id","product_name"
|
|
|
+ local isok ,key = tools.checkData({"words","author","fee_unit","default_price","default_pay_section","publish_time","status","product_parent_id","tg_platform_id","product_id","product_name"
|
|
|
,"genre","is_store"},msg_body)
|
|
|
if not isok then
|
|
|
return false,string.format("缺少字段: %s.", key)
|
|
|
end
|
|
|
+ local album_link = ""
|
|
|
+ if msg_body.album_link~=nil then
|
|
|
+ album_link = msg_body.album_link
|
|
|
+ end
|
|
|
+
|
|
|
+ local match_book = "NONE"
|
|
|
+ if msg_body.match_book~=nil then
|
|
|
+ match_book = msg_body.match_book
|
|
|
+ end
|
|
|
local sql ;
|
|
|
local isok,res;
|
|
|
- local sql = string.format("SELECT * FROM video_product where product_id = '%s' LIMIT 1 ",msg_body.product_id)
|
|
|
+ local sql = string.format("SELECT id FROM video_product where product_id = '%s' LIMIT 1 ",msg_body.product_id)
|
|
|
res = mysqldtaskbx.Singleton().query(sql)
|
|
|
|
|
|
if #res>0 then
|
|
|
return false,"书籍已存在!"
|
|
|
end
|
|
|
|
|
|
- sql = string.format("INSERT INTO `video_product` (author,album_link,fee_unit,default_price,default_pay_section,publish_time,status,product_parent_id,book_platform,product_id, product_name, genre,is_store,is_auto) VALUES ('%s','%s',%d,%f,%d,'%s',%d,'%s',%d,'%s','%s',%d,%d,0)",
|
|
|
+ sql = string.format("INSERT INTO `video_product` (match_book,words,author,album_link,fee_unit,default_price,default_pay_section,publish_time,status,product_parent_id,book_platform,product_id, product_name, genre,is_store,is_auto) VALUES ('%s','%s','%s','%s',%d,%f,%d,'%s',%d,'%s',%d,'%s','%s',%d,%d,0)",
|
|
|
+ match_book,
|
|
|
+ msg_body.words,
|
|
|
msg_body.author,
|
|
|
- msg_body.album_link,
|
|
|
+ album_link,
|
|
|
msg_body.fee_unit,
|
|
|
msg_body.default_price,
|
|
|
msg_body.default_pay_section,
|