|
|
|
@ -1,8 +1,10 @@ |
|
|
|
package cn.chjyj.szwh.utils; |
|
|
|
|
|
|
|
import cn.chjyj.szwh.bean.GoodsDetail; |
|
|
|
import cn.chjyj.szwh.bean.GoodsSource; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
@ -64,4 +66,43 @@ public class ApiGoodsUtisl { |
|
|
|
goodsSource.setGoodsIsliCode(islicode); |
|
|
|
return goodsSource; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 从json字符串中抽取商品详情 |
|
|
|
* @param json soucedata中的字段 |
|
|
|
* @param nodejson json数组中的单项 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static GoodsDetail jsonToGoodsDetail(JSONObject json,JSONObject nodejson){ |
|
|
|
// 抽取出sourcedata
|
|
|
|
String sprice = json.getString("price"); |
|
|
|
float price = Float.valueOf(sprice); |
|
|
|
|
|
|
|
GoodsDetail goodsDetail = new GoodsDetail(); |
|
|
|
goodsDetail.setGoodsName(json.getString("titleName")); |
|
|
|
goodsDetail.setGoodsImage(json.getString("cover")); |
|
|
|
goodsDetail.setPrice(new BigDecimal(sprice)); |
|
|
|
// 商品类型
|
|
|
|
int igtype = "文化资源数据".equalsIgnoreCase("collectionType")?1:2; |
|
|
|
goodsDetail.setGoodsType(igtype); |
|
|
|
//
|
|
|
|
int ictype = price<=0?1:2; |
|
|
|
goodsDetail.setChargesType(ictype); |
|
|
|
goodsDetail.setGoodsIslicode(json.getString("identifier")); |
|
|
|
goodsDetail.setContractualPeriod(0); |
|
|
|
goodsDetail.setSourcedataIslicode(json.getString("isliCode")); |
|
|
|
goodsDetail.setEarnestMoney(new BigDecimal(0)); |
|
|
|
//权属问题
|
|
|
|
String stclass=json.getString("transactionKind"); |
|
|
|
int istclass = "权属".equals(stclass)?1:2; |
|
|
|
goodsDetail.setTransactionClass(istclass); |
|
|
|
// 商品描述
|
|
|
|
goodsDetail.setContract(json.getString("description")); |
|
|
|
goodsDetail.setOtheridentifiers(json.getString("otherIdentifiers")); |
|
|
|
//
|
|
|
|
goodsDetail.setDataJson(nodejson.toJSONString()); |
|
|
|
goodsDetail.setSourceJson(json.toJSONString()); |
|
|
|
//
|
|
|
|
return goodsDetail; |
|
|
|
} |
|
|
|
} |
|
|
|
|