提交 caf410c6 authored 作者: zgy's avatar zgy

修改购物车

上级 207c0bb1
......@@ -186,11 +186,9 @@
`item_descrition_id`
from tb_cf_station_item
where enable_flag=1 and item_category = #{categoryId}
order by
<if test="order != null">discount_price ${order},</if>
item_num desc
<if test="order != null ">
order by discount_price ${order}
</if>
</select>
<select id="getGoodsTypeList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfStationItemEntity">
select
......
package com.diaoyun.zion;
import com.aliyun.oss.common.utils.HttpUtil;
import com.diaoyun.zion.chinafrica.constant.KeyConstant;
import com.diaoyun.zion.chinafrica.dao.TbCfIssueCouponDao;
import com.diaoyun.zion.chinafrica.entity.TbCfStationItemEntity;
import com.diaoyun.zion.chinafrica.entity.TbCfUserInfoEntity;
import com.diaoyun.zion.chinafrica.service.SpiderService;
import com.diaoyun.zion.chinafrica.service.TbCfCouponService;
import com.diaoyun.zion.chinafrica.service.TbCfIssueCouponService;
import com.diaoyun.zion.chinafrica.service.TbCfUserInfoService;
import com.diaoyun.zion.chinafrica.vo.ShopifyConstant;
import com.diaoyun.zion.chinafrica.vo.TbCfOrderVo;
import com.diaoyun.zion.master.common.RedisCache;
import com.diaoyun.zion.master.thread.TaskLimitSemaphore;
import com.diaoyun.zion.master.util.AESUtils;
import com.diaoyun.zion.master.util.HttpClientUtil;
import com.diaoyun.zion.master.util.IdUtil;
import com.diaoyun.zion.master.util.SMSUtil;
import com.stripe.exception.StripeException;
import freemarker.template.Configuration;
import freemarker.template.TemplateException;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.mail.EmailException;
import org.apache.http.NameValuePair;
import org.apache.http.client.CookieStore;
......@@ -532,7 +538,7 @@ public class ZionApplicationTests {
phone += user.getPhone();
phone += ",";
}
// System.out.println(phone);
// System.out.println(phone);
String text = "We've updated!\n" +
"Thank you for downloading Afrishop. If you get a 'Server Busy' notification as you are trying to shop, be sure to sign out and sign in again. Be sure to check your device store for the lastest app updates.\n" +
"You can also shop using our website www.afrieshop.com\n" +
......@@ -548,7 +554,7 @@ public class ZionApplicationTests {
// String hour = orderRedisCache.expire("order_detf28b71d685a34c528180782520fef886");
String hour = getHour("3662");
// System.out.println(hour);
// System.out.println(hour);
}
......@@ -570,8 +576,8 @@ public class ZionApplicationTests {
}
public String getHour(String time) {
if(Integer.parseInt(time)<0){
time="0";
if (Integer.parseInt(time) < 0) {
time = "0";
}
int seconds = Integer.parseInt(time);
int temp = 0;
......@@ -586,4 +592,78 @@ public class ZionApplicationTests {
sb.append((temp < 10) ? "0" + temp : "" + temp);
return sb.toString();
}
@Test
public void queryItemFromShopify() throws IOException {
Map<String, Object> params = new HashMap<>();
params.put("product_type", "Face");
params.put("limit", "2");
String data = HttpClientUtil.createConnection(ShopifyConstant.productTypeUrl(), params, "UTF-8");
System.out.println(data);
JSONObject jsonObject = JSONObject.fromObject(data);
JSONArray products = jsonObject.getJSONArray("products");
System.err.println(products);
for (int j = 0; j < products.size(); j++) {
JSONObject object = products.getJSONObject(j);
String id = object.getString("id");
String title = object.getString("title");
String product_type = object.getString("product_type");
JSONArray variants = object.getJSONArray("variants");
String image = object.getJSONObject("image").getString("src");
List<Double> priceList = new ArrayList<>();
for (int m = 0; m < variants.size(); m++) {
JSONObject obj = variants.getJSONObject(m);
String productPrice = obj.getString("price");
priceList.add(Double.valueOf(productPrice));
}
Collections.sort(priceList);
System.out.println(id);
System.out.println(title);
System.out.println(product_type);
System.out.println(image);
System.out.println(priceList);
System.out.println("===================");
System.out.println(new BigDecimal(priceList.get(0)).setScale(2, BigDecimal.ROUND_DOWN));
TbCfStationItemEntity product = new TbCfStationItemEntity();
product.setItemId(IdUtil.createIdbyUUID());
product.setItemCode(id);
product.setItemName(title);
product.setItemBrief(title);
product.setItemPrice(new BigDecimal(priceList.get(0)).setScale(2, BigDecimal.ROUND_DOWN));
product.setItemImg(image);
product.setItemNum(0L);
product.setPlatformCode("afri-eshop");
product.setPlatformName("afri-eshop");
product.setEnableFlag(3);
product.setCreateTime(new Date());
// tbCfStationItemDao.save(product);
}
}
/**
* 查询所有商品分类
*
* @return
* @throws IOException
*/
public List getProductType() throws IOException {
Map<String, Object> params = new HashMap<>();
params.put("fields", "product_type");
String connection = HttpClientUtil.createConnection(ShopifyConstant.productTypeUrl(), params, "UTF-8");
List list = new ArrayList();
JSONArray products = JSONObject.fromObject(connection).getJSONArray("products");
for (int i = 0; i < products.size(); i++) {
String string = products.getString(i);
JSONObject jsonObject = JSONObject.fromObject(string);
String product_type = jsonObject.getString("product_type");
if (!"".equals(product_type) && !list.contains(product_type)) {
list.add(product_type);
}
}
System.out.println(list);
return list;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论