From 81da61b828e29b7745e1382dfbbaeb685dc083ef Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 23 一月 2024 17:17:55 +0800
Subject: [PATCH] 抖音转链修改

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/BoutiqueAutoRuleAdminController.java | 1571 ++++++++++++++++++++++++++++-----------------------------
 1 files changed, 772 insertions(+), 799 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/BoutiqueAutoRuleAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/BoutiqueAutoRuleAdminController.java
index be66370..d750e78 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/BoutiqueAutoRuleAdminController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/BoutiqueAutoRuleAdminController.java
@@ -1,799 +1,772 @@
-package com.yeshi.fanli.controller.admin;
-
-import java.io.PrintWriter;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-
-import javax.annotation.Resource;
-
-import net.sf.json.JSONObject;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
-import com.yeshi.fanli.entity.bus.clazz.TaoBaoClass;
-import com.yeshi.fanli.entity.bus.lable.BoutiqueAutoRule;
-import com.yeshi.fanli.entity.taobao.TaobaoMeterial;
-import com.yeshi.fanli.exception.goods.quality.BoutiqueAutoRuleException;
-import com.yeshi.fanli.service.inter.goods.GoodsClassService;
-import com.yeshi.fanli.service.inter.goods.TaoBaoClassService;
-import com.yeshi.fanli.service.inter.lable.BoutiqueAutoRuleService;
-import com.yeshi.fanli.service.inter.taobao.TaobaoMeterialService;
-import com.yeshi.fanli.tag.PageEntity;
-import com.yeshi.fanli.util.Constant;
-import com.yeshi.fanli.util.StringUtil;
-import org.yeshi.utils.JsonUtil;
-
-@Controller
-@RequestMapping("admin/new/api/v1/autoRule")
-public class BoutiqueAutoRuleAdminController {
-
-	@Resource
-	private BoutiqueAutoRuleService boutiqueAutoRuleService;
-
-	@Resource
-	private TaobaoMeterialService taobaoMeterialService;
-	@Resource
-	private GoodsClassService goodsClassService;
-	
-	@Resource
-	private TaoBaoClassService taoBaoClassService;
-	
-	
-	
-	
-	/**
-	 * 鏂板鍏ュ簱瑙勫垯
-	 * 
-	 * @param callback
-	 * @param boutiqueAutoRule
-	 * @param out
-	 */
-	@RequestMapping(value = "saveAdd")
-	public void saveAdd(String callback, BoutiqueAutoRule boutiqueAutoRule, PrintWriter out) {
-		try {
-
-			// 楠岃瘉浼犻�掓暟鎹槸鍚︽纭�
-			boolean validationData = validationData(callback, boutiqueAutoRule, out);
-			// 楠岃瘉鏈�氳繃
-			if (!validationData) {
-				return;
-			}
-			
-			// 杞崲json
-			transformJsonString(boutiqueAutoRule);
-			
-			// cron鏃堕棿
-			String cronTime = boutiqueAutoRuleService.setCronTime(boutiqueAutoRule.getExecuteDay(),boutiqueAutoRule.getExecuteTime());
-			boutiqueAutoRule.setCronTime(cronTime);
-						
-			// 榛樿鐘舵�佷负鍚敤
-			boutiqueAutoRule.setState(1);
-			boutiqueAutoRule.setCreatetime(new Date());
-			boutiqueAutoRule.setUpdatetime(new Date());
-			
-			boutiqueAutoRuleService.insertSelective(boutiqueAutoRule);
-			
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛"));
-			
-		
-			// 楠岃瘉褰撳墠浠诲姟鏄惁绔嬪嵆鍚姩
-			boolean validateDate = boutiqueAutoRuleService.validateDate(boutiqueAutoRule);
-			if (validateDate) {
-				// 浠诲姟鍚姩
-				boutiqueAutoRuleService.setScheduler(boutiqueAutoRule, "add");
-			} 
-			
-
-		} catch (BoutiqueAutoRuleException e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇濆瓨澶辫触"));
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 鑾峰彇鍏ュ簱瑙勫垯-淇敼
-	 * 
-	 * @param callback
-	 * @param id
-	 * @param out
-	 */
-	@RequestMapping(value = "enterModify")
-	public void enterModify(String callback, Long id, PrintWriter out) {
-		try {
-			if (id == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇蜂紶閫掓纭弬鏁�"));
-				return;
-			}
-
-			BoutiqueAutoRule boutiqueAutoRule = boutiqueAutoRuleService.selectByPrimaryKey(id);
-			
-			if (boutiqueAutoRule == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ヨ鍒欏凡涓嶅瓨鍦�"));
-				return;
-			} 
-			
-			jsonTransformString(boutiqueAutoRule);
-			
-			
-			Integer source = boutiqueAutoRule.getSource();
-			if (source.equals(BoutiqueAutoRule.TB_OPTIONAL) || source == BoutiqueAutoRule.TB_OPTIONAL) {
-				String className = boutiqueAutoRule.getClassName();
-				GoodsClass rb = goodsClassService.getGoodsClass(Long.parseLong(className));
-				if (rb != null) {
-					boutiqueAutoRule.setClassNameChinese(rb.getName());
-				} 
-			}
-			
-			GsonBuilder gsonBuilder = new GsonBuilder();
-			gsonBuilder.serializeNulls();
-			Gson gson = gsonBuilder.setDateFormat("yyyy-MM-dd").create();
-
-			JSONObject data = new JSONObject();
-			data.put("autoRule", gson.toJson(boutiqueAutoRule));
-
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-
-		} catch (BoutiqueAutoRuleException e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鑾峰彇澶辫触"));
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 淇敼鍏ュ簱瑙勫垯
-	 * 
-	 * @param callback
-	 * @param boutiqueAutoRule
-	 * @param out
-	 */
-	@RequestMapping(value = "saveModify")
-	public void saveModify(String callback, BoutiqueAutoRule boutiqueAutoRule, PrintWriter out) {
-		try {
-			Long id = boutiqueAutoRule.getId();
-			if (id == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇蜂紶閫掓纭弬鏁�"));
-				return;
-			}
-
-			BoutiqueAutoRule crrent = boutiqueAutoRuleService.selectByPrimaryKey(id);
-			if (crrent == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ユ潯瑙勫垯宸蹭笉瀛樺湪"));
-				return;
-			}
-
-			// 楠岃瘉浼犻�掓暟鎹槸鍚︽纭�
-			boolean validationData = validationData(callback, boutiqueAutoRule, out);
-			// 楠岃瘉鏈�氳繃
-			if (!validationData) {
-				return;
-			}
-			
-			transformJsonString(boutiqueAutoRule);
-		
-			String cronTime = boutiqueAutoRuleService.setCronTime(boutiqueAutoRule.getExecuteDay(),boutiqueAutoRule.getExecuteTime());
-			// cron鏃堕棿
-			boutiqueAutoRule.setCronTime(cronTime);
-			
-			boutiqueAutoRule.setState(crrent.getState());
-			boutiqueAutoRule.setCreatetime(crrent.getCreatetime());
-			// 鏇存柊鏃堕棿
-			boutiqueAutoRule.setUpdatetime(new Date());
-			
-			boutiqueAutoRuleService.updateByPrimaryKey(boutiqueAutoRule);
-
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇敼鎴愬姛"));
-			
-			
-			// 楠岃瘉褰撳墠浠诲姟鏄惁闇�瑕佷慨鏀� 銆佺珛鍗虫墽琛�
-			Integer crrentState = crrent.getState();
-			
-			if (crrentState != null) {
-				if (crrentState.equals(1)){
-					boolean validateDate = boutiqueAutoRuleService.validateDate(boutiqueAutoRule);
-					if (validateDate) {
-						// 浠诲姟淇敼
-						boutiqueAutoRuleService.setScheduler(boutiqueAutoRule, "modify"); 	
-					} else {
-						boutiqueAutoRuleService.setScheduler(boutiqueAutoRule, "delete");
-					}
-				}
-					
-			}
-			
-			
-		} catch (BoutiqueAutoRuleException e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇敼澶辫触"));
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 淇敼瑙勫垯鐘舵��
-	 * 
-	 * @param callback
-	 * @param id
-	 * @param state
-	 *            鐘舵�侊細1鍚敤 0鍋滅敤
-	 * @param out
-	 */
-	@RequestMapping(value = "saveState")
-	public void saveState(String callback, Long id, Integer state, PrintWriter out) {
-		try {
-
-			if (id == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇蜂紶閫掓纭弬鏁�"));
-				return;
-			}
-
-			BoutiqueAutoRule crrent = boutiqueAutoRuleService.selectByPrimaryKey(id);
-			if (crrent == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ユ潯瑙勫垯宸蹭笉瀛樺湪"));
-				return;
-			}
-
-			if (state == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇敼鐘舵�佷负绌�"));
-				return;
-			}
-
-			crrent.setState(state);
-			crrent.setUpdatetime(new Date());
-
-			boutiqueAutoRuleService.updateByPrimaryKeySelective(crrent);
-
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇敼鎴愬姛"));
-			
-			boolean validateDate = boutiqueAutoRuleService.validateDate(crrent);
-			if (state.equals(1)) {
-				if (validateDate) {
-					boutiqueAutoRuleService.setScheduler(crrent, "add"); 	// 浠诲姟鍚姩
-				}
-			} else {
-				boutiqueAutoRuleService.setScheduler(crrent, "delete"); 	// 浠诲姟鍒犻櫎
-			}
-
-		} catch (BoutiqueAutoRuleException e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇敼澶辫触"));
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 鏌ヨ鍏ュ簱瑙勫垯
-	 * 
-	 * @param callback
-	 * @param pageIndex
-	 * @param pageSize
-	 * @param source
-	 *            鏉ユ簮
-	 * @param out
-	 */
-	@RequestMapping(value = "query")
-	public void query(String callback, Integer pageIndex, Integer pageSize, Integer source, 
-			String key, Integer state, Integer sort,  PrintWriter out) {
-
-		try {
-
-			if (pageIndex == null)
-				pageIndex = 1;
-
-			if (pageSize == null)
-				pageSize = Constant.PAGE_SIZE;
-
-			List<BoutiqueAutoRule> list = boutiqueAutoRuleService.query((pageIndex - 1) * pageSize, 
-					pageSize, source, key, state, sort);
-
-			if (list == null || list.size() == 0) {
-				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁")));
-				return;
-			}
-
-			for (BoutiqueAutoRule boutiqueAutoRule: list) {
-				jsonTransformString(boutiqueAutoRule);
-				
-				if (source.equals(BoutiqueAutoRule.TB_OPTIONAL) || source == BoutiqueAutoRule.TB_OPTIONAL) {
-					String className = boutiqueAutoRule.getClassName();
-					GoodsClass rb = goodsClassService.getGoodsClass(Long.parseLong(className));
-					if (rb != null) {
-						boutiqueAutoRule.setClassNameChinese(rb.getName());
-					} 
-				}
-			}
-			
-			
-			long count = boutiqueAutoRuleService.queryCount(source, key, state);
-
-			int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
-			PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
-
-			GsonBuilder gsonBuilder = new GsonBuilder();
-			gsonBuilder.serializeNulls();
-			Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
-
-			JSONObject data = new JSONObject();
-			data.put("pe", pe);
-			data.put("resultList", gson.toJson(list));
-
-			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
-
-		} catch (Exception e) {
-			e.printStackTrace();
-			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触")));
-		}
-	}
-	
-	
-	/**
-	 * 淇敼鍏ュ簱瑙勫垯
-	 * 
-	 * @param callback
-	 * @param boutiqueAutoRule
-	 * @param out
-	 */
-	@RequestMapping(value = "delete")
-	public void delete(String callback, Long id, PrintWriter out) {
-		try {
-			
-			if (id == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇蜂紶閫掓纭弬鏁�"));
-				return;
-			}
-			
-			BoutiqueAutoRule boutiqueAutoRule = boutiqueAutoRuleService.selectByPrimaryKey(id);
-			if (boutiqueAutoRule == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ヨ鍒欏凡琚垹闄�"));
-				return;
-			}
-			
-			// 浠诲姟鍒犻櫎
-			boutiqueAutoRuleService.setScheduler(boutiqueAutoRule, "delete");
-
-			boutiqueAutoRuleService.deleteByPrimaryKey(id);
-
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鍒犻櫎鎴愬姛"));
-			
-		} catch (BoutiqueAutoRuleException e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触"));
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 淇敼鍏ュ簱瑙勫垯
-	 * 
-	 * @param callback
-	 * @param boutiqueAutoRule
-	 * @param out
-	 */
-	@RequestMapping(value = "shutdownJobs")
-	public void shutdownJobs(String callback, PrintWriter out) {
-		
-		try {
-			
-			boutiqueAutoRuleService.shutdownJobs();
-			
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
-	
-	
-	/**
-	 * 灏嗘煡璇㈢瓫閫夋潯浠惰浆鎹负json
-	 * @param boutiqueAutoRule
-	 */
-	public void transformJsonString(BoutiqueAutoRule boutiqueAutoRule){
-	
-		
-		JSONObject data = new JSONObject();
-		
-		Integer source = boutiqueAutoRule.getSource();
-		if (source.equals(BoutiqueAutoRule.TB_OPTIONAL)) {
-			// 绫荤洰id
-			data.put("systemCid", boutiqueAutoRule.getClassName());
-		}
-		
-		
-		if (boutiqueAutoRule.getKey() != null){
-			// 鎼滅储鍏抽敭璇�
-			data.put("key", boutiqueAutoRule.getKey());
-		}
-		
-		if (boutiqueAutoRule.getTitle() != null){
-			// 鎼滅储鍏抽敭璇�
-			data.put("title", boutiqueAutoRule.getTitle());
-		}
-		
-		
-		if ( boutiqueAutoRule.getCateIds() != null){
-			// 瀹樻柟鎺ㄨ崘鍟嗗搧搴撴姇鏀綢D;娣樺疂绫荤洰id闆嗗悎
-			data.put("cateIds", boutiqueAutoRule.getCateIds()); 
-		}
-	
-		if ( boutiqueAutoRule.getStartTkRate() != null){
-			// 浣i噾鑼冨洿灏忓��
-			data.put("startTkRate", boutiqueAutoRule.getStartTkRate()); 
-		}
-		
-		if ( boutiqueAutoRule.getEndTkRate() != null){
-			// 浣i噾鑼冨洿澶у��
-			data.put("endTkRate", boutiqueAutoRule.getEndTkRate()); 
-		}
-		
-		if ( boutiqueAutoRule.getStartSales() != null){
-			// 閿�閲忓皬鍊�
-			data.put("startSales", boutiqueAutoRule.getStartSales()); 
-		}
-		
-		if ( boutiqueAutoRule.getEndSales() != null){
-			// 閿�閲忓ぇ鍊�
-			data.put("endSales", boutiqueAutoRule.getEndSales()); 
-		}
-		
-		
-		if ( boutiqueAutoRule.getStartZkPrice() != null){
-			// 鍦ㄥ敭浠疯寖鍥村皬鍊�
-			data.put("startZkPrice", boutiqueAutoRule.getStartZkPrice());
-		}
-		
-		if ( boutiqueAutoRule.getEndZkPrice() != null){
-			// 鍦ㄥ敭浠疯寖鍥村ぇ鍊�
-			data.put("endZkPrice", boutiqueAutoRule.getEndZkPrice()); 
-		}
-
-		
-		
-		if ( boutiqueAutoRule.getStartPrice() != null){
-			// 鍒稿悗浠疯寖鍥村皬鍊�
-			data.put("startPrice", boutiqueAutoRule.getStartPrice());
-		}
-		
-		if ( boutiqueAutoRule.getEndPrice() != null){
-			// 鍒稿悗浠疯寖鍥村ぇ鍊�
-			data.put("endPrice", boutiqueAutoRule.getEndPrice()); 
-		}
-
-		if ( boutiqueAutoRule.getIsTmall() != null){
-			// 鏄惁澶╃尗
-			data.put("isTmall", boutiqueAutoRule.getIsTmall()); 
-		}
-		
-		if ( boutiqueAutoRule.getHasCoupon() != null){
-			// 鏄惁鏈夊埜锛�1 鏈� 0 鏃�
-			data.put("hasCoupon", boutiqueAutoRule.getHasCoupon()); 
-		}
-		
-		if ( boutiqueAutoRule.getFreeShipment() != null){
-			// 鏄惁鍖呴偖锛�1 鏈� 0 鏃�
-			data.put("freeShipment", boutiqueAutoRule.getFreeShipment()); 
-		}
-		
-		if ( boutiqueAutoRule.getNeedPrepay() != null){
-			// 鏄惁娑堣垂淇濋殰锛�1鏈� 0 鏃�
-			data.put("needPrepay", boutiqueAutoRule.getNeedPrepay()); 
-		}
-		
-		if (boutiqueAutoRule.getNpxLevel() != null){
-			// 鐗涚毊鐧g▼搴︼紝鍙栧�硷細1:涓嶉檺锛�2:鏃狅紝3:杞诲井
-			data.put("npxLevel", boutiqueAutoRule.getNpxLevel()); 
-		}
-
-		if ( boutiqueAutoRule.getIncludePayRate30() != null){
-			// 鎴愪氦杞寲鏄惁楂樹簬琛屼笟鍧囧��        1 鏈� 0 鏃�
-			data.put("includePayRate30", boutiqueAutoRule.getIncludePayRate30()); 
-		}
-		
-		if ( boutiqueAutoRule.getIncludeGoodRate() != null){
-			// 濂借瘎鐜囨槸鍚﹂珮浜庤涓氬潎鍊�            1 鏈� 0 鏃�
-			data.put("includeGoodRate", boutiqueAutoRule.getIncludeGoodRate()); 
-		}
-		
-		if ( boutiqueAutoRule.getIncludeRfdRate() != null){
-			// 閫�娆剧巼鏄惁浣庝簬琛屼笟鍧囧��             1 鏈� 0 鏃�
-			data.put("includeRfdRate", boutiqueAutoRule.getIncludeRfdRate()); 
-		}
-		
-		if ( boutiqueAutoRule.getLableNames() != null){
-			data.put("lableNames", boutiqueAutoRule.getLableNames()); 
-		}
-		
-		// 璇锋眰鏈�澶ч〉鐮�
-		if (boutiqueAutoRule.getMaxPage() != null){
-			data.put("maxPage", boutiqueAutoRule.getMaxPage()); 
-		}
-		
-		// 璇锋眰鏈�澶ч〉鐮�
-		if (boutiqueAutoRule.getClassName() != null){
-			
-			if (source.equals(BoutiqueAutoRule.TB_OPTIONAL) || source== BoutiqueAutoRule.TB_OPTIONAL) {
-				
-				String classId = boutiqueAutoRule.getClassName();
-				if (!StringUtil.isNullOrEmpty(classId)){
-					GoodsClass rb = goodsClassService.getGoodsClass(Long.parseLong(classId));
-					if (rb != null) {
-						data.put("sourceCalss", rb.getName()); 
-					} 
-				}
-				
-			}  else if (source.equals(BoutiqueAutoRule.TB_MATERIAL) || source == BoutiqueAutoRule.TB_MATERIAL) {
-				String subName = boutiqueAutoRule.getSubclassName();
-				String superName = boutiqueAutoRule.getClassName();
-				if (StringUtil.isNullOrEmpty(subName)) {
-					data.put("sourceCalss", superName); 
-				} else {
-					data.put("sourceCalss", superName +" "+ subName); 
-				}
-			}
-		}
-		
-		boutiqueAutoRule.setSearchContent(data.toString());
-		
-	}
-	
-	
-	/**
-	 * json 杞崲鏈猄tring
-	 * @param boutiqueAutoRule
-	 */
-	public void jsonTransformString(BoutiqueAutoRule boutiqueAutoRule){
-	
-		String searchContent = boutiqueAutoRule.getSearchContent();
-		if (StringUtil.isNullOrEmpty(searchContent)) {
-			return;
-		}
-		
-		JSONObject jsonData = JSONObject.fromObject(searchContent);
-		
-		if (jsonData.get("key") != null){
-			// 鎼滅储鍏抽敭璇�
-			boutiqueAutoRule.setKey(jsonData.get("key").toString());
-		}
-		
-		if (jsonData.get("cateIds") != null){
-			// 瀹樻柟鎺ㄨ崘鍟嗗搧搴撴姇鏀綢D;娣樺疂绫荤洰id闆嗗悎
-			boutiqueAutoRule.setCateIds(jsonData.get("cateIds").toString());
-		}
-	
-		if (jsonData.get("startTkRate") != null){
-			// 浣i噾鑼冨洿灏忓�糄ouble.valueOf(itoString());
-			boutiqueAutoRule.setStartTkRate(Double.valueOf(jsonData.get("startTkRate").toString()));
-		}
-		
-		if (jsonData.get("endTkRate") != null){
-			// 浣i噾鑼冨洿澶у��
-			 boutiqueAutoRule.setEndTkRate(Double.valueOf(jsonData.get("endTkRate").toString())); 
-		}
-		
-		if (jsonData.get("startSales") != null){
-			// 閿�閲忓皬鍊�
-			 boutiqueAutoRule.setStartSales((int)jsonData.get("startSales")); 
-		}
-		
-		if (jsonData.get("endSales") != null){
-			// 閿�閲忓ぇ鍊�
-			boutiqueAutoRule.setEndSales((int)jsonData.get("endSales")); 
-		}
-		
-		if (jsonData.get("startZkPrice") != null){
-			// 鍦ㄥ敭浠疯寖鍥村皬鍊�
-			boutiqueAutoRule.setStartZkPrice(Double.valueOf(jsonData.get("startZkPrice").toString()));
-		}
-		
-		if (jsonData.get("endZkPrice") != null){
-			// 鍦ㄥ敭浠疯寖鍥村ぇ鍊�
-			boutiqueAutoRule.setEndZkPrice(Double.valueOf(jsonData.get("endZkPrice").toString())); 
-		}
-		
-		if (jsonData.get("startPrice") != null){
-			// 鍒稿悗浠疯寖鍥村皬鍊�
-			boutiqueAutoRule.setStartPrice(Double.valueOf(jsonData.get("startPrice").toString()));
-		}
-		
-		if (jsonData.get("endPrice") != null){
-			// 鍒稿悗浠疯寖鍥村ぇ鍊�
-			boutiqueAutoRule.setEndPrice(Double.valueOf(jsonData.get("endPrice").toString())); 
-		}
-
-		if (jsonData.get("isTmall") != null){
-			// 鏄惁澶╃尗
-			boutiqueAutoRule.setIsTmall((int)jsonData.get("isTmall")); 
-		}
-		
-		if (jsonData.get("hasCoupon") != null){
-			// 鏄惁鏈夊埜锛�1 鏈� 0 鏃�
-			boutiqueAutoRule.setHasCoupon((int)jsonData.get("hasCoupon")); 
-		}
-		
-		if (jsonData.get("freeShipment") != null){
-			// 鏄惁鍖呴偖锛�1 鏈� 0 鏃�
-			boutiqueAutoRule.setFreeShipment((int)jsonData.get("freeShipment")); 
-		}
-		
-		if (jsonData.get("needPrepay") != null){
-			// 鏄惁娑堣垂淇濋殰锛�1鏈� 0 鏃�
-			boutiqueAutoRule.setNeedPrepay((int)jsonData.get("needPrepay")); 
-		}
-		
-		if (jsonData.get("npxLevel") != null){
-			// 鐗涚毊鐧g▼搴︼紝鍙栧�硷細1:涓嶉檺锛�2:鏃狅紝3:杞诲井
-			boutiqueAutoRule.setNpxLevel((int)jsonData.get("npxLevel")); 
-		}
-
-		if (jsonData.get("includePayRate30") != null){
-			// 鎴愪氦杞寲鏄惁楂樹簬琛屼笟鍧囧��        1 鏈� 0 鏃�
-			boutiqueAutoRule.setIncludePayRate30((int)jsonData.get("includePayRate30")); 
-		}
-		
-		if (jsonData.get("includeGoodRate") != null){
-			// 濂借瘎鐜囨槸鍚﹂珮浜庤涓氬潎鍊�            1 鏈� 0 鏃�
-			boutiqueAutoRule.setIncludeGoodRate((int)jsonData.get("includeGoodRate")); 
-		}
-		
-		if (jsonData.get("includeRfdRate") != null){
-			// 閫�娆剧巼鏄惁浣庝簬琛屼笟鍧囧��             1 鏈� 0 鏃�
-			boutiqueAutoRule.setIncludeRfdRate((int)jsonData.get("includeRfdRate")); 
-		}
-		
-		if (jsonData.get("lableNames") != null){
-			boutiqueAutoRule.setLableNames(jsonData.get("lableNames").toString()); 
-		}
-		
-		if (jsonData.get("maxPage") != null){
-			// 鏄惁鍖呴偖锛�1 鏈� 0 鏃�
-			boutiqueAutoRule.setMaxPage((int)jsonData.get("maxPage")); 
-		}
-		
-	}
-	
-	/**
-	 * 楠岃瘉鍓嶇灞曠ず鏁版嵁鏄惁绗﹀悎瑙勮寖
-	 * @param callback
-	 * @param boutiqueAutoRule
-	 * @param out
-	 * @return
-	 */
-	public boolean validationData(String callback, BoutiqueAutoRule boutiqueAutoRule, PrintWriter out){
-		
-		Integer source = boutiqueAutoRule.getSource();
-		if (source == null) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏉ユ簮涓嶈兘涓虹┖"));
-			return false;
-		}
-		
-		Integer maxPage = boutiqueAutoRule.getMaxPage();
-		if (maxPage == null) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇锋眰鏈�澶ч〉鏁颁笉鑳界┖"));
-			return false;
-		}
-		
-		
-		if (source.equals(BoutiqueAutoRule.TB_OPTIONAL) || source== BoutiqueAutoRule.TB_OPTIONAL) {
-			
-			/* 娣樺疂瀵艰喘鐗╂枡API 鏁版嵁楠岃瘉 */
-			
-			String key = boutiqueAutoRule.getKey();
-			String classId = boutiqueAutoRule.getClassName();
-		
-			if (StringUtil.isNullOrEmpty(key) && StringUtil.isNullOrEmpty(classId)) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绫诲瀷涓庡叧閿瘝涓嶈兘鍚屾椂涓虹┖"));
-				return false;
-			}
-			
-			
-			if (!StringUtil.isNullOrEmpty(classId)){
-				
-				GoodsClass rb = goodsClassService.getGoodsClass(Long.parseLong(classId));
-				if (rb == null) {
-					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ョ被鍨嬪凡涓嶅瓨鍦�,璇峰埛鏂伴噸璇�"));
-					return false;
-				} 
-				
-				
-				List<TaoBaoClass> listCatIds = taoBaoClassService.listBySystemCid(0, 10, Long.parseLong(classId));
-				if (listCatIds == null || listCatIds.size() == 0) {
-					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(rb.getName() + "瀵瑰簲娣樺疂id涓虹┖锛岃閫氱煡鐩稿叧浜哄憳杩涜缁存姢"));
-					return false;
-				}
-				
-				String taobaoCatIds = "";
-				for (TaoBaoClass taoBaoClass: listCatIds) {
-					   Integer categoryId = taoBaoClass.getCategoryId();
-					  
-					  if (categoryId == null ) {
-						  continue;
-					  }
-					  
-					  taobaoCatIds += categoryId + ",";
-				}
-				
-				if (StringUtil.isNullOrEmpty(taobaoCatIds)){
-					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(rb.getName() + "瀵瑰簲娣樺疂id涓虹┖锛岃閫氱煡鐩稿叧浜哄憳杩涜缁存姢"));
-					return false;
-				} 
-				
-				boutiqueAutoRule.setCateIds(taobaoCatIds.substring(0, taobaoCatIds.length()-1));
-			}
-			
-		}  else if (source.equals(BoutiqueAutoRule.TB_MATERIAL) || source == BoutiqueAutoRule.TB_MATERIAL) {
-			
-			/* 娣樺疂瀹樻柟鎺ㄨ崘   鏁版嵁楠岃瘉  */
-			
-			String subName = boutiqueAutoRule.getSubclassName();
-			String superName = boutiqueAutoRule.getClassName();
-			
-			if (StringUtil.isNullOrEmpty(subName) && StringUtil.isNullOrEmpty(superName) ) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨姝g‘鐨勭被鐩�"));
-				return false;
-			} 
-			
-			List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperName(subName, superName);
-
-			if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ョ被鐩俊鎭笉瀛樺湪"));
-				return false;
-			} else if (taobaoMeterials.size() > 1) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鐩稿簲鐨勫瓙绫�"));
-				return false;
-			}
-			
-			TaobaoMeterial taobaoMeterial = taobaoMeterials.get(0);
-			Integer materialId = taobaoMeterial.getMaterialId();
-			
-			if (materialId == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ョ被鐩墿鏂橧D涓嶅瓨鍦�"));
-				return false;
-			}
-			
-			boutiqueAutoRule.setCateIds(materialId + "");
-		} else {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇蜂紶閫掓纭潵婧�"));
-			return false;
-		}
-		
-		
-		// 鐢熸晥鏃堕棿
-		Date startTime = boutiqueAutoRule.getStartTime();
-		
-		// 澶辨晥鏃堕棿
-		Date endTime = boutiqueAutoRule.getEndTime();
-		
-		if (endTime != null) {
-			
-			if (startTime != null && startTime.getTime() > endTime.getTime()){
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢熸晥鏃堕棿涓嶈兘澶т簬澶辨晥鏃堕棿"));
-				return false;
-			}
-			
-			Calendar calendar = Calendar.getInstance();
-			calendar.setTime(endTime);
-			calendar.set(Calendar.HOUR, 23);
-			calendar.set(Calendar.MINUTE, 59);
-			calendar.set(Calendar.SECOND, 59);
-			
-			boutiqueAutoRule.setEndTime(calendar.getTime());
-		}
-		
-		if (startTime == null) {
-			 boutiqueAutoRule.setStartTime(new Date());
-		}
-		
-		
-		return true;
-	}
-	
-	
-	public static void main(String[] args) {
-		String s = "abacada";
-		if (s.contains("a")) {
-			System.out.println(1);
-		} else {
-			System.out.println(0);
-		}
-	}
-	
-}
+package com.yeshi.fanli.controller.admin;
+
+import java.io.PrintWriter;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import com.yeshi.fanli.entity.accept.AdminAcceptData;
+import net.sf.json.JSONObject;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
+import com.yeshi.fanli.entity.bus.clazz.TaoBaoClass;
+import com.yeshi.fanli.entity.bus.lable.BoutiqueAutoRule;
+import com.yeshi.fanli.entity.taobao.TaobaoMeterial;
+import com.yeshi.fanli.exception.goods.quality.BoutiqueAutoRuleException;
+import com.yeshi.fanli.service.inter.goods.GoodsClassService;
+import com.yeshi.fanli.service.inter.goods.TaoBaoClassService;
+import com.yeshi.fanli.service.inter.lable.BoutiqueAutoRuleService;
+import com.yeshi.fanli.service.inter.taobao.TaobaoMeterialService;
+import com.yeshi.common.entity.PageEntity;
+import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.StringUtil;
+import org.yeshi.utils.JsonUtil;
+
+@Controller
+@RequestMapping("admin/new/api/v1/autoRule")
+public class BoutiqueAutoRuleAdminController {
+
+	@Resource
+	private BoutiqueAutoRuleService boutiqueAutoRuleService;
+
+	@Resource
+	private TaobaoMeterialService taobaoMeterialService;
+	@Resource
+	private GoodsClassService goodsClassService;
+	
+	@Resource
+	private TaoBaoClassService taoBaoClassService;
+	
+	
+	
+	
+	/**
+	 * 鏂板鍏ュ簱瑙勫垯
+	 * 
+	 * @param callback
+	 * @param boutiqueAutoRule
+	 * @param out
+	 */
+	@RequestMapping(value = "saveAdd")
+	public void saveAdd(AdminAcceptData acceptData, String callback, BoutiqueAutoRule boutiqueAutoRule, PrintWriter out) {
+		try {
+
+			// 楠岃瘉浼犻�掓暟鎹槸鍚︽纭�
+			boolean validationData = validationData(callback, boutiqueAutoRule, out);
+			// 楠岃瘉鏈�氳繃
+			if (!validationData) {
+				return;
+			}
+			
+			// 杞崲json
+			transformJsonString(boutiqueAutoRule);
+			
+			// cron鏃堕棿
+			String cronTime = boutiqueAutoRuleService.setCronTime(boutiqueAutoRule.getExecuteDay(),boutiqueAutoRule.getExecuteTime());
+			boutiqueAutoRule.setCronTime(cronTime);
+						
+			// 榛樿鐘舵�佷负鍚敤
+			boutiqueAutoRule.setState(1);
+			boutiqueAutoRule.setCreatetime(new Date());
+			boutiqueAutoRule.setUpdatetime(new Date());
+			
+			boutiqueAutoRuleService.insertSelective(boutiqueAutoRule);
+			
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇濆瓨鎴愬姛"));
+			
+		
+			// 楠岃瘉褰撳墠浠诲姟鏄惁绔嬪嵆鍚姩
+			boolean validateDate = boutiqueAutoRuleService.validateDate(boutiqueAutoRule);
+			if (validateDate) {
+				// 浠诲姟鍚姩
+				boutiqueAutoRuleService.setScheduler(boutiqueAutoRule, "add");
+			} 
+			
+
+		} catch (BoutiqueAutoRuleException e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇濆瓨澶辫触"));
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 鑾峰彇鍏ュ簱瑙勫垯-淇敼
+	 * 
+	 * @param callback
+	 * @param id
+	 * @param out
+	 */
+	@RequestMapping(value = "enterModify")
+	public void enterModify(AdminAcceptData acceptData,String callback, Long id, PrintWriter out) {
+		try {
+			if (id == null) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇蜂紶閫掓纭弬鏁�"));
+				return;
+			}
+
+			BoutiqueAutoRule boutiqueAutoRule = boutiqueAutoRuleService.selectByPrimaryKey(id);
+			
+			if (boutiqueAutoRule == null) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ヨ鍒欏凡涓嶅瓨鍦�"));
+				return;
+			} 
+			
+			jsonTransformString(boutiqueAutoRule);
+			
+			
+			Integer source = boutiqueAutoRule.getSource();
+			if (source.equals(BoutiqueAutoRule.TB_OPTIONAL) || source == BoutiqueAutoRule.TB_OPTIONAL) {
+				String className = boutiqueAutoRule.getClassName();
+				GoodsClass rb = goodsClassService.getGoodsClass(Long.parseLong(className));
+				if (rb != null) {
+					boutiqueAutoRule.setClassNameChinese(rb.getName());
+				} 
+			}
+			
+			GsonBuilder gsonBuilder = new GsonBuilder();
+			gsonBuilder.serializeNulls();
+			Gson gson = gsonBuilder.setDateFormat("yyyy-MM-dd").create();
+
+			JSONObject data = new JSONObject();
+			data.put("autoRule", gson.toJson(boutiqueAutoRule));
+
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+
+		} catch (BoutiqueAutoRuleException e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鑾峰彇澶辫触"));
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 淇敼鍏ュ簱瑙勫垯
+	 * 
+	 * @param callback
+	 * @param boutiqueAutoRule
+	 * @param out
+	 */
+	@RequestMapping(value = "saveModify")
+	public void saveModify(AdminAcceptData acceptData,String callback, BoutiqueAutoRule boutiqueAutoRule, PrintWriter out) {
+		try {
+			Long id = boutiqueAutoRule.getId();
+			if (id == null) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇蜂紶閫掓纭弬鏁�"));
+				return;
+			}
+
+			BoutiqueAutoRule crrent = boutiqueAutoRuleService.selectByPrimaryKey(id);
+			if (crrent == null) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ユ潯瑙勫垯宸蹭笉瀛樺湪"));
+				return;
+			}
+
+			// 楠岃瘉浼犻�掓暟鎹槸鍚︽纭�
+			boolean validationData = validationData(callback, boutiqueAutoRule, out);
+			// 楠岃瘉鏈�氳繃
+			if (!validationData) {
+				return;
+			}
+			
+			transformJsonString(boutiqueAutoRule);
+		
+			String cronTime = boutiqueAutoRuleService.setCronTime(boutiqueAutoRule.getExecuteDay(),boutiqueAutoRule.getExecuteTime());
+			// cron鏃堕棿
+			boutiqueAutoRule.setCronTime(cronTime);
+			
+			boutiqueAutoRule.setState(crrent.getState());
+			boutiqueAutoRule.setCreatetime(crrent.getCreatetime());
+			// 鏇存柊鏃堕棿
+			boutiqueAutoRule.setUpdatetime(new Date());
+			
+			boutiqueAutoRuleService.updateByPrimaryKey(boutiqueAutoRule);
+
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇敼鎴愬姛"));
+			
+			
+			// 楠岃瘉褰撳墠浠诲姟鏄惁闇�瑕佷慨鏀� 銆佺珛鍗虫墽琛�
+			Integer crrentState = crrent.getState();
+			
+			if (crrentState != null) {
+				if (crrentState.equals(1)){
+					boolean validateDate = boutiqueAutoRuleService.validateDate(boutiqueAutoRule);
+					if (validateDate) {
+						// 浠诲姟淇敼
+						boutiqueAutoRuleService.setScheduler(boutiqueAutoRule, "modify"); 	
+					} else {
+						boutiqueAutoRuleService.setScheduler(boutiqueAutoRule, "delete");
+					}
+				}
+					
+			}
+			
+			
+		} catch (BoutiqueAutoRuleException e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇敼澶辫触"));
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 淇敼瑙勫垯鐘舵��
+	 * 
+	 * @param callback
+	 * @param id
+	 * @param state
+	 *            鐘舵�侊細1鍚敤 0鍋滅敤
+	 * @param out
+	 */
+	@RequestMapping(value = "saveState")
+	public void saveState(AdminAcceptData acceptData,String callback, Long id, Integer state, PrintWriter out) {
+		try {
+
+			if (id == null) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇蜂紶閫掓纭弬鏁�"));
+				return;
+			}
+
+			BoutiqueAutoRule crrent = boutiqueAutoRuleService.selectByPrimaryKey(id);
+			if (crrent == null) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ユ潯瑙勫垯宸蹭笉瀛樺湪"));
+				return;
+			}
+
+			if (state == null) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇敼鐘舵�佷负绌�"));
+				return;
+			}
+
+			crrent.setState(state);
+			crrent.setUpdatetime(new Date());
+
+			boutiqueAutoRuleService.updateByPrimaryKeySelective(crrent);
+
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇敼鎴愬姛"));
+			
+			boolean validateDate = boutiqueAutoRuleService.validateDate(crrent);
+			if (state.equals(1)) {
+				if (validateDate) {
+					boutiqueAutoRuleService.setScheduler(crrent, "add"); 	// 浠诲姟鍚姩
+				}
+			} else {
+				boutiqueAutoRuleService.setScheduler(crrent, "delete"); 	// 浠诲姟鍒犻櫎
+			}
+
+		} catch (BoutiqueAutoRuleException e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("淇敼澶辫触"));
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 鏌ヨ鍏ュ簱瑙勫垯
+	 * 
+	 * @param callback
+	 * @param pageIndex
+	 * @param pageSize
+	 * @param source
+	 *            鏉ユ簮
+	 * @param out
+	 */
+	@RequestMapping(value = "query")
+	public void query(AdminAcceptData acceptData,String callback, Integer pageIndex, Integer pageSize, Integer source,
+			String key, Integer state, Integer sort,  PrintWriter out) {
+
+		try {
+
+			if (pageIndex == null)
+				pageIndex = 1;
+
+			if (pageSize == null)
+				pageSize = Constant.PAGE_SIZE;
+
+			List<BoutiqueAutoRule> list = boutiqueAutoRuleService.query((pageIndex - 1) * pageSize, 
+					pageSize, source, key, state, sort);
+
+			if (list == null || list.size() == 0) {
+				out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁")));
+				return;
+			}
+
+			for (BoutiqueAutoRule boutiqueAutoRule: list) {
+				jsonTransformString(boutiqueAutoRule);
+				
+				if (source.equals(BoutiqueAutoRule.TB_OPTIONAL) || source == BoutiqueAutoRule.TB_OPTIONAL) {
+					String className = boutiqueAutoRule.getClassName();
+					GoodsClass rb = goodsClassService.getGoodsClass(Long.parseLong(className));
+					if (rb != null) {
+						boutiqueAutoRule.setClassNameChinese(rb.getName());
+					} 
+				}
+			}
+			
+			
+			long count = boutiqueAutoRuleService.queryCount(source, key, state);
+
+			int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
+			PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
+
+			GsonBuilder gsonBuilder = new GsonBuilder();
+			gsonBuilder.serializeNulls();
+			Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
+
+			JSONObject data = new JSONObject();
+			data.put("pe", pe);
+			data.put("resultList", gson.toJson(list));
+
+			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
+
+		} catch (Exception e) {
+			e.printStackTrace();
+			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("鏌ヨ澶辫触")));
+		}
+	}
+	
+	
+	/**
+	 * 淇敼鍏ュ簱瑙勫垯
+	 * 
+	 * @param callback
+	 * @param boutiqueAutoRule
+	 * @param out
+	 */
+	@RequestMapping(value = "delete")
+	public void delete(AdminAcceptData acceptData,String callback, Long id, PrintWriter out) {
+		try {
+			if (id == null) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇蜂紶閫掓纭弬鏁�"));
+				return;
+			}
+			
+			BoutiqueAutoRule boutiqueAutoRule = boutiqueAutoRuleService.selectByPrimaryKey(id);
+			if (boutiqueAutoRule == null) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ヨ鍒欏凡琚垹闄�"));
+				return;
+			}
+			
+			// 浠诲姟鍒犻櫎
+			boutiqueAutoRuleService.setScheduler(boutiqueAutoRule, "delete");
+
+			boutiqueAutoRuleService.deleteByPrimaryKey(id);
+
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鍒犻櫎鎴愬姛"));
+			
+		} catch (BoutiqueAutoRuleException e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒犻櫎澶辫触"));
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 淇敼鍏ュ簱瑙勫垯
+	 * 
+	 * @param callback
+	 * @param boutiqueAutoRule
+	 * @param out
+	 */
+	@RequestMapping(value = "shutdownJobs")
+	public void shutdownJobs(AdminAcceptData acceptData,String callback, PrintWriter out) {
+		try {
+			boutiqueAutoRuleService.shutdownJobs();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+	
+	
+	/**
+	 * 灏嗘煡璇㈢瓫閫夋潯浠惰浆鎹负json
+	 * @param boutiqueAutoRule
+	 */
+	public void transformJsonString(BoutiqueAutoRule boutiqueAutoRule){
+		JSONObject data = new JSONObject();
+		Integer source = boutiqueAutoRule.getSource();
+		// 绫荤洰id
+		if (source.equals(BoutiqueAutoRule.TB_OPTIONAL)) {
+			data.put("systemCid", boutiqueAutoRule.getClassName());
+		}
+		
+		if (boutiqueAutoRule.getKey() != null){
+			// 鎼滅储鍏抽敭璇�
+			data.put("key", boutiqueAutoRule.getKey());
+		}
+		
+		if (boutiqueAutoRule.getTitle() != null){
+			// 鎼滅储鍏抽敭璇�
+			data.put("title", boutiqueAutoRule.getTitle());
+		}
+		
+		
+		if ( boutiqueAutoRule.getCateIds() != null){
+			// 瀹樻柟鎺ㄨ崘鍟嗗搧搴撴姇鏀綢D;娣樺疂绫荤洰id闆嗗悎
+			data.put("cateIds", boutiqueAutoRule.getCateIds()); 
+		}
+	
+		if ( boutiqueAutoRule.getStartTkRate() != null){
+			// 浣i噾鑼冨洿灏忓��
+			data.put("startTkRate", boutiqueAutoRule.getStartTkRate()); 
+		}
+		
+		if ( boutiqueAutoRule.getEndTkRate() != null){
+			// 浣i噾鑼冨洿澶у��
+			data.put("endTkRate", boutiqueAutoRule.getEndTkRate()); 
+		}
+		
+		if ( boutiqueAutoRule.getStartSales() != null){
+			// 閿�閲忓皬鍊�
+			data.put("startSales", boutiqueAutoRule.getStartSales()); 
+		}
+		
+		if ( boutiqueAutoRule.getEndSales() != null){
+			// 閿�閲忓ぇ鍊�
+			data.put("endSales", boutiqueAutoRule.getEndSales()); 
+		}
+		
+		
+		if ( boutiqueAutoRule.getStartZkPrice() != null){
+			// 鍦ㄥ敭浠疯寖鍥村皬鍊�
+			data.put("startZkPrice", boutiqueAutoRule.getStartZkPrice());
+		}
+		
+		if ( boutiqueAutoRule.getEndZkPrice() != null){
+			// 鍦ㄥ敭浠疯寖鍥村ぇ鍊�
+			data.put("endZkPrice", boutiqueAutoRule.getEndZkPrice()); 
+		}
+
+		if ( boutiqueAutoRule.getStartPrice() != null){
+			// 鍒稿悗浠疯寖鍥村皬鍊�
+			data.put("startPrice", boutiqueAutoRule.getStartPrice());
+		}
+		
+		if ( boutiqueAutoRule.getEndPrice() != null){
+			// 鍒稿悗浠疯寖鍥村ぇ鍊�
+			data.put("endPrice", boutiqueAutoRule.getEndPrice()); 
+		}
+
+		if ( boutiqueAutoRule.getIsTmall() != null){
+			// 鏄惁澶╃尗
+			data.put("isTmall", boutiqueAutoRule.getIsTmall()); 
+		}
+		
+		if ( boutiqueAutoRule.getHasCoupon() != null){
+			// 鏄惁鏈夊埜锛�1 鏈� 0 鏃�
+			data.put("hasCoupon", boutiqueAutoRule.getHasCoupon()); 
+		}
+		
+		if ( boutiqueAutoRule.getFreeShipment() != null){
+			// 鏄惁鍖呴偖锛�1 鏈� 0 鏃�
+			data.put("freeShipment", boutiqueAutoRule.getFreeShipment()); 
+		}
+		
+		if ( boutiqueAutoRule.getNeedPrepay() != null){
+			// 鏄惁娑堣垂淇濋殰锛�1鏈� 0 鏃�
+			data.put("needPrepay", boutiqueAutoRule.getNeedPrepay()); 
+		}
+		
+		if (boutiqueAutoRule.getNpxLevel() != null){
+			// 鐗涚毊鐧g▼搴︼紝鍙栧�硷細1:涓嶉檺锛�2:鏃狅紝3:杞诲井
+			data.put("npxLevel", boutiqueAutoRule.getNpxLevel()); 
+		}
+
+		if ( boutiqueAutoRule.getIncludePayRate30() != null){
+			// 鎴愪氦杞寲鏄惁楂樹簬琛屼笟鍧囧��        1 鏈� 0 鏃�
+			data.put("includePayRate30", boutiqueAutoRule.getIncludePayRate30()); 
+		}
+		
+		if ( boutiqueAutoRule.getIncludeGoodRate() != null){
+			// 濂借瘎鐜囨槸鍚﹂珮浜庤涓氬潎鍊�            1 鏈� 0 鏃�
+			data.put("includeGoodRate", boutiqueAutoRule.getIncludeGoodRate()); 
+		}
+		
+		if ( boutiqueAutoRule.getIncludeRfdRate() != null){
+			// 閫�娆剧巼鏄惁浣庝簬琛屼笟鍧囧��             1 鏈� 0 鏃�
+			data.put("includeRfdRate", boutiqueAutoRule.getIncludeRfdRate()); 
+		}
+		
+		if ( boutiqueAutoRule.getLableNames() != null){
+			data.put("lableNames", boutiqueAutoRule.getLableNames()); 
+		}
+		
+		// 璇锋眰鏈�澶ч〉鐮�
+		if (boutiqueAutoRule.getMaxPage() != null){
+			data.put("maxPage", boutiqueAutoRule.getMaxPage()); 
+		}
+		
+		// 璇锋眰鏈�澶ч〉鐮�
+		if (boutiqueAutoRule.getClassName() != null){
+			if (source.equals(BoutiqueAutoRule.TB_OPTIONAL) || source== BoutiqueAutoRule.TB_OPTIONAL) {
+				String classId = boutiqueAutoRule.getClassName();
+				if (!StringUtil.isNullOrEmpty(classId)){
+					GoodsClass rb = goodsClassService.getGoodsClass(Long.parseLong(classId));
+					if (rb != null) {
+						data.put("sourceCalss", rb.getName()); 
+						boutiqueAutoRule.setSourceCalss(rb.getName());
+					} 
+				}
+			}  else if (source.equals(BoutiqueAutoRule.TB_MATERIAL) || source == BoutiqueAutoRule.TB_MATERIAL) {
+				String subName = boutiqueAutoRule.getSubclassName();
+				String superName = boutiqueAutoRule.getClassName();
+				if (StringUtil.isNullOrEmpty(subName)) {
+					data.put("sourceCalss", superName); 
+					boutiqueAutoRule.setSourceCalss(superName);
+				} else {
+					data.put("sourceCalss", superName +" "+ subName); 
+					boutiqueAutoRule.setSourceCalss(superName +" "+ subName);
+				}
+			}
+		}
+		
+		boutiqueAutoRule.setSearchContent(data.toString());
+		
+	}
+	
+	
+	/**
+	 * json 杞崲鏈猄tring
+	 * @param boutiqueAutoRule
+	 */
+	public void jsonTransformString(BoutiqueAutoRule boutiqueAutoRule){
+		String searchContent = boutiqueAutoRule.getSearchContent();
+		if (StringUtil.isNullOrEmpty(searchContent)) {
+			return;
+		}
+		
+		JSONObject jsonData = JSONObject.fromObject(searchContent);
+		
+		if (jsonData.get("key") != null){
+			// 鎼滅储鍏抽敭璇�
+			boutiqueAutoRule.setKey(jsonData.get("key").toString());
+		}
+		
+		if (jsonData.get("cateIds") != null){
+			// 瀹樻柟鎺ㄨ崘鍟嗗搧搴撴姇鏀綢D;娣樺疂绫荤洰id闆嗗悎
+			boutiqueAutoRule.setCateIds(jsonData.get("cateIds").toString());
+		}
+	
+		if (jsonData.get("startTkRate") != null){
+			// 浣i噾鑼冨洿灏忓�糄ouble.valueOf(itoString());
+			boutiqueAutoRule.setStartTkRate(Double.valueOf(jsonData.get("startTkRate").toString()));
+		}
+		
+		if (jsonData.get("endTkRate") != null){
+			// 浣i噾鑼冨洿澶у��
+			 boutiqueAutoRule.setEndTkRate(Double.valueOf(jsonData.get("endTkRate").toString())); 
+		}
+		
+		if (jsonData.get("startSales") != null){
+			// 閿�閲忓皬鍊�
+			 boutiqueAutoRule.setStartSales((int)jsonData.get("startSales")); 
+		}
+		
+		if (jsonData.get("endSales") != null){
+			// 閿�閲忓ぇ鍊�
+			boutiqueAutoRule.setEndSales((int)jsonData.get("endSales")); 
+		}
+		
+		if (jsonData.get("startZkPrice") != null){
+			// 鍦ㄥ敭浠疯寖鍥村皬鍊�
+			boutiqueAutoRule.setStartZkPrice(Double.valueOf(jsonData.get("startZkPrice").toString()));
+		}
+		
+		if (jsonData.get("endZkPrice") != null){
+			// 鍦ㄥ敭浠疯寖鍥村ぇ鍊�
+			boutiqueAutoRule.setEndZkPrice(Double.valueOf(jsonData.get("endZkPrice").toString())); 
+		}
+		
+		if (jsonData.get("startPrice") != null){
+			// 鍒稿悗浠疯寖鍥村皬鍊�
+			boutiqueAutoRule.setStartPrice(Double.valueOf(jsonData.get("startPrice").toString()));
+		}
+		
+		if (jsonData.get("endPrice") != null){
+			// 鍒稿悗浠疯寖鍥村ぇ鍊�
+			boutiqueAutoRule.setEndPrice(Double.valueOf(jsonData.get("endPrice").toString())); 
+		}
+
+		if (jsonData.get("isTmall") != null){
+			// 鏄惁澶╃尗
+			boutiqueAutoRule.setIsTmall((int)jsonData.get("isTmall")); 
+		}
+		
+		if (jsonData.get("hasCoupon") != null){
+			// 鏄惁鏈夊埜锛�1 鏈� 0 鏃�
+			boutiqueAutoRule.setHasCoupon((int)jsonData.get("hasCoupon")); 
+		}
+		
+		if (jsonData.get("freeShipment") != null){
+			// 鏄惁鍖呴偖锛�1 鏈� 0 鏃�
+			boutiqueAutoRule.setFreeShipment((int)jsonData.get("freeShipment")); 
+		}
+		
+		if (jsonData.get("needPrepay") != null){
+			// 鏄惁娑堣垂淇濋殰锛�1鏈� 0 鏃�
+			boutiqueAutoRule.setNeedPrepay((int)jsonData.get("needPrepay")); 
+		}
+		
+		if (jsonData.get("npxLevel") != null){
+			// 鐗涚毊鐧g▼搴︼紝鍙栧�硷細1:涓嶉檺锛�2:鏃狅紝3:杞诲井
+			boutiqueAutoRule.setNpxLevel((int)jsonData.get("npxLevel")); 
+		}
+
+		if (jsonData.get("includePayRate30") != null){
+			// 鎴愪氦杞寲鏄惁楂樹簬琛屼笟鍧囧��        1 鏈� 0 鏃�
+			boutiqueAutoRule.setIncludePayRate30((int)jsonData.get("includePayRate30")); 
+		}
+		
+		if (jsonData.get("includeGoodRate") != null){
+			// 濂借瘎鐜囨槸鍚﹂珮浜庤涓氬潎鍊�            1 鏈� 0 鏃�
+			boutiqueAutoRule.setIncludeGoodRate((int)jsonData.get("includeGoodRate")); 
+		}
+		
+		if (jsonData.get("includeRfdRate") != null){
+			// 閫�娆剧巼鏄惁浣庝簬琛屼笟鍧囧��             1 鏈� 0 鏃�
+			boutiqueAutoRule.setIncludeRfdRate((int)jsonData.get("includeRfdRate")); 
+		}
+		
+		if (jsonData.get("lableNames") != null){
+			boutiqueAutoRule.setLableNames(jsonData.get("lableNames").toString()); 
+		}
+		
+		if (jsonData.get("maxPage") != null){
+			// 鏄惁鍖呴偖锛�1 鏈� 0 鏃�
+			boutiqueAutoRule.setMaxPage((int)jsonData.get("maxPage")); 
+		}
+	}
+	
+	/**
+	 * 楠岃瘉鍓嶇灞曠ず鏁版嵁鏄惁绗﹀悎瑙勮寖
+	 * @param callback
+	 * @param boutiqueAutoRule
+	 * @param out
+	 * @return
+	 */
+	public boolean validationData(String callback, BoutiqueAutoRule boutiqueAutoRule, PrintWriter out){
+		
+		Integer source = boutiqueAutoRule.getSource();
+		if (source == null) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏉ユ簮涓嶈兘涓虹┖"));
+			return false;
+		}
+		
+		Integer maxPage = boutiqueAutoRule.getMaxPage();
+		if (maxPage == null) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇锋眰鏈�澶ч〉鏁颁笉鑳界┖"));
+			return false;
+		}
+		
+		
+		if (source.equals(BoutiqueAutoRule.TB_OPTIONAL) || source== BoutiqueAutoRule.TB_OPTIONAL) {
+			
+			/* 娣樺疂瀵艰喘鐗╂枡API 鏁版嵁楠岃瘉 */
+			
+			String key = boutiqueAutoRule.getKey();
+			String classId = boutiqueAutoRule.getClassName();
+		
+			if (StringUtil.isNullOrEmpty(key) && StringUtil.isNullOrEmpty(classId)) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绫诲瀷涓庡叧閿瘝涓嶈兘鍚屾椂涓虹┖"));
+				return false;
+			}
+			
+			
+			if (!StringUtil.isNullOrEmpty(classId)){
+				
+				GoodsClass rb = goodsClassService.getGoodsClass(Long.parseLong(classId));
+				if (rb == null) {
+					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ョ被鍨嬪凡涓嶅瓨鍦�,璇峰埛鏂伴噸璇�"));
+					return false;
+				} 
+				
+				
+				List<TaoBaoClass> listCatIds = taoBaoClassService.listBySystemCid(0, 10, Long.parseLong(classId));
+				if (listCatIds == null || listCatIds.size() == 0) {
+					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(rb.getName() + "瀵瑰簲娣樺疂id涓虹┖锛岃閫氱煡鐩稿叧浜哄憳杩涜缁存姢"));
+					return false;
+				}
+				
+				String taobaoCatIds = "";
+				for (TaoBaoClass taoBaoClass: listCatIds) {
+					   Integer categoryId = taoBaoClass.getCategoryId();
+					  
+					  if (categoryId == null ) {
+						  continue;
+					  }
+					  
+					  taobaoCatIds += categoryId + ",";
+				}
+				
+				if (StringUtil.isNullOrEmpty(taobaoCatIds)){
+					JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(rb.getName() + "瀵瑰簲娣樺疂id涓虹┖锛岃閫氱煡鐩稿叧浜哄憳杩涜缁存姢"));
+					return false;
+				} 
+				
+				boutiqueAutoRule.setCateIds(taobaoCatIds.substring(0, taobaoCatIds.length()-1));
+			}
+			
+		}  else if (source.equals(BoutiqueAutoRule.TB_MATERIAL) || source == BoutiqueAutoRule.TB_MATERIAL) {
+			
+			/* 娣樺疂瀹樻柟鎺ㄨ崘   鏁版嵁楠岃瘉  */
+			
+			String subName = boutiqueAutoRule.getSubclassName();
+			String superName = boutiqueAutoRule.getClassName();
+			
+			if (StringUtil.isNullOrEmpty(subName) && StringUtil.isNullOrEmpty(superName) ) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨姝g‘鐨勭被鐩�"));
+				return false;
+			} 
+			
+			List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperName(subName, superName);
+
+			if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ョ被鐩俊鎭笉瀛樺湪"));
+				return false;
+			} else if (taobaoMeterials.size() > 1) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鐩稿簲鐨勫瓙绫�"));
+				return false;
+			}
+			
+			TaobaoMeterial taobaoMeterial = taobaoMeterials.get(0);
+			Integer materialId = taobaoMeterial.getMaterialId();
+			
+			if (materialId == null) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ョ被鐩墿鏂橧D涓嶅瓨鍦�"));
+				return false;
+			}
+			
+			boutiqueAutoRule.setCateIds(materialId + "");
+		} else {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇蜂紶閫掓纭潵婧�"));
+			return false;
+		}
+		
+		
+		// 鐢熸晥鏃堕棿
+		Date startTime = boutiqueAutoRule.getStartTime();
+		// 澶辨晥鏃堕棿
+		Date endTime = boutiqueAutoRule.getEndTime();
+		if (endTime != null) {
+			if (startTime != null && startTime.getTime() > endTime.getTime()){
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢熸晥鏃堕棿涓嶈兘澶т簬澶辨晥鏃堕棿"));
+				return false;
+			}
+			
+			Calendar calendar = Calendar.getInstance();
+			calendar.setTime(endTime);
+			calendar.set(Calendar.HOUR, 23);
+			calendar.set(Calendar.MINUTE, 59);
+			calendar.set(Calendar.SECOND, 59);
+			boutiqueAutoRule.setEndTime(calendar.getTime());
+		}
+		
+		if (startTime == null) {
+			 boutiqueAutoRule.setStartTime(new Date());
+		}
+		return true;
+	}
+	
+}

--
Gitblit v1.8.0