barcode update
This commit is contained in:
@@ -140,14 +140,17 @@ class Api::BatchLineItemsController < ApplicationController
|
||||
# end
|
||||
# Generate Code
|
||||
end
|
||||
|
||||
def update_manufacture_uid
|
||||
account_no = params[:account_no]
|
||||
barcode = params[:barcode]
|
||||
manufacture_uid = params[:manufacture_uid]
|
||||
batch_line_item = BatchLineItem.find_by_asset_identity(account_no)
|
||||
if !batch_line_item.nil?
|
||||
batch_line_item.manufacture_uid = manufacture_uid
|
||||
batch_line_item.barcode = barcode
|
||||
batch_line_item.save
|
||||
|
||||
|
||||
# update batch
|
||||
batch = Batch.find_by_id(batch_line_item.batch_id)
|
||||
card_qty=batch.qty_processing.to_i
|
||||
@@ -172,6 +175,94 @@ class Api::BatchLineItemsController < ApplicationController
|
||||
else
|
||||
@out = false,"no batch"
|
||||
end
|
||||
end
|
||||
|
||||
def code_activate
|
||||
session_token = params[:session_token]
|
||||
barcode =params[:barcode]
|
||||
find_seller = Member.find_by_session_token(session_token)
|
||||
if !find_seller.nil?
|
||||
seller_id = find_seller.user_id
|
||||
find_barcode = BatchLineItem.find_by_barcode(barcode)
|
||||
if !find_barcode.nil?
|
||||
find_batch = Batch.find_by_id(find_barcode.batch_id)
|
||||
if find_batch.export_to_seller_id == seller_id
|
||||
if find_barcode.is_activated == false
|
||||
find_barcode.is_activated = true
|
||||
find_barcode.activated_date = DateTime.now
|
||||
find_barcode.save
|
||||
@out = true,"Success"
|
||||
else
|
||||
@out = false,"This is already activated!"
|
||||
end
|
||||
else
|
||||
@out = false,"Not Authorized Seller"
|
||||
end
|
||||
else
|
||||
@out = false,"Fail"
|
||||
end
|
||||
else
|
||||
@out = false, "Not Authorized"
|
||||
end
|
||||
end
|
||||
|
||||
# def check_ticket
|
||||
# session_token = params[:session_token]
|
||||
# barcode =params[:barcode]
|
||||
# find_seller = Member.find_by_session_token(session_token)
|
||||
# if !find_seller.nil?
|
||||
# seller_id = find_seller.user_id
|
||||
# find_barcode = BatchLineItem.find_by_barcode(barcode)
|
||||
# if !find_barcode.nil?
|
||||
# @out = true,"valid"
|
||||
# end
|
||||
# else
|
||||
# @out = false, "Not Authorized"
|
||||
# end
|
||||
# end
|
||||
|
||||
def activated_list
|
||||
session_token = params[:session_token]
|
||||
find_seller = Member.find_by_session_token(session_token)
|
||||
if !find_seller.nil?
|
||||
total_page_count= 0
|
||||
page_no = params[:page]
|
||||
if !page_no.nil? && page_no != ""
|
||||
offset = (page_no.to_i - 1 ) * 10
|
||||
else
|
||||
offset = 0
|
||||
end
|
||||
seller_id = find_seller.user_id
|
||||
get_list = BatchLineItem.select("batch_line_items.id,batch_line_items.barcode,batch_line_items.activated_date").joins("join batches on batches.id=batch_line_items.batch_id").where("batch_line_items.is_activated=? and batches.export_to_seller_id=?",true,seller_id).limit(10).offset(offset)
|
||||
|
||||
if get_list.count%10 > 0
|
||||
total_page_count = get_list.count/10 + 1
|
||||
else
|
||||
total_page_count = get_list.count/10
|
||||
end
|
||||
|
||||
if !get_list.nil?
|
||||
@out = true, get_list, total_page_count
|
||||
else
|
||||
@out = false, "No data"
|
||||
end
|
||||
else
|
||||
@out = false, "Not Authorized"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def seller_info
|
||||
session_token = params[:session_token]
|
||||
find_seller = Member.find_by_session_token(session_token)
|
||||
if !find_seller.nil?
|
||||
seller_id = find_seller.user_id
|
||||
total_export_qty = BatchLineItem.select("count(batch_line_items.id)as count").joins("join batches on batches.id=batch_line_items.batch_id").where("batches.export_to_seller_id=?",seller_id)
|
||||
total_activated_qty = BatchLineItem.select("count(batch_line_items.id)as count").joins("join batches on batches.id=batch_line_items.batch_id").where("batches.export_to_seller_id=? and batch_line_items.is_activated=?",seller_id,true)
|
||||
@out = true,total_export_qty[0]["count"],total_activated_qty[0]["count"]
|
||||
else
|
||||
@out = false,"Not Authorized"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user