package com.uas.account;

import java.util.Date;

//import org.junit.Test;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.uas.account.entity.User;
import com.uas.account.entity.UserDetail;
import com.uas.account.entity.UserSpace;
import com.uas.account.entity.UserSpaceDetail;
import com.uas.sso.common.util.HttpUtil;
import com.uas.sso.common.util.HttpUtil.ResponseWrap;

public class AccountTest {

	// @Test
	public void sendUserSpaceToB2B() throws Exception {
		String url = "http://127.0.0.1:8082/public/enterprise";
		UserSpace userSpace = new UserSpace();
		userSpace.setAppId("b2b");
		userSpace.setName("安徽文忠科技有限公司");
		userSpace.setUid("600898765678234");
		UserSpaceDetail userSpaceDetail = new UserSpaceDetail();
		userSpaceDetail.setAddress("安徽省安庆市太湖县沙河一路100号");
		userSpaceDetail.setAdminEmail("zhangs@usoftchina.com");
		userSpaceDetail.setAdminName("詹国胜");
		userSpaceDetail.setAdminTel("15914138464");
		userSpaceDetail.setArea("中国大陆");
		userSpaceDetail.setBusinessCode("600898765678234");
		userSpaceDetail.setCity("安庆市");
		userSpaceDetail.setBusinessCodeImage("http://dfs.ubtob.com/group1/M00/0E/EB/CgpkyFf4ZBqAVoxQAAAHlyS-C64856.jpg");
		userSpaceDetail.setDistrict("太湖县");
		userSpaceDetail.setIndustry("make");
		userSpaceDetail.setName("安徽文忠科技有限公司");
		userSpaceDetail.setProvince("安徽省");
		userSpaceDetail.setRegisterDate(new Date().getTime());
		userSpaceDetail.setShortName("文忠科技");
		userSpaceDetail.setStatus(313);
		userSpaceDetail.setStreet("沙河一路100号");
		JSONObject formData = JSON.parseObject(JSON.toJSONString(userSpace));
		formData.putAll(JSON.parseObject(JSON.toJSONString(userSpaceDetail)));
		ResponseWrap res = HttpUtil.doPost(url, formData);
		System.out.println(res.isSuccess());
		System.out.println(res.getContent());
	}

	// @Test
	public void sendUserSpaceToCenter() throws Exception {
		String url = "https://account.ubtob.com/api/userspace";
		UserSpace userSpace = new UserSpace();
		userSpace.setAppId("uas");
		userSpace.setName("深圳市英唐创泰科技有限公司");
		userSpace.setUid("2222222222");
		userSpace.setDialectUID("6414");
		UserSpaceDetail userSpaceDetail = new UserSpaceDetail();
		userSpaceDetail.setBusinessCode("2222222222");
		userSpaceDetail.setName("深圳市英唐创泰科技有限公司");
		userSpaceDetail.setShortName("英唐创泰");
		userSpaceDetail.setRegisterDate(new Date().getTime());
		userSpaceDetail.setAdminName("佘德鑫");
		userSpaceDetail.setAdminTel("13538142808");
		JSONObject formData = JSON.parseObject(JSON.toJSONString(userSpace));
		formData.putAll(JSON.parseObject(JSON.toJSONString(userSpaceDetail)));
		ResponseWrap res = HttpUtil.doPost(url, formData);
		System.out.println(res.isSuccess());
		System.out.println(res.getContent());
	}

	// @Test
	public void sendUserToB2B() throws Exception {
		// 用户账户信息
		User user = new User();
		user.setAppId("b2b");
		user.setName("张三");
		user.setUid("18787878787");
		user.setDialectUID("zhangsan");
		user.setPassword("666666");
		user.setSecondUID("18787878787@qq.com");
		user.setSpaceDialectUID("0000000000");
		// 用户个人资料
		UserDetail detail = new UserDetail();
		detail.setEmail("18787878787@qq.com");
		detail.setBirthday(new Date().getTime());
		detail.setIdCode("11111111111111111");
		detail.setMobile("18787878787");
		detail.setName("张三");
		detail.setSex("M");
		JSONObject formData = JSON.parseObject(JSON.toJSONString(detail));
		formData.putAll(JSON.parseObject(JSON.toJSONString(user)));
		ResponseWrap res = HttpUtil.doPost("http://127.0.0.1:8082/public/user", formData);
		System.out.println(res.isSuccess());
		System.out.println(res.getContent());
	}

	// @Test
	public void saveFromErp() throws Exception {
		// 用户账户信息
		User user = new User();
		user.setAppId("uas");
		user.setDialectUID("1111");
		user.setName("沈佳");
		user.setUid("13418872805");
		user.setPassword("111111");
		user.setSpaceDialectUID("6017");
		// 用户个人资料
		UserDetail detail = new UserDetail();
		detail.setBirthday(new Date().getTime());
		detail.setMobile("13418872805");
		detail.setName("沈佳");
		detail.setSex("M");
		JSONObject formData = JSON.parseObject(JSON.toJSONString(detail));
		formData.putAll(JSON.parseObject(JSON.toJSONString(user)));
		ResponseWrap res = HttpUtil.doPost("https://account.ubtob.com/api/user", formData);
		System.out.println(res.isSuccess());
		System.out.println(res.getContent());
	}

	// @Test
	public void sendUserToManage() throws Exception {
		// 用户账户信息
		User user = new User();
		user.setAppId("saas");
		user.setName("应鹏");
		user.setUid("13798490565");
		user.setPassword("111111");
		user.setSecondUID("yingp@usoftchina.com");
		user.setSpaceDialectUID("5937");
		// 用户个人资料
		UserDetail detail = new UserDetail();
		detail.setEmail("yingp@usoftchina.com");
		detail.setBirthday(new Date().getTime());
		detail.setIdCode("11111111111111111");
		detail.setMobile("13798490565");
		detail.setName("应鹏");
		detail.setSex("M");
		JSONObject formData = JSON.parseObject(JSON.toJSONString(detail));
		formData.putAll(JSON.parseObject(JSON.toJSONString(user)));
		ResponseWrap res = HttpUtil.doPost("http://localhost/public/user", formData);
		System.out.println(res.isSuccess());
		System.out.println(res.getContent());
	}

	// @Test
	public void sendUserToIM() throws Exception {
		// 用户账户信息
		User user = new User();
		user.setAppId("im");
		user.setName("应鹏");
		user.setUid("13798490565");
		user.setPassword("12345678");
		user.setSecondUID("yingp@usoftchina.com");
		user.setDialectUID("100129");
		// 用户个人资料
		UserDetail detail = new UserDetail();
		detail.setEmail("yingp@usoftchina.com");
		detail.setBirthday(new Date().getTime());
		detail.setIdCode("11111111111111111");
		detail.setMobile("13798490565");
		detail.setName("应鹏");
		detail.setSex("M");
		JSONObject formData = JSON.parseObject(JSON.toJSONString(detail));
		formData.putAll(JSON.parseObject(JSON.toJSONString(user)));
		ResponseWrap res = HttpUtil.doPost("http://113.105.74.140:8092/user/modify", formData);
		System.out.println(res.isSuccess());
		System.out.println(res.getContent());
	}

}
