package com.ssj.service.task;

import java.util.Date;

import com.alibaba.fastjson.JSONObject;
import com.ssj.bean.sys.fx.domain.Merchant;
import com.ssj.bean.weixin.problem.domain.RequestMethodLog;
import com.ssj.framework.core.util.SystemResourceLocator;
import com.ssj.service.sys.fx.service.MerchantService;
import com.ssj.service.weixin.problem.service.RequestMethodLogService;
import com.ssj.taskthread.Task;

public class SyncRecordByMerchant extends Task {
			
		 private String id;
		 
		 private String loginName;
		
		 private String title;
		 
		 private String ip;
		 
		 public SyncRecordByMerchant(String loginName,String id,String ip,String title) {
		        super();
		        this.loginName=loginName;
		        this.id = id;
		        this.ip = ip;
		        this.title=title;
		 } 
		 
		 @Override
		 public void run() {
			 try {
				 String substance="";
				 MerchantService merchantService = SystemResourceLocator.getBean(MerchantService.class);
				 RequestMethodLogService requestMethodLogService = SystemResourceLocator.getBean(RequestMethodLogService.class);
				 Merchant merchant =merchantService.getById(id);
				 if(merchant!=null) {
					 substance=JSONObject.toJSONString(merchant);
				 }
				 RequestMethodLog log=new RequestMethodLog();
				 log.setAccountName(loginName);
				 log.setCreateTime(new Date());
				 log.setIpAddress(ip);
				 log.setMethodName("商户数据操作记录");
				 log.setMethodUrl(title);
				 log.setOrgCode(id);
				 log.setSubstance(substance);
				 requestMethodLogService.save(log);
			} catch (Exception e) {
				e.printStackTrace();
			}
		 }
	

}
