|
@@ -377,10 +377,22 @@ function M.set_album_link(msg_body)
|
|
|
return true, {}
|
|
|
end
|
|
|
|
|
|
+function M.modify_product_info(msg_body)
|
|
|
+ local isok ,key = tools.checkData({"id","list_time","words","author","fee_unit","default_price","default_pay_section","publish_time","status","product_parent_id",
|
|
|
+ "genre","is_store"},msg_body)
|
|
|
+ if not isok then
|
|
|
+ return false,string.format("缺少字段: %s.", key)
|
|
|
+ end
|
|
|
+ local sql ;
|
|
|
+ local isok,res;
|
|
|
+ sql = string.format("UPDATE `video_product` SET list_time = '%s' , words = '%s' , author = '%s' ,fee_unit = %d , default_price = %f , default_pay_section = %d , publish_time = '%s' , status = %d , product_parent_id = '%s' , genre = %d , is_store = %d WHERE id = %d ",msg_body.list_time,msg_body.words,msg_body.author,msg_body.fee_unit,msg_body.default_price,msg_body.default_pay_section,msg_body.publish_time,msg_body.status,msg_body.product_parent_id,msg_body.genre,msg_body.is_store,msg_body.id)
|
|
|
+ res = mysqldtaskbx.Singleton().query(sql)
|
|
|
+ return true,{}
|
|
|
+end
|
|
|
+
|
|
|
--同步匹配书籍
|
|
|
function M.sync_match_book_id(msg_body)
|
|
|
- -- ,"is_free"
|
|
|
- local isok ,key = tools.checkData({"match_book","product_id"},msg_body)
|
|
|
+ local isok ,key = tools.checkData({"match_book","product_id","is_free"},msg_body)
|
|
|
if not isok then
|
|
|
return false,string.format("缺少字段: %s.", key)
|
|
|
end
|
|
@@ -390,8 +402,22 @@ function M.sync_match_book_id(msg_body)
|
|
|
if #res<=0 then
|
|
|
return true,{status=0,msg="请先创建对应的匹配书籍:"..msg_body.match_book}
|
|
|
end
|
|
|
- sql = string.format("UPDATE video_product SET match_book = '%s' , product_parent_id = '%s' WHERE product_id = '%s' ",msg_body.match_book,msg_body.match_book,msg_body.product_id)
|
|
|
+ if msg_body.is_free == 1 then
|
|
|
+ sql = string.format("UPDATE video_product SET match_book = '%s' , product_parent_id = '%s' WHERE product_id = '%s' ",msg_body.match_book,msg_body.match_book,msg_body.product_id)
|
|
|
+ else
|
|
|
+ sql = string.format("UPDATE video_product SET match_book = '%s' WHERE product_id = '%s' ",msg_body.match_book,msg_body.product_id)
|
|
|
+ end
|
|
|
+
|
|
|
+ mysqldtaskbx.Singleton().query(sql)
|
|
|
+
|
|
|
+ --再查询匹配到的书籍,在进行匹配
|
|
|
+ if msg_body.is_free == 1 then
|
|
|
+ sql = string.format("UPDATE video_product SET match_book = '%s' WHERE product_id = '%s' ",msg_body.product_id,msg_body.match_book)
|
|
|
+ else
|
|
|
+ sql = string.format("UPDATE video_product SET match_book = '%s' , product_parent_id = '%s' WHERE product_id = '%s' ",msg_body.product_id,msg_body.product_id,msg_body.match_book)
|
|
|
+ end
|
|
|
mysqldtaskbx.Singleton().query(sql)
|
|
|
+
|
|
|
return true, {}
|
|
|
end
|
|
|
|