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

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/diaoyun/zion/chinafrica/controller/TbCfItemDetailController.java
...@@ -22,7 +22,10 @@ public interface TbCfCartRecordRDao extends BaseDao<TbCfCartRecordREntity> { ...@@ -22,7 +22,10 @@ public interface TbCfCartRecordRDao extends BaseDao<TbCfCartRecordREntity> {
*/ */
int deleteItems(String[] cartRecordIds); int deleteItems(String[] cartRecordIds);
TbCfCartRecordREntity queryByItemId(String itemId); TbCfCartRecordREntity queryByItemId(@Param("itemId") String itemId,@Param("userId") String userId,@Param("itemSku") String itemSku);
TbCfCartRecordREntity querySkuAndUrl( @Param("itemSku") String itemSku, @Param("itemId") String itemId, @Param("sourceItemId") String sourceItemId, @Param("userId") String userId);
int queryItemNum(String userId);
TbCfCartRecordREntity querySkuAndUrl(@Param("itemSku") String itemSku,@Param("sourceItemId") String sourceItemId);
} }
...@@ -2,6 +2,7 @@ package com.diaoyun.zion.chinafrica.dao; ...@@ -2,6 +2,7 @@ package com.diaoyun.zion.chinafrica.dao;
import com.diaoyun.zion.chinafrica.entity.TbCfExchangeEntity; import com.diaoyun.zion.chinafrica.entity.TbCfExchangeEntity;
import com.diaoyun.zion.chinafrica.entity.TbCfFeeEntity;
import com.diaoyun.zion.master.dao.BaseDao; import com.diaoyun.zion.master.dao.BaseDao;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -15,4 +16,6 @@ import java.math.BigDecimal; ...@@ -15,4 +16,6 @@ import java.math.BigDecimal;
public interface TbCfExchangeDao extends BaseDao<TbCfExchangeEntity> { public interface TbCfExchangeDao extends BaseDao<TbCfExchangeEntity> {
void updateByType(String type, BigDecimal rate); void updateByType(String type, BigDecimal rate);
TbCfExchangeEntity getRateFee(String exchangeCurrency);
} }
...@@ -33,5 +33,6 @@ public interface TbCfItemDetailDao extends BaseDao<TbCfItemDetailEntity> { ...@@ -33,5 +33,6 @@ public interface TbCfItemDetailDao extends BaseDao<TbCfItemDetailEntity> {
*/ */
int changeItemState(String cartRecordId, Integer checkFlag); int changeItemState(String cartRecordId, Integer checkFlag);
int queryItemNum(String userId);
int changeState(@Param("ids") String[] ids, @Param("checkFlag") String checkFlag); int changeState(@Param("ids") String[] ids, @Param("checkFlag") String checkFlag);
} }
...@@ -33,6 +33,10 @@ public class OrderEntity implements Serializable { ...@@ -33,6 +33,10 @@ public class OrderEntity implements Serializable {
* 收货人手机 * 收货人手机
*/ */
private String deliveryPhone; private String deliveryPhone;
/**
* 订单备注
*/
private String remarkInfo;
/** /**
* 商品明细集合 * 商品明细集合
*/ */
...@@ -94,4 +98,12 @@ public class OrderEntity implements Serializable { ...@@ -94,4 +98,12 @@ public class OrderEntity implements Serializable {
public void setUserName(String userName) { public void setUserName(String userName) {
this.userName = userName; this.userName = userName;
} }
public String getRemarkInfo() {
return remarkInfo;
}
public void setRemarkInfo(String remarkInfo) {
this.remarkInfo = remarkInfo;
}
} }
...@@ -2,6 +2,7 @@ package com.diaoyun.zion.chinafrica.service; ...@@ -2,6 +2,7 @@ package com.diaoyun.zion.chinafrica.service;
import com.diaoyun.zion.chinafrica.entity.TbCfExchangeEntity; import com.diaoyun.zion.chinafrica.entity.TbCfExchangeEntity;
import com.diaoyun.zion.chinafrica.entity.TbCfFeeEntity;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
...@@ -72,4 +73,6 @@ public interface TbCfExchangeService { ...@@ -72,4 +73,6 @@ public interface TbCfExchangeService {
int deleteBatch(String[] ids); int deleteBatch(String[] ids);
void updateByType(String type, BigDecimal rate); void updateByType(String type, BigDecimal rate);
TbCfExchangeEntity getRateFee(String exchangeCurrency);
} }
...@@ -106,4 +106,5 @@ public interface TbCfItemDetailService { ...@@ -106,4 +106,5 @@ public interface TbCfItemDetailService {
* @return * @return
*/ */
Result changeItemState(String cartRecordId, Integer enableFlag); Result changeItemState(String cartRecordId, Integer enableFlag);
} }
...@@ -3,6 +3,7 @@ package com.diaoyun.zion.chinafrica.service.impl; ...@@ -3,6 +3,7 @@ package com.diaoyun.zion.chinafrica.service.impl;
import com.diaoyun.zion.chinafrica.dao.TbCfExchangeDao; import com.diaoyun.zion.chinafrica.dao.TbCfExchangeDao;
import com.diaoyun.zion.chinafrica.entity.TbCfExchangeEntity; import com.diaoyun.zion.chinafrica.entity.TbCfExchangeEntity;
import com.diaoyun.zion.chinafrica.entity.TbCfFeeEntity;
import com.diaoyun.zion.chinafrica.service.TbCfExchangeService; import com.diaoyun.zion.chinafrica.service.TbCfExchangeService;
import com.diaoyun.zion.master.util.IdUtil; import com.diaoyun.zion.master.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -69,4 +70,9 @@ public class TbCfExchangeServiceImpl implements TbCfExchangeService { ...@@ -69,4 +70,9 @@ public class TbCfExchangeServiceImpl implements TbCfExchangeService {
tbCfExchangeDao.updateByType(type,rate); tbCfExchangeDao.updateByType(type,rate);
} }
@Override
public TbCfExchangeEntity getRateFee(String exchangeCurrency) {
return tbCfExchangeDao.getRateFee(exchangeCurrency);
}
} }
...@@ -22,6 +22,7 @@ import com.diaoyun.zion.master.util.ValidateUtils; ...@@ -22,6 +22,7 @@ import com.diaoyun.zion.master.util.ValidateUtils;
import com.diaoyun.zion.master.util.WordposHelper; import com.diaoyun.zion.master.util.WordposHelper;
import net.sf.json.JSONArray; import net.sf.json.JSONArray;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.apache.logging.log4j.spi.LoggerRegistry;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -100,6 +101,11 @@ public class TbCfItemDetailServiceImpl implements TbCfItemDetailService { ...@@ -100,6 +101,11 @@ public class TbCfItemDetailServiceImpl implements TbCfItemDetailService {
public Result addToCart(TbCfItemDetailVo tbCfItemDetailVo) throws InterruptedException, ExecutionException, TimeoutException { public Result addToCart(TbCfItemDetailVo tbCfItemDetailVo) throws InterruptedException, ExecutionException, TimeoutException {
String token = jwtTokenProvider.resolveToken(request); String token = jwtTokenProvider.resolveToken(request);
TbCfUserInfoVo tbCfUserInfoVo = tokenManager.validate(token); TbCfUserInfoVo tbCfUserInfoVo = tokenManager.validate(token);
int itemCount = tbCfItemDetailDao.queryItemNum(tbCfUserInfoVo.getUserId());
System.out.println(itemCount);
if(itemCount>=99){
return new Result(ResultCodeEnum.ERROR.getCode()).setMessage("The shopping cart is full and needs to be cleaned!");
}
boolean flag = false; boolean flag = false;
if (tbCfItemDetailVo.getItemPrice() != null) { if (tbCfItemDetailVo.getItemPrice() != null) {
int compare = tbCfItemDetailVo.getItemPrice().compareTo(BigDecimal.ZERO); int compare = tbCfItemDetailVo.getItemPrice().compareTo(BigDecimal.ZERO);
...@@ -109,14 +115,26 @@ public class TbCfItemDetailServiceImpl implements TbCfItemDetailService { ...@@ -109,14 +115,26 @@ public class TbCfItemDetailServiceImpl implements TbCfItemDetailService {
} }
if (flag) { if (flag) {
//填充新商品必要信息 //填充新商品必要信息
TbCfCartRecordREntity tbCfCartRecord = tbCfCartRecordRDao.querySkuAndUrl(tbCfItemDetailVo.getItemSku(), tbCfItemDetailVo.getSourceItemId()); TbCfCartRecordREntity tbCfCartRecord = tbCfCartRecordRDao.querySkuAndUrl(tbCfItemDetailVo.getItemSku(),tbCfItemDetailVo.getItemId(), tbCfItemDetailVo.getSourceItemId(),tbCfUserInfoVo.getUserId());
if (tbCfCartRecord != null) { if(tbCfItemDetailVo.getSourceItemId().equals("www.afrieshop.com")) {
tbCfItemDetailVo.setItemId(tbCfCartRecord.getItemId()); if (tbCfCartRecord != null) {
tbCfItemDetailVo.setItemNum(tbCfCartRecord.getItemNum() + tbCfItemDetailVo.getItemNum()); tbCfItemDetailVo.setItemId(tbCfCartRecord.getItemId());
tbCfItemDetailVo.setCreateTime(new Date()); tbCfItemDetailVo.setItemNum(tbCfCartRecord.getItemNum() + tbCfItemDetailVo.getItemNum());
} else { tbCfItemDetailVo.setCreateTime(new Date());
tbCfItemDetailVo.setItemId(IdUtil.createIdbyUUID()); }else{
tbCfItemDetailVo.setCreateTime(new Date()); tbCfItemDetailVo.setItemId(tbCfItemDetailVo.getItemId());
tbCfItemDetailVo.setItemNum(tbCfItemDetailVo.getItemNum());
tbCfItemDetailVo.setCreateTime(new Date());
}
}else{
if (tbCfCartRecord != null) {
tbCfItemDetailVo.setItemId(tbCfCartRecord.getItemId());
tbCfItemDetailVo.setItemNum(tbCfCartRecord.getItemNum() + tbCfItemDetailVo.getItemNum());
tbCfItemDetailVo.setCreateTime(new Date());
}else{
tbCfItemDetailVo.setItemId(IdUtil.createIdbyUUID());
tbCfItemDetailVo.setCreateTime(new Date());
}
} }
//为商品分类,后面计算运费 //为商品分类,后面计算运费
TbCfExpressTemplateEntity expressTemplate = recognizeItemCategory(tbCfItemDetailVo.getItemTitle()); TbCfExpressTemplateEntity expressTemplate = recognizeItemCategory(tbCfItemDetailVo.getItemTitle());
...@@ -125,31 +143,32 @@ public class TbCfItemDetailServiceImpl implements TbCfItemDetailService { ...@@ -125,31 +143,32 @@ public class TbCfItemDetailServiceImpl implements TbCfItemDetailService {
TbCfItemDetailEntity tbCfItemDetail = new TbCfItemDetailEntity(); TbCfItemDetailEntity tbCfItemDetail = new TbCfItemDetailEntity();
BeanUtils.copyProperties(tbCfItemDetailVo, tbCfItemDetail); BeanUtils.copyProperties(tbCfItemDetailVo, tbCfItemDetail);
//将商品加入购物车表 //将商品加入购物车表
TbCfCartRecordREntity tbCfCartRecordREntity1 = tbCfCartRecordRDao.queryByItemId(tbCfItemDetailVo.getItemId()); TbCfCartRecordREntity tbCfCartRecordREntity1 = tbCfCartRecordRDao.queryByItemId(tbCfItemDetailVo.getItemId(),tbCfUserInfoVo.getUserId(),tbCfItemDetailVo.getItemSku());
if (tbCfCartRecordREntity1 == null) { if (tbCfCartRecordREntity1!=null) {
tbCfItemDetailDao.save(tbCfItemDetail);
TbCfCartRecordREntity tbCfCartRecordREntity = new TbCfCartRecordREntity(); TbCfCartRecordREntity tbCfCartRecordREntity = new TbCfCartRecordREntity();
tbCfCartRecordREntity.setCartRecordId(IdUtil.createIdbyUUID()); tbCfCartRecordREntity.setCartRecordId(tbCfCartRecordREntity1.getCartRecordId());
tbCfCartRecordREntity.setItemId(tbCfItemDetailVo.getItemId());
tbCfCartRecordREntity.setCheckFlag(StateConstant.VALID); tbCfCartRecordREntity.setCheckFlag(StateConstant.VALID);
tbCfCartRecordREntity.setEnableFlag(StateConstant.VALID); tbCfCartRecordREntity.setEnableFlag(StateConstant.VALID);
tbCfCartRecordREntity.setItemId(tbCfItemDetailVo.getItemId()); tbCfCartRecordREntity.setUserId(tbCfCartRecordREntity1.getUserId());
tbCfCartRecordREntity.setUserId(tbCfUserInfoVo.getUserId());
tbCfCartRecordREntity.setCreateTime(new Date()); tbCfCartRecordREntity.setCreateTime(new Date());
tbCfCartRecordREntity.setItemNum(tbCfItemDetailVo.getItemNum()); tbCfCartRecordREntity.setItemNum(tbCfItemDetailVo.getItemNum());
tbCfCartRecordREntity.setItemSku(tbCfItemDetailVo.getItemSku()); tbCfCartRecordRDao.update(tbCfCartRecordREntity);
tbCfCartRecordREntity.setSourceItemId(tbCfItemDetailVo.getSourceItemId());
tbCfCartRecordRDao.save(tbCfCartRecordREntity);
} else {
tbCfItemDetailDao.update(tbCfItemDetail); tbCfItemDetailDao.update(tbCfItemDetail);
} else {
tbCfItemDetailDao.save(tbCfItemDetail);
TbCfCartRecordREntity tbCfCartRecordREntity = new TbCfCartRecordREntity(); TbCfCartRecordREntity tbCfCartRecordREntity = new TbCfCartRecordREntity();
tbCfCartRecordREntity.setCartRecordId(tbCfCartRecordREntity1.getCartRecordId()); tbCfCartRecordREntity.setCartRecordId(IdUtil.createIdbyUUID());
tbCfCartRecordREntity.setItemId(tbCfItemDetailVo.getItemId());
tbCfCartRecordREntity.setCheckFlag(StateConstant.VALID); tbCfCartRecordREntity.setCheckFlag(StateConstant.VALID);
tbCfCartRecordREntity.setEnableFlag(StateConstant.VALID); tbCfCartRecordREntity.setEnableFlag(StateConstant.VALID);
tbCfCartRecordREntity.setItemId(tbCfItemDetailVo.getItemId());
tbCfCartRecordREntity.setUserId(tbCfUserInfoVo.getUserId()); tbCfCartRecordREntity.setUserId(tbCfUserInfoVo.getUserId());
tbCfCartRecordREntity.setCreateTime(new Date()); tbCfCartRecordREntity.setCreateTime(new Date());
tbCfCartRecordREntity.setItemNum(tbCfItemDetailVo.getItemNum()); tbCfCartRecordREntity.setItemNum(tbCfItemDetailVo.getItemNum());
tbCfCartRecordRDao.update(tbCfCartRecordREntity); tbCfCartRecordREntity.setItemSku(tbCfItemDetailVo.getItemSku());
tbCfCartRecordREntity.setSourceItemId(tbCfItemDetailVo.getSourceItemId());
tbCfCartRecordRDao.save(tbCfCartRecordREntity);
} }
return new Result(ResultCodeEnum.SUCCESS.getDesc()); return new Result(ResultCodeEnum.SUCCESS.getDesc());
} else { } else {
......
...@@ -459,6 +459,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService { ...@@ -459,6 +459,7 @@ public class TbCfOrderServiceImpl implements TbCfOrderService {
orderEntity.setDeliveryPhone(order.getDeliveryPhone()); orderEntity.setDeliveryPhone(order.getDeliveryPhone());
orderEntity.setDeliveryName(order.getDeliveryName()); orderEntity.setDeliveryName(order.getDeliveryName());
orderEntity.setDeliveryAddress(order.getDeliveryAddress()); orderEntity.setDeliveryAddress(order.getDeliveryAddress());
orderEntity.setRemarkInfo(order.getRemarkInfo());
orderEntity.setOrderNo(order.getOrderNo()); orderEntity.setOrderNo(order.getOrderNo());
orderEntity.setUserName(order.getUserName()); orderEntity.setUserName(order.getUserName());
//获取订单内商品 //获取订单内商品
......
...@@ -136,7 +136,7 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService { ...@@ -136,7 +136,7 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
emailTemplateBo.setNick(nick); emailTemplateBo.setNick(nick);
emailTemplateBo.setIdentifyCode(randomCode); emailTemplateBo.setIdentifyCode(randomCode);
Integer identifyCode = emailHelper.sendIdentifyEmail(email, EmailTemplateConstant.REGISTER, emailTemplateBo); Integer identifyCode = emailHelper.sendIdentifyEmail(email, EmailTemplateConstant.REGISTER, emailTemplateBo);
captchaRedisCache.set(KeyConstant.CAPTCHA + email, identifyCode, 1800); captchaRedisCache.set(KeyConstant.CAPTCHA + email, identifyCode, 100);
return identifyCode; return identifyCode;
} }
......
package com.diaoyun.zion.master.entity;
/**
* Dcloud 返回数据的实体类
*/
public class DcloudDto {
private String appid;
private String appname;
private String today_active_user_android;
private String today_active_user_ios;
private String today_active_user;
private String total_active_count_android;
private String total_active_count_ios;
private String total_active_count;
private String total_user_android;
private String total_user_ios;
private String total_user;
private String new_user_android;
private String new_user_ios;
private String new_user;
private String next_day_retention_android;
private String next_day_retention_ios;
private String next_day_retention;
private String week_retention_android;
private String week_retention_ios;
private String week_retention;
private String day;
public DcloudDto(String appid, String appname, String today_active_user_android, String today_active_user_ios, String today_active_user, String total_active_count_android, String total_active_count_ios, String total_active_count, String total_user_android, String total_user_ios, String total_user, String new_user_android, String new_user_ios, String new_user, String next_day_retention_android, String next_day_retention_ios, String next_day_retention, String week_retention_android, String week_retention_ios, String week_retention, String day) {
this.appid = appid;
this.appname = appname;
this.today_active_user_android = today_active_user_android;
this.today_active_user_ios = today_active_user_ios;
this.today_active_user = today_active_user;
this.total_active_count_android = total_active_count_android;
this.total_active_count_ios = total_active_count_ios;
this.total_active_count = total_active_count;
this.total_user_android = total_user_android;
this.total_user_ios = total_user_ios;
this.total_user = total_user;
this.new_user_android = new_user_android;
this.new_user_ios = new_user_ios;
this.new_user = new_user;
this.next_day_retention_android = next_day_retention_android;
this.next_day_retention_ios = next_day_retention_ios;
this.next_day_retention = next_day_retention;
this.week_retention_android = week_retention_android;
this.week_retention_ios = week_retention_ios;
this.week_retention = week_retention;
this.day = day;
}
public String getAppid() {
return appid;
}
public void setAppid(String appid) {
this.appid = appid;
}
public String getAppname() {
return appname;
}
public void setAppname(String appname) {
this.appname = appname;
}
public String getToday_active_user_android() {
return today_active_user_android;
}
public void setToday_active_user_android(String today_active_user_android) {
this.today_active_user_android = today_active_user_android;
}
public String getToday_active_user_ios() {
return today_active_user_ios;
}
public void setToday_active_user_ios(String today_active_user_ios) {
this.today_active_user_ios = today_active_user_ios;
}
public String getToday_active_user() {
return today_active_user;
}
public void setToday_active_user(String today_active_user) {
this.today_active_user = today_active_user;
}
public String getTotal_active_count_android() {
return total_active_count_android;
}
public void setTotal_active_count_android(String total_active_count_android) {
this.total_active_count_android = total_active_count_android;
}
public String getTotal_active_count_ios() {
return total_active_count_ios;
}
public void setTotal_active_count_ios(String total_active_count_ios) {
this.total_active_count_ios = total_active_count_ios;
}
public String getTotal_active_count() {
return total_active_count;
}
public void setTotal_active_count(String total_active_count) {
this.total_active_count = total_active_count;
}
public String getTotal_user_android() {
return total_user_android;
}
public void setTotal_user_android(String total_user_android) {
this.total_user_android = total_user_android;
}
public String getTotal_user_ios() {
return total_user_ios;
}
public void setTotal_user_ios(String total_user_ios) {
this.total_user_ios = total_user_ios;
}
public String getTotal_user() {
return total_user;
}
public void setTotal_user(String total_user) {
this.total_user = total_user;
}
public String getNew_user_android() {
return new_user_android;
}
public void setNew_user_android(String new_user_android) {
this.new_user_android = new_user_android;
}
public String getNew_user_ios() {
return new_user_ios;
}
public void setNew_user_ios(String new_user_ios) {
this.new_user_ios = new_user_ios;
}
public String getNew_user() {
return new_user;
}
public void setNew_user(String new_user) {
this.new_user = new_user;
}
public String getNext_day_retention_android() {
return next_day_retention_android;
}
public void setNext_day_retention_android(String next_day_retention_android) {
this.next_day_retention_android = next_day_retention_android;
}
public String getNext_day_retention_ios() {
return next_day_retention_ios;
}
public void setNext_day_retention_ios(String next_day_retention_ios) {
this.next_day_retention_ios = next_day_retention_ios;
}
public String getNext_day_retention() {
return next_day_retention;
}
public void setNext_day_retention(String next_day_retention) {
this.next_day_retention = next_day_retention;
}
public String getWeek_retention_android() {
return week_retention_android;
}
public void setWeek_retention_android(String week_retention_android) {
this.week_retention_android = week_retention_android;
}
public String getWeek_retention_ios() {
return week_retention_ios;
}
public void setWeek_retention_ios(String week_retention_ios) {
this.week_retention_ios = week_retention_ios;
}
public String getWeek_retention() {
return week_retention;
}
public void setWeek_retention(String week_retention) {
this.week_retention = week_retention;
}
public String getDay() {
return day;
}
public void setDay(String day) {
this.day = day;
}
}
...@@ -44,14 +44,13 @@ public class QuartzMethod { ...@@ -44,14 +44,13 @@ public class QuartzMethod {
* @throws IOException * @throws IOException
* @throws URISyntaxException * @throws URISyntaxException
*/ */
@Scheduled(cron = "0 0/2 * * * ? ") @Scheduled(cron = "0 0/3 * * * ? ")
public void getRent() throws IOException, URISyntaxException { public void getRent() throws IOException, URISyntaxException {
String content = HttpClientUtil.getContentByUrl("https://cn.valutafx.com/USD-ZMW.htm?amount=1", "rent"); String content = HttpClientUtil.getContentByUrl("https://cn.valutafx.com/USD-ZMW.htm?amount=1", "rent");
// 解析为 Document 对象 // 解析为 Document 对象
Document document = Jsoup.parse(content); Document document = Jsoup.parse(content);
String rent = document.select("div[class=rate-value]").text(); String rent = document.select("div[class=rate-value]").text();
BigDecimal rate=new BigDecimal(rent); BigDecimal rate=new BigDecimal(rent);
System.err.println(rate);
String type="USD-ZMW"; String type="USD-ZMW";
tbCfExchangeService.updateByType(type,rate); tbCfExchangeService.updateByType(type,rate);
} }
...@@ -68,7 +67,6 @@ public class QuartzMethod { ...@@ -68,7 +67,6 @@ public class QuartzMethod {
Document document = Jsoup.parse(content); Document document = Jsoup.parse(content);
String rent = document.select("div[class=rate-value]").text(); String rent = document.select("div[class=rate-value]").text();
BigDecimal rate=new BigDecimal(rent); BigDecimal rate=new BigDecimal(rent);
System.err.println(rate);
String type="USD-CNY"; String type="USD-CNY";
tbCfExchangeService.updateByType(type,rate); tbCfExchangeService.updateByType(type,rate);
} }
......
package com.diaoyun.zion.master.util;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.IOException;
import java.net.URISyntaxException;
public class RentUtil {
public static String getRent() throws IOException, URISyntaxException {
String content = HttpClientUtil.getContentByUrl("https://cn.valutafx.com/USD-ZMW.htm?amount=1", "rent");
// 解析为 Document 对象
Document document = Jsoup.parse(content);
String rent = document.select("div[class=rate-value]").text();
System.err.println(rent);
return rent;
}
}
package com.diaoyun.zion.master.util; package com.diaoyun.zion.master.util;
import com.diaoyun.zion.chinafrica.service.TbCfExchangeService;
import com.diaoyun.zion.chinafrica.service.TbCfFeeService; import com.diaoyun.zion.chinafrica.service.TbCfFeeService;
import com.diaoyun.zion.master.entity.DcloudDto;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import io.lettuce.core.ConnectionEvents;
import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URISyntaxException;
import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/** /**
...@@ -13,15 +20,17 @@ import java.util.regex.Pattern; ...@@ -13,15 +20,17 @@ import java.util.regex.Pattern;
public class SpiderUtil { public class SpiderUtil {
private static BigDecimal rate; private static BigDecimal rate;
private static final String DCLOUD_APPID = "H52FE1175";
static { static {
TbCfFeeService tbCfFeeService = (TbCfFeeService) SpringContextUtil.getBean("tbCfFeeService"); TbCfExchangeService tbCfExchangeService = (TbCfExchangeService) SpringContextUtil.getBean("tbCfExchangeService");
rate = tbCfFeeService.getRateFee().getFeeRate(); String exchangeCurrency="CNY";
rate = tbCfExchangeService.getRateFee(exchangeCurrency).getExchangeRate();
System.out.println(rate);
} }
/** /**
* 转换汇率--由人民币转换为美元 * 转换汇率--由人民币转换为美元
* TODO 同步汇率问题
* 注意:暂时从后台获取人工设置的汇率,还未是动态获取 * 注意:暂时从后台获取人工设置的汇率,还未是动态获取
* @param fullPrice 原始价格 * @param fullPrice 原始价格
* @return 汇率计算的价格 * @return 汇率计算的价格
...@@ -41,5 +50,25 @@ public class SpiderUtil { ...@@ -41,5 +50,25 @@ public class SpiderUtil {
return str; return str;
} }
/**
*
* @param appid
* @param start_date
* @param end_date
* @param item
* @param channel
* @return
*/
public static List<DcloudDto> spiderByDcloud(String appid, String start_date, String end_date, String item, String channel) throws IOException, URISyntaxException {
String targetUrl = "https://dev.dcloud.net.cn/statistics/fpat?appid="+ appid + "&start_date=" + start_date + "&end_date=" + end_date + "&item=" + item + "&channel=" + channel;
String content = HttpClientUtil.getContentByUrl(targetUrl, "Dcloud");
return null;
}
public static void main(String[] args) throws IOException, URISyntaxException {
String targetUrl = "https://dev.dcloud.net.cn/statistics/fpat?appid=H5014FF11&start_date=2019-12-31&end_date=2020-01-06&item=today_active_user&channel=";
String content = HttpClientUtil.getContentByUrl(targetUrl, "Dcloud");
System.out.println(content);
}
} }
...@@ -124,27 +124,47 @@ ...@@ -124,27 +124,47 @@
</delete> </delete>
<select id="querySkuAndUrl" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCartRecordREntity"> <select id="querySkuAndUrl" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCartRecordREntity">
select select
`cart_record_id`, `cart_record_id`,
`item_id`, `item_id`,
`user_id`, `user_id`,
`check_flag`, `check_flag`,
`enable_flag`, `enable_flag`,
`create_time`, `create_time`,
`source_item_id`, `source_item_id`,
`item_sku`, `item_sku`,
`item_num` `item_num`
from tb_cf_cart_record_r from tb_cf_cart_record_r
where item_sku =#{itemSku} and source_item_id=#{sourceItemId} and enable_flag=1 where 1=1
and user_id=#{userId}
and enable_flag=1
<if test="itemSku != null and itemSku.trim() != ''">
and item_sku =#{itemSku}
</if>
<if test="sourceItemId != null and sourceItemId.trim() != ''">
and source_item_id=#{sourceItemId}
</if>
<if test="itemId != null and itemId.trim() != ''">
and item_id=#{itemId}
</if>
</select> </select>
<select id="queryByItemId" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCartRecordREntity"> <select id="queryByItemId" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCartRecordREntity">
select `cart_record_id`, select `cart_record_id`,
`item_id`, `item_id`,
`user_id`, `user_id`,
`check_flag`, `check_flag`,
`enable_flag`, `enable_flag`,
`create_time`, `create_time`,
`source_item_id`, `source_item_id`,
`item_sku`, `item_sku`,
`item_num` from tb_cf_cart_record_r where item_id =#{itemId} and enable_flag=1 `item_num` from tb_cf_cart_record_r where 1=1
and enable_flag=1
and user_id=#{userId}
and item_id =#{itemId}
<if test="itemSku != null and itemSku.trim() != ''">
and item_sku =#{itemSku}
</if>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -113,4 +113,8 @@ ...@@ -113,4 +113,8 @@
<update id="updateByType"> <update id="updateByType">
update tb_cf_exchange set exchange_rate = #{rate} where type=#{type}; update tb_cf_exchange set exchange_rate = #{rate} where type=#{type};
</update> </update>
<select id="getRateFee" resultType="com.diaoyun.zion.chinafrica.entity.TbCfExchangeEntity">
select * from tb_cf_exchange where exchange_currency=#{exchangeCurrency}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -3,24 +3,24 @@ ...@@ -3,24 +3,24 @@
<mapper namespace="com.diaoyun.zion.chinafrica.dao.TbCfItemDetailDao"> <mapper namespace="com.diaoyun.zion.chinafrica.dao.TbCfItemDetailDao">
<resultMap type="com.diaoyun.zion.chinafrica.entity.TbCfItemDetailEntity" id="tbCfItemDetailMap"> <resultMap type="com.diaoyun.zion.chinafrica.entity.TbCfItemDetailEntity" id="tbCfItemDetailMap">
<result property="itemId" column="item_id"/> <result property="itemId" column="item_id"/>
<result property="sourceItemId" column="source_item_id"/> <result property="sourceItemId" column="source_item_id"/>
<result property="stationId" column="station_id"/> <result property="stationId" column="station_id"/>
<result property="stationType" column="station_type"/> <result property="stationType" column="station_type"/>
<result property="itemTitle" column="item_title"/> <result property="itemTitle" column="item_title"/>
<result property="itemNum" column="item_num"/> <result property="itemNum" column="item_num"/>
<result property="itemImg" column="item_img"/> <result property="itemImg" column="item_img"/>
<result property="itemPrice" column="item_price"/> <result property="itemPrice" column="item_price"/>
<result property="itemCategory" column="item_category"/> <result property="itemCategory" column="item_category"/>
<result property="itemSku" column="item_sku"/> <result property="itemSku" column="item_sku"/>
<result property="shopId" column="shop_id"/> <result property="shopId" column="shop_id"/>
<result property="shopName" column="shop_name"/> <result property="shopName" column="shop_name"/>
<result property="shopUrl" column="shop_url"/> <result property="shopUrl" column="shop_url"/>
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
</resultMap> </resultMap>
<select id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfItemDetailEntity"> <select id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfItemDetailEntity">
select select
`item_id`, `item_id`,
`source_item_id`, `source_item_id`,
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
from tb_cf_item_detail from tb_cf_item_detail
where item_id = #{id} where item_id = #{id}
</select> </select>
<select id="queryByTitle" resultType="com.diaoyun.zion.chinafrica.vo.TbCfItemDetailVo"> <select id="queryByTitle" resultType="com.diaoyun.zion.chinafrica.vo.TbCfItemDetailVo">
select select
`item_id`, `item_id`,
`source_item_id`, `source_item_id`,
...@@ -58,48 +58,48 @@ ...@@ -58,48 +58,48 @@
from tb_cf_item_detail from tb_cf_item_detail
where item_title = #{itemTitle} where item_title = #{itemTitle}
</select> </select>
<select id="queryList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfItemDetailEntity"> <select id="queryList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfItemDetailEntity">
select select
`item_id`, `item_id`,
`source_item_id`, `source_item_id`,
`station_id`, `station_id`,
`station_type`, `station_type`,
`item_title`, `item_title`,
`item_num`, `item_num`,
`item_img`, `item_img`,
`item_price`, `item_price`,
`item_category`, `item_category`,
`item_sku`, `item_sku`,
`shop_id`, `shop_id`,
`shop_name`, `shop_name`,
`shop_url`, `shop_url`,
`create_time` `create_time`
from tb_cf_item_detail from tb_cf_item_detail
WHERE 1=1 WHERE 1=1
<if test="name != null and name.trim() != ''"> <if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%') AND name LIKE concat('%',#{name},'%')
</if> </if>
<choose> <choose>
<when test="sidx != null and sidx.trim() != ''"> <when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order} order by ${sidx} ${order}
</when> </when>
<otherwise> <otherwise>
order by item_id desc order by item_id desc
</otherwise> </otherwise>
</choose> </choose>
<if test="offset != null and limit != null"> <if test="offset != null and limit != null">
limit #{offset}, #{limit} limit #{offset}, #{limit}
</if> </if>
</select> </select>
<select id="queryTotal" resultType="int"> <select id="queryTotal" resultType="int">
select count(*) from tb_cf_item_detail select count(*) from tb_cf_item_detail
WHERE 1=1 WHERE 1=1
<if test="name != null and name.trim() != ''"> <if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%') AND name LIKE concat('%',#{name},'%')
</if> </if>
</select> </select>
<insert id="save" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfItemDetailEntity"> <insert id="save" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfItemDetailEntity">
insert into tb_cf_item_detail( insert into tb_cf_item_detail(
`item_id`, `item_id`,
`source_item_id`, `source_item_id`,
...@@ -132,57 +132,71 @@ ...@@ -132,57 +132,71 @@
#{createTime}) #{createTime})
</insert> </insert>
<update id="update" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfItemDetailEntity"> <update id="update" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfItemDetailEntity">
update tb_cf_item_detail update tb_cf_item_detail
<set> <set>
<if test="sourceItemId != null">`source_item_id` = #{sourceItemId},</if> <if test="sourceItemId != null">`source_item_id` = #{sourceItemId}, </if>
<if test="stationId != null">`station_id` = #{stationId},</if> <if test="stationId != null">`station_id` = #{stationId}, </if>
<if test="stationType != null">`station_type` = #{stationType},</if> <if test="stationType != null">`station_type` = #{stationType}, </if>
<if test="itemTitle != null">`item_title` = #{itemTitle},</if> <if test="itemTitle != null">`item_title` = #{itemTitle}, </if>
<if test="itemNum != null">`item_num` = #{itemNum},</if> <if test="itemNum != null">`item_num` = #{itemNum}, </if>
<if test="itemImg != null">`item_img` = #{itemImg},</if> <if test="itemImg != null">`item_img` = #{itemImg}, </if>
<if test="itemPrice != null">`item_price` = #{itemPrice},</if> <if test="itemPrice != null">`item_price` = #{itemPrice}, </if>
<if test="itemCategory != null">`item_category` = #{itemCategory},</if> <if test="itemCategory != null">`item_category` = #{itemCategory}, </if>
<if test="itemSku != null">`item_sku` = #{itemSku},</if> <if test="itemSku != null">`item_sku` = #{itemSku}, </if>
<if test="shopId != null">`shop_id` = #{shopId},</if> <if test="shopId != null">`shop_id` = #{shopId}, </if>
<if test="shopName != null">`shop_name` = #{shopName},</if> <if test="shopName != null">`shop_name` = #{shopName}, </if>
<if test="shopUrl != null">`shop_url` = #{shopUrl},</if> <if test="shopUrl != null">`shop_url` = #{shopUrl},</if>
<if test="createTime != null">`create_time` = #{createTime}</if> <if test="createTime != null">`create_time` = #{createTime}</if>
</set> </set>
where item_id = #{itemId} where item_id = #{itemId} and item_sku=#{itemSku}
</update> </update>
<delete id="delete"> <delete id="delete">
delete from tb_cf_item_detail where item_id = #{value} delete from tb_cf_item_detail where item_id = #{value}
</delete> </delete>
<delete id="deleteBatch"> <delete id="deleteBatch">
delete from tb_cf_item_detail where item_id in delete from tb_cf_item_detail where item_id in
<foreach item="itemId" collection="array" open="(" separator="," close=")"> <foreach item="itemId" collection="array" open="(" separator="," close=")">
#{itemId} #{itemId}
</foreach> </foreach>
</delete> </delete>
<!--获取用户购物车内商品--> <!--获取用户购物车内商品-->
<select id="getCartItemList" resultType="com.diaoyun.zion.chinafrica.vo.TbCfCartItemDetailVo"> <select id="getCartItemList" resultType="com.diaoyun.zion.chinafrica.vo.TbCfCartItemDetailVo">
select t1.cart_record_id,t1.check_flag,t2.* from tb_cf_cart_record_r t1,tb_cf_item_detail t2 where select
t1.item_id=t2.item_id t1.cart_record_id,
and t1.user_id=#{userId} and t2.item_price is not null t1.check_flag,
<if test="checkFlag != null">and t1.check_flag = #{checkFlag}</if> t2.item_id,
and t1.enable_flag=1 order by t2.create_time desc t2.source_item_id,
</select> t2.station_id,
t2.station_type,
t2.item_title,
t2.item_num,
t2.item_img,
t2.item_price,
t2.item_category,
t2.item_sku,
t2.shop_id,
t2.shop_name,
t2.shop_url,
t2.create_time
from
tb_cf_cart_record_r t1 left join tb_cf_item_detail t2 on t1.item_id=t2.item_id and t1.item_sku=t2.item_sku
where 1=1
and t1.user_id=#{userId}
and t2.item_price is not null
and t1.enable_flag=1 order by t2.create_time desc
<if test="checkFlag != null"> and t1.check_flag = #{checkFlag}</if>
</select>
<!--改变购物车的商品勾选状态(旧版)--> <!--改变购物车的商品勾选状态-->
<update id="changeItemState"> <update id="changeItemState">
update tb_cf_cart_record_r set check_flag=#{checkFlag} where cart_record_id=#{cartRecordId} update tb_cf_cart_record_r set check_flag=#{checkFlag} where cart_record_id=#{cartRecordId}
</update> </update>
<!--改变购物车商品勾选状态(新版)--> <select id="queryItemNum" resultType="int">
<update id="changeState"> select count(*) from tb_cf_cart_record_r where 1=1 and user_id=#{userId} and enable_flag=1
update tb_cf_cart_record_r set check_flag=#{checkFlag} where cart_record_id in </select>
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper> </mapper>
\ No newline at end of file
...@@ -85,7 +85,8 @@ ...@@ -85,7 +85,8 @@
o.user_name, o.user_name,
o.delivery_address, o.delivery_address,
o.delivery_name, o.delivery_name,
o.delivery_phone o.delivery_phone,
o.remark_info
from tb_cf_order o left join tb_cf_item_order_r r on r.order_id=o.order_id from tb_cf_order o left join tb_cf_item_order_r r on r.order_id=o.order_id
where r.order_item_id = #{id} where r.order_item_id = #{id}
</select> </select>
......
package com.diaoyun.zion; package com.diaoyun.zion;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.spec.InvalidKeySpecException;
import java.util.Properties; import java.util.Properties;
import javax.crypto.*;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.DESedeKeySpec;
import javax.mail.Address; import javax.mail.Address;
import javax.mail.Message; import javax.mail.Message;
import javax.mail.MessagingException; import javax.mail.MessagingException;
...@@ -10,9 +20,20 @@ import javax.mail.Transport; ...@@ -10,9 +20,20 @@ import javax.mail.Transport;
import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage;
import com.diaoyun.zion.master.util.HttpClientUtil;
import com.egzosn.pay.common.util.sign.encrypt.Base64;
import com.sun.mail.util.MailSSLSocketFactory; import com.sun.mail.util.MailSSLSocketFactory;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class Test { public class Test {
// 向量
private final static String DES = "DES";
public final static String KEY = "111111111111111111111111111111111111111";
public final static String encode="UTF-8";
/** /**
/**
* @Title: sendEmail * @Title: sendEmail
* @Description: 发送邮件工具类方法 * @Description: 发送邮件工具类方法
* @param sendEmail * @param sendEmail
...@@ -97,18 +118,102 @@ public class Test { ...@@ -97,18 +118,102 @@ public class Test {
* @throws Exception * @throws Exception
* @return: void * @return: void
*/ */
public static void main(String[] args) throws Exception { /**
/** * @param sendEmail 发件人地址
* @param sendEmail 发件人地址 * @param sendEmailPwd
* @param sendEmailPwd * 授权码代替密码(更安全)
* 授权码代替密码(更安全) * @param title
* @param title * 邮件标题
* 邮件标题 * @param content
* @param content * 邮件内容
* 邮件内容 * @param toEmilAddress
* @param toEmilAddress * 收件人地址
* 收件人地址 */
*/ // Test.sendEmail("1203063316@qq.com", "mkwugpvzbafpjfdc", "testEmail", "testcontent",new String[]{"pure091529@163.com"});
Test.sendEmail("1203063316@qq.com", "mkwugpvzbafpjfdc", "testEmail", "testcontent",new String[]{"pure091529@163.com"}); /* String targetUrl = "https://dev.dcloud.net.cn/statistics/fpat?appid=H5014FF11&start_date=2019-12-31&end_date=2020-01-06&item=today_active_user&channel=";
String content = HttpClientUtil.getContentByUrl(targetUrl, "Dcloud");
System.out.println(content);*/
/**
     * Description 根据键值进行加密
     * @param data
     * @param key  加密键byte数组
     * @return
     * @throws Exception
     */
public static String encrypt(String data, String key) throws Exception {
byte[] bt = encrypt(data.getBytes(), key.getBytes());
String strs = new BASE64Encoder().encode(bt);
return strs;
}
/**
     * Description 根据键值进行解密
     * @param data
     * @param key  加密键byte数组
     * @return
     * @throws IOException
     * @throws Exception
     */
public static String decrypt(String data, String key) throws IOException,
Exception {
if (data == null)
return null;
BASE64Decoder decoder = new BASE64Decoder();
byte[] buf = decoder.decodeBuffer(data);
byte[] bt = decrypt(buf,key.getBytes());
return new String(bt);
}
/**
     * Description 根据键值进行加密
     * @param data
     * @param key  加密键byte数组
     * @return
     * @throws Exception
     */
private static byte[] encrypt(byte[] data, byte[] key) throws Exception {
// 生成一个可信任的随机数源
SecureRandom sr = new SecureRandom();
// 从原始密钥数据创建DESKeySpec对象
DESKeySpec dks = new DESKeySpec(key);
// 创建一个密钥工厂,然后用它把DESKeySpec转换成SecretKey对象
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(DES);
SecretKey securekey = keyFactory.generateSecret(dks);
// Cipher对象实际完成加密操作
Cipher cipher = Cipher.getInstance(DES);
// 用密钥初始化Cipher对象
cipher.init(Cipher.ENCRYPT_MODE, securekey, sr);
return cipher.doFinal(data);
}
/**
     * Description 根据键值进行解密
     * @param data
     * @param key  加密键byte数组
     * @return
     * @throws Exception
     */
private static byte[] decrypt(byte[] data, byte[] key) throws Exception {
// 生成一个可信任的随机数源
SecureRandom sr = new SecureRandom();
// 从原始密钥数据创建DESKeySpec对象
DESKeySpec dks = new DESKeySpec(key);
// 创建一个密钥工厂,然后用它把DESKeySpec转换成SecretKey对象
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(DES);
SecretKey securekey = keyFactory.generateSecret(dks);
// Cipher对象实际完成解密操作
Cipher cipher = Cipher.getInstance(DES);
// 用密钥初始化Cipher对象
cipher.init(Cipher.DECRYPT_MODE, securekey, sr);
return cipher.doFinal(data);
}
public static void main(String[] args)throws Exception{
//加密
System.out.println( Test.encrypt("12", Test.KEY));
//解密
System.out.println( Test.decrypt("XX2s27k8G6Q=", Test.KEY));
} }
} }
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论