add new file
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
class BatchLineItem < ApplicationRecord
|
||||
belongs_to :batch
|
||||
attr_accessor :wristband_token
|
||||
|
||||
def self.generate_account_no
|
||||
attr_accessor :secret_token
|
||||
|
||||
def self.generate_account_no
|
||||
super_merchant = "101"
|
||||
account_type='1'
|
||||
location='101'
|
||||
@@ -41,21 +41,20 @@ class BatchLineItem < ApplicationRecord
|
||||
|
||||
end
|
||||
end
|
||||
def self.to_csv(user_id)
|
||||
def self.to_csv(client_id)
|
||||
encrypt_key=""
|
||||
|
||||
find_user=User.find_by_id(user_id)
|
||||
if !find_user.nil?
|
||||
encrypt_key=find_user.secrect_key
|
||||
find_client=Client.find_by_id(client_id)
|
||||
if !find_client.nil?
|
||||
encrypt_key=find_client.secrect_key
|
||||
end
|
||||
attributes = %w{serial_no wristband_code batch_id manufacture_uid card_type wristband_token}
|
||||
attributes = %w{serial_no asset_identity batch_id manufacture_uid asset_type secret_token}
|
||||
CSV.generate(headers: true) do |csv|
|
||||
csv << attributes
|
||||
all.each do |encoder|
|
||||
str="manufacture_uid="+encoder.manufacture_uid.to_s+"&serial_no="+encoder.serial_no.to_s
|
||||
|
||||
encryptd_data=BatchLineItem.encrypted(str,encrypt_key)
|
||||
encoder.wristband_token=encryptd_data
|
||||
encoder.secret_token=encryptd_data
|
||||
|
||||
csv << attributes.map{ |attr| encoder.send(attr)}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user