| @@ -1,9 +1,9 @@ | |||||
| package com.iformall.schedule; | package com.iformall.schedule; | ||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.iformall.domain.po.WxMall; | |||||
| import com.iformall.domain.po.WxWiWideInfo; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.WxMallMapper; | |||||
| import com.iformall.mapper.WxWiwideInfoMapper; | |||||
| import com.iformall.utils.WiwideUtil; | import com.iformall.utils.WiwideUtil; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| @@ -23,31 +23,31 @@ public class WiwideTokenSchedule { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | @Autowired | ||||
| private WxMallMapper wxMallMapper; | |||||
| private WxWiwideInfoMapper wxWiwideInfoMapper; | |||||
| @Scheduled(cron = "0 0/45 * * * ?") | @Scheduled(cron = "0 0/45 * * * ?") | ||||
| public void requestToken() { | public void requestToken() { | ||||
| List<WxMall> list = wxMallMapper.findList(null); | |||||
| List<WxWiWideInfo> list = wxWiwideInfoMapper.findList(null); | |||||
| for (int i = 0, size = list.size(); i < size; i++) { | for (int i = 0, size = list.size(); i < size; i++) { | ||||
| WxMall wxMall = list.get(i); | |||||
| String data = WiwideUtil.queryToken(wxMall); | |||||
| WxWiWideInfo wxWiWideInfo = list.get(i); | |||||
| String data = WiwideUtil.queryToken(wxWiWideInfo); | |||||
| String token = (String) JSONObject.parseObject(data).get("data"); | String token = (String) JSONObject.parseObject(data).get("data"); | ||||
| updateToken(wxMall, token); | |||||
| updateToken(wxWiWideInfo, token); | |||||
| } | } | ||||
| } | } | ||||
| private void updateToken(WxMall wxMall, String token) { | |||||
| private void updateToken(WxWiWideInfo wxWiWideInfo, String token) { | |||||
| Calendar instance = Calendar.getInstance(); | Calendar instance = Calendar.getInstance(); | ||||
| instance.add(Calendar.MINUTE, 45); | instance.add(Calendar.MINUTE, 45); | ||||
| WxMall record = new WxMall(); | |||||
| record.setId(wxMall.getId()); | |||||
| WxWiWideInfo record = new WxWiWideInfo(); | |||||
| record.setId(wxWiWideInfo.getId()); | |||||
| record.setToken(token); | record.setToken(token); | ||||
| record.setExpiredTime(instance.getTime()); | record.setExpiredTime(instance.getTime()); | ||||
| try { | try { | ||||
| wxMallMapper.updateToken(record); | |||||
| wxWiwideInfoMapper.updateToken(record); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.info("更新TOKEN失败:商场" + wxMall.getName()); | |||||
| logger.info("更新TOKEN失败:商场" + wxWiWideInfo.getTenantId()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -63,9 +63,6 @@ public class WxMall implements Serializable { | |||||
| /*地址**/ | /*地址**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="地址",name="addr") | @io.swagger.annotations.ApiModelProperty(value="地址",name="addr") | ||||
| private String addr; | private String addr; | ||||
| /*迈外迪id**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="迈外迪id",name="wiwideId") | |||||
| private String wiwideId; | |||||
| /*总面积**/ | /*总面积**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="总面积",name="totalArea") | @io.swagger.annotations.ApiModelProperty(value="总面积",name="totalArea") | ||||
| private BigDecimal totalArea; | private BigDecimal totalArea; | ||||
| @@ -78,9 +75,6 @@ public class WxMall implements Serializable { | |||||
| /*车位数**/ | /*车位数**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="车位数",name="parkPlaceNumber") | @io.swagger.annotations.ApiModelProperty(value="车位数",name="parkPlaceNumber") | ||||
| private Integer parkPlaceNumber; | private Integer parkPlaceNumber; | ||||
| /*支付ID,参看wx_pay_account**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="支付ID,参看wx_pay_account",name="payId") | |||||
| private Long payId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="电话",name="servicePhone") | @io.swagger.annotations.ApiModelProperty(value="电话",name="servicePhone") | ||||
| private String servicePhone; | private String servicePhone; | ||||
| @io.swagger.annotations.ApiModelProperty(value="商场图标",name="imgUrl") | @io.swagger.annotations.ApiModelProperty(value="商场图标",name="imgUrl") | ||||
| @@ -88,22 +82,9 @@ public class WxMall implements Serializable { | |||||
| @io.swagger.annotations.ApiModelProperty(value="商场图标",name="imgUrlH") | @io.swagger.annotations.ApiModelProperty(value="商场图标",name="imgUrlH") | ||||
| private String imgUrlH; | private String imgUrlH; | ||||
| @io.swagger.annotations.ApiModelProperty(value="迈外迪key",name="wiwideKey") | |||||
| private String wiwideKey; | |||||
| @io.swagger.annotations.ApiModelProperty(value="迈外迪url",name="wiwideUrl") | |||||
| private String wiwideUrl; | |||||
| @io.swagger.annotations.ApiModelProperty(value="小程序提示",name="weapNote") | @io.swagger.annotations.ApiModelProperty(value="小程序提示",name="weapNote") | ||||
| private String weapNote; | private String weapNote; | ||||
| @io.swagger.annotations.ApiModelProperty(value="token",name="token") | |||||
| private String token; | |||||
| @io.swagger.annotations.ApiModelProperty(value="expiredTime",name="expiredTime") | |||||
| private Date expiredTime; | |||||
| public String getTenantId() { | public String getTenantId() { | ||||
| return tenantId; | return tenantId; | ||||
| } | } | ||||
| @@ -146,12 +127,6 @@ public class WxMall implements Serializable { | |||||
| public void setAddr(String _addr) { | public void setAddr(String _addr) { | ||||
| addr = _addr; | addr = _addr; | ||||
| } | } | ||||
| public String getWiwideId() { | |||||
| return wiwideId; | |||||
| } | |||||
| public void setWiwideId(String _wiwideId) { | |||||
| wiwideId = _wiwideId; | |||||
| } | |||||
| public BigDecimal getTotalArea() { | public BigDecimal getTotalArea() { | ||||
| return totalArea; | return totalArea; | ||||
| } | } | ||||
| @@ -176,12 +151,6 @@ public class WxMall implements Serializable { | |||||
| public void setParkPlaceNumber(Integer _parkPlaceNumber) { | public void setParkPlaceNumber(Integer _parkPlaceNumber) { | ||||
| parkPlaceNumber = _parkPlaceNumber; | parkPlaceNumber = _parkPlaceNumber; | ||||
| } | } | ||||
| public Long getPayId() { | |||||
| return payId; | |||||
| } | |||||
| public void setPayId(Long _payId) { | |||||
| payId = _payId; | |||||
| } | |||||
| public String getServicePhone() { | public String getServicePhone() { | ||||
| return servicePhone; | return servicePhone; | ||||
| @@ -207,22 +176,6 @@ public class WxMall implements Serializable { | |||||
| this.imgUrlH = imgUrlH; | this.imgUrlH = imgUrlH; | ||||
| } | } | ||||
| public String getWiwideKey() { | |||||
| return wiwideKey; | |||||
| } | |||||
| public void setWiwideKey(String wiwideKey) { | |||||
| this.wiwideKey = wiwideKey; | |||||
| } | |||||
| public String getWiwideUrl() { | |||||
| return wiwideUrl; | |||||
| } | |||||
| public void setWiwideUrl(String wiwideUrl) { | |||||
| this.wiwideUrl = wiwideUrl; | |||||
| } | |||||
| public String getWeapNote() { | public String getWeapNote() { | ||||
| return weapNote; | return weapNote; | ||||
| } | } | ||||
| @@ -231,22 +184,6 @@ public class WxMall implements Serializable { | |||||
| this.weapNote = weapNote; | this.weapNote = weapNote; | ||||
| } | } | ||||
| public String getToken() { | |||||
| return token; | |||||
| } | |||||
| public void setToken(String token) { | |||||
| this.token = token; | |||||
| } | |||||
| public Date getExpiredTime() { | |||||
| return expiredTime; | |||||
| } | |||||
| public void setExpiredTime(Date expiredTime) { | |||||
| this.expiredTime = expiredTime; | |||||
| } | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | ||||
| @@ -257,12 +194,10 @@ public class WxMall implements Serializable { | |||||
| ,Province_ASC("`province` ASC"),Province_DESC("`province` DESC") | ,Province_ASC("`province` ASC"),Province_DESC("`province` DESC") | ||||
| ,City_ASC("`city` ASC"),City_DESC("`city` DESC") | ,City_ASC("`city` ASC"),City_DESC("`city` DESC") | ||||
| ,Addr_ASC("`addr` ASC"),Addr_DESC("`addr` DESC") | ,Addr_ASC("`addr` ASC"),Addr_DESC("`addr` DESC") | ||||
| ,WiwideId_ASC("`wiwide_id` ASC"),WiwideId_DESC("`wiwide_id` DESC") | |||||
| ,TotalArea_ASC("`total_area` ASC"),TotalArea_DESC("`total_area` DESC") | ,TotalArea_ASC("`total_area` ASC"),TotalArea_DESC("`total_area` DESC") | ||||
| ,OperatingArea_ASC("`operating_area` ASC"),OperatingArea_DESC("`operating_area` DESC") | ,OperatingArea_ASC("`operating_area` ASC"),OperatingArea_DESC("`operating_area` DESC") | ||||
| ,ParkArea_ASC("`parkArea` ASC"),ParkArea_DESC("`parkArea` DESC") | ,ParkArea_ASC("`parkArea` ASC"),ParkArea_DESC("`parkArea` DESC") | ||||
| ,ParkPlaceNumber_ASC("`park_place_number` ASC"),ParkPlaceNumber_DESC("`park_place_number` DESC") | ,ParkPlaceNumber_ASC("`park_place_number` ASC"),ParkPlaceNumber_DESC("`park_place_number` DESC") | ||||
| ,PayId_ASC("`pay_id` ASC"),PayId_DESC("`pay_id` DESC") | |||||
| ,ServicePhone_ASC("`service_phone` ASC"),ServicePhone_DESC("`service_phone` DESC") | ,ServicePhone_ASC("`service_phone` ASC"),ServicePhone_DESC("`service_phone` DESC") | ||||
| ,ImgUrl_ASC("`img_url` ASC"),ImgUrl_DESC("`img_url` DESC") | ,ImgUrl_ASC("`img_url` ASC"),ImgUrl_DESC("`img_url` DESC") | ||||
| ,ImgUrlH_ASC("`img_url_h` ASC"),ImgUrlH_DESC("`img_url_h` DESC") | ,ImgUrlH_ASC("`img_url_h` ASC"),ImgUrlH_DESC("`img_url_h` DESC") | ||||
| @@ -0,0 +1,165 @@ | |||||
| package com.iformall.domain.po; | |||||
| import javax.persistence.Id; | |||||
| import javax.persistence.Table; | |||||
| import javax.persistence.Transient; | |||||
| import java.io.Serializable; | |||||
| import java.math.BigDecimal; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @Table(name = "wx_wiwide_info") | |||||
| public class WxWiWideInfo implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | |||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| @Transient | |||||
| protected String sortColumns; | |||||
| public Long getId() { | |||||
| return id; | |||||
| } | |||||
| public void setId(Long id) { | |||||
| this.id = id; | |||||
| } | |||||
| public String getSortColumns() { | |||||
| return sortColumns; | |||||
| } | |||||
| public List<Long> getIds() { | |||||
| return ids; | |||||
| } | |||||
| public void setIds(List<Long> ids) { | |||||
| this.ids = ids; | |||||
| } | |||||
| /**租户ID**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||||
| private String tenantId; | |||||
| /**迈外迪id**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="迈外迪id",name="wiwideId") | |||||
| private String wiwideId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="迈外迪key",name="wiwideKey") | |||||
| private String wiwideKey; | |||||
| @io.swagger.annotations.ApiModelProperty(value="迈外迪url",name="wiwideUrl") | |||||
| private String wiwideUrl; | |||||
| @io.swagger.annotations.ApiModelProperty(value="token",name="token") | |||||
| private String token; | |||||
| @io.swagger.annotations.ApiModelProperty(value="expiredTime",name="expiredTime") | |||||
| private Date expiredTime; | |||||
| public String getTenantId() { | |||||
| return tenantId; | |||||
| } | |||||
| public void setTenantId(String _tenantId) { | |||||
| tenantId = _tenantId; | |||||
| } | |||||
| public String getWiwideId() { | |||||
| return wiwideId; | |||||
| } | |||||
| public void setWiwideId(String _wiwideId) { | |||||
| wiwideId = _wiwideId; | |||||
| } | |||||
| public String getWiwideKey() { | |||||
| return wiwideKey; | |||||
| } | |||||
| public void setWiwideKey(String wiwideKey) { | |||||
| this.wiwideKey = wiwideKey; | |||||
| } | |||||
| public String getWiwideUrl() { | |||||
| return wiwideUrl; | |||||
| } | |||||
| public void setWiwideUrl(String wiwideUrl) { | |||||
| this.wiwideUrl = wiwideUrl; | |||||
| } | |||||
| public String getToken() { | |||||
| return token; | |||||
| } | |||||
| public void setToken(String token) { | |||||
| this.token = token; | |||||
| } | |||||
| public Date getExpiredTime() { | |||||
| return expiredTime; | |||||
| } | |||||
| public void setExpiredTime(Date expiredTime) { | |||||
| this.expiredTime = expiredTime; | |||||
| } | |||||
| public static enum Field | |||||
| { | |||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||||
| ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") | |||||
| ,WiwideId_ASC("`wiwide_id` ASC"),WiwideId_DESC("`wiwide_id` DESC") | |||||
| ; | |||||
| private String value; | |||||
| Field(String value){ | |||||
| this.value = value; | |||||
| } | |||||
| public String getValue() { | |||||
| return value; | |||||
| } | |||||
| public void setCol(String value) { | |||||
| this.value = value; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return this.getValue(); | |||||
| } | |||||
| } | |||||
| public void setSortColumns(WxWiWideInfo.Field... fields) | |||||
| { | |||||
| if (fields == null || fields.length == 0) { | |||||
| return; | |||||
| } | |||||
| for (int k = 0; k < fields.length; k++) { | |||||
| if (fields[k] == null) { | |||||
| return; | |||||
| } | |||||
| } | |||||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||||
| for (int k = 1; k < fields.length; k++) { | |||||
| sb.append(","); | |||||
| sb.append(fields[k].toString()); | |||||
| } | |||||
| this.sortColumns = sb.toString(); | |||||
| } | |||||
| public void setSortColumns(String sortColumns) | |||||
| { | |||||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||||
| return; | |||||
| } | |||||
| if (sortColumns.contains(",")) { | |||||
| String[] cols = sortColumns.split(","); | |||||
| List<Field> fList = new java.util.ArrayList(); | |||||
| for (int k = 0; k < cols.length; k++) { | |||||
| fList.add(Field.valueOf(cols[k])); | |||||
| } | |||||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||||
| } else { | |||||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,15 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxWiWideInfo; | |||||
| import java.util.List; | |||||
| public interface WxWiwideInfoMapper extends CommonMapper<WxWiWideInfo, Long> { | |||||
| List<WxWiWideInfo> findList(WxWiWideInfo wxWiWideInfo); | |||||
| void updateToken(WxWiWideInfo wxWiWideInfo); | |||||
| } | |||||
| @@ -9,13 +9,9 @@ import com.iformall.enums.*; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.DataTowerService; | import com.iformall.service.DataTowerService; | ||||
| import com.iformall.service.WxRentContractService; | |||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| import com.iformall.utils.HashUtil; | |||||
| import com.iformall.utils.HttpUtil; | |||||
| import com.iformall.utils.WiwideUtil; | import com.iformall.utils.WiwideUtil; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.apache.shiro.codec.Base64; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -47,7 +43,7 @@ public class DataTowerServiceImpl implements DataTowerService { | |||||
| WxCarCmdLogMapper wxCarCmdLogMapper; | WxCarCmdLogMapper wxCarCmdLogMapper; | ||||
| @Autowired | @Autowired | ||||
| WxMallMapper wxMallMapper; | |||||
| WxWiwideInfoMapper wxWiwideInfoMapper; | |||||
| @Autowired | @Autowired | ||||
| WxBillRentMapper wxBillRentMapper; | WxBillRentMapper wxBillRentMapper; | ||||
| @@ -622,41 +618,41 @@ public class DataTowerServiceImpl implements DataTowerService { | |||||
| public Map<String, Object> queryCustomer(String tenantId) { | public Map<String, Object> queryCustomer(String tenantId) { | ||||
| WxMall wxMall = new WxMall(); | |||||
| wxMall.setTenantId(tenantId); | |||||
| List<WxMall> list = wxMallMapper.findList(wxMall); | |||||
| wxMall = list.get(0); | |||||
| String wiwideUrl = wxMall.getWiwideUrl(); | |||||
| WxWiWideInfo wiWideInfo = new WxWiWideInfo(); | |||||
| wiWideInfo.setTenantId(tenantId); | |||||
| List<WxWiWideInfo> list = wxWiwideInfoMapper.findList(wiWideInfo); | |||||
| wiWideInfo = list.get(0); | |||||
| String wiwideUrl = wiWideInfo.getWiwideUrl(); | |||||
| Map<String, Object> datamap = new HashMap<>(2); | Map<String, Object> datamap = new HashMap<>(2); | ||||
| datamap.put("token", getWiwideToken(wxMall)); | |||||
| datamap.put("token", getWiwideToken(wiWideInfo)); | |||||
| datamap.put("url", wiwideUrl); | datamap.put("url", wiwideUrl); | ||||
| return datamap; | return datamap; | ||||
| } | } | ||||
| private void updateToken(WxMall wxMall, String token) { | |||||
| private void updateToken(WxWiWideInfo wiWideInfo, String token) { | |||||
| Calendar instance = Calendar.getInstance(); | Calendar instance = Calendar.getInstance(); | ||||
| instance.add(Calendar.MINUTE, 45); | instance.add(Calendar.MINUTE, 45); | ||||
| WxMall record = new WxMall(); | |||||
| record.setId(wxMall.getId()); | |||||
| WxWiWideInfo record = new WxWiWideInfo(); | |||||
| record.setId(wiWideInfo.getId()); | |||||
| record.setToken(token); | record.setToken(token); | ||||
| record.setExpiredTime(instance.getTime()); | record.setExpiredTime(instance.getTime()); | ||||
| try { | try { | ||||
| wxMallMapper.updateToken(record); | |||||
| wxWiwideInfoMapper.updateToken(record); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.info("更新TOKEN失败:商场" + wxMall.getName()); | |||||
| logger.info("更新TOKEN失败:商场" + wiWideInfo.getTenantId()); | |||||
| } | } | ||||
| } | } | ||||
| private String getWiwideToken(WxMall wxMall) { | |||||
| Date expiredTime = wxMall.getExpiredTime(); | |||||
| String token = wxMall.getToken(); | |||||
| private String getWiwideToken(WxWiWideInfo wiWideInfo) { | |||||
| Date expiredTime = wiWideInfo.getExpiredTime(); | |||||
| String token = wiWideInfo.getToken(); | |||||
| if (StringUtils.isEmpty(token) || expiredTime == null || expiredTime.before(new Date())) { | if (StringUtils.isEmpty(token) || expiredTime == null || expiredTime.before(new Date())) { | ||||
| String data = WiwideUtil.queryToken(wxMall); | |||||
| String data = WiwideUtil.queryToken(wiWideInfo); | |||||
| token = (String) JSONObject.parseObject(data).get("data"); | token = (String) JSONObject.parseObject(data).get("data"); | ||||
| updateToken(wxMall, token); | |||||
| updateToken(wiWideInfo, token); | |||||
| } | } | ||||
| return token; | return token; | ||||
| } | } | ||||
| @@ -664,14 +660,14 @@ public class DataTowerServiceImpl implements DataTowerService { | |||||
| @Override | @Override | ||||
| public ResultData queryCustomerData(String tenantId, Map<String, String> params) { | public ResultData queryCustomerData(String tenantId, Map<String, String> params) { | ||||
| WxMall wxMall = new WxMall(); | |||||
| wxMall.setTenantId(tenantId); | |||||
| List<WxMall> list = wxMallMapper.findList(wxMall); | |||||
| wxMall = list.get(0); | |||||
| if (wxMall == null) | |||||
| WxWiWideInfo wiWideInfo = new WxWiWideInfo(); | |||||
| wiWideInfo.setTenantId(tenantId); | |||||
| List<WxWiWideInfo> list = wxWiwideInfoMapper.findList(wiWideInfo); | |||||
| wiWideInfo = list.get(0); | |||||
| if (wiWideInfo == null) | |||||
| return new ResultData(ErrorCode.MALL_INFO_NOT_FOUND); | return new ResultData(ErrorCode.MALL_INFO_NOT_FOUND); | ||||
| String res = WiwideUtil.queryData(wxMall, getWiwideToken(wxMall), params); | |||||
| String res = WiwideUtil.queryData(wiWideInfo, getWiwideToken(wiWideInfo), params); | |||||
| JSONObject result = JSONObject.parseObject(res); | JSONObject result = JSONObject.parseObject(res); | ||||
| @@ -3,6 +3,7 @@ package com.iformall.utils; | |||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.domain.po.WxMall; | import com.iformall.domain.po.WxMall; | ||||
| import com.iformall.domain.po.WxWiWideInfo; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import org.apache.shiro.codec.Base64; | import org.apache.shiro.codec.Base64; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -130,22 +131,22 @@ public class WiwideUtil { | |||||
| } | } | ||||
| public static String queryToken(WxMall wxMall) { | |||||
| public static String queryToken(WxWiWideInfo wiWideInfo) { | |||||
| logger.info("获取TOKEN"); | logger.info("获取TOKEN"); | ||||
| String username = wxMall.getWiwideId(); | |||||
| String authVal = WiwideUtil.encrypt(wxMall.getWiwideKey()); | |||||
| String username = wiWideInfo.getWiwideId(); | |||||
| String authVal = WiwideUtil.encrypt(wiWideInfo.getWiwideKey()); | |||||
| Map<String, String> params = new HashMap<>(); | Map<String, String> params = new HashMap<>(); | ||||
| params.put("username", username); | params.put("username", username); | ||||
| params.put("authVal", authVal); | params.put("authVal", authVal); | ||||
| String wiwideUrl = wxMall.getWiwideUrl(); | |||||
| String wiwideUrl = wiWideInfo.getWiwideUrl(); | |||||
| String token = HttpUtil.doPost(wiwideUrl + "/login/auth", params); | String token = HttpUtil.doPost(wiwideUrl + "/login/auth", params); | ||||
| logger.info("商场:" + wxMall.getName() + ",返回TOKEN" + token); | |||||
| logger.info("商场:" + wiWideInfo.getTenantId() + ",返回TOKEN" + token); | |||||
| return token; | return token; | ||||
| } | } | ||||
| public static String queryData(WxMall wxMall, String token, Map<String, String> params) { | |||||
| public static String queryData(WxWiWideInfo wiWideInfo, String token, Map<String, String> params) { | |||||
| String data = HttpUtil.doPostWiwide(wxMall.getWiwideUrl() + "/reports/data", token, params); | |||||
| String data = HttpUtil.doPostWiwide(wiWideInfo.getWiwideUrl() + "/reports/data", token, params); | |||||
| return data; | return data; | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,139 +1,110 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||||
| <mapper namespace="com.iformall.mapper.WxMallMapper"> | <mapper namespace="com.iformall.mapper.WxMallMapper"> | ||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxMall"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="name" jdbcType="VARCHAR" property="name" /> | |||||
| <result column="group" jdbcType="VARCHAR" property="group" /> | |||||
| <result column="country" jdbcType="VARCHAR" property="country" /> | |||||
| <result column="province" jdbcType="VARCHAR" property="province" /> | |||||
| <result column="city" jdbcType="VARCHAR" property="city" /> | |||||
| <result column="addr" jdbcType="VARCHAR" property="addr" /> | |||||
| <result column="wiwide_id" jdbcType="VARCHAR" property="wiwideId" /> | |||||
| <result column="total_area" jdbcType="DECIMAL" property="totalArea" /> | |||||
| <result column="operating_area" jdbcType="DECIMAL" property="operatingArea" /> | |||||
| <result column="park_area" jdbcType="DECIMAL" property="parkArea" /> | |||||
| <result column="park_place_number" jdbcType="INTEGER" property="parkPlaceNumber" /> | |||||
| <result column="pay_id" jdbcType="BIGINT" property="payId" /> | |||||
| <result column="service_phone" jdbcType="VARCHAR" property="servicePhone" /> | |||||
| <result column="img_url" jdbcType="VARCHAR" property="imgUrl" /> | |||||
| <result column="img_url_h" jdbcType="VARCHAR" property="imgUrlH" /> | |||||
| <result column="wiwide_key" jdbcType="VARCHAR" property="wiwideKey" /> | |||||
| <result column="wiwide_url" jdbcType="VARCHAR" property="wiwideUrl" /> | |||||
| <result column="weap_note" jdbcType="VARCHAR" property="weapNote" /> | |||||
| <result column="token" jdbcType="VARCHAR" property="token" /> | |||||
| <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`name`,`group`,`country`,`province`,`city`,`addr`,`wiwide_id`, | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxMall"> | |||||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||||
| <result column="name" jdbcType="VARCHAR" property="name"/> | |||||
| <result column="group" jdbcType="VARCHAR" property="group"/> | |||||
| <result column="country" jdbcType="VARCHAR" property="country"/> | |||||
| <result column="province" jdbcType="VARCHAR" property="province"/> | |||||
| <result column="city" jdbcType="VARCHAR" property="city"/> | |||||
| <result column="addr" jdbcType="VARCHAR" property="addr"/> | |||||
| <result column="total_area" jdbcType="DECIMAL" property="totalArea"/> | |||||
| <result column="operating_area" jdbcType="DECIMAL" property="operatingArea"/> | |||||
| <result column="park_area" jdbcType="DECIMAL" property="parkArea"/> | |||||
| <result column="park_place_number" jdbcType="INTEGER" property="parkPlaceNumber"/> | |||||
| <result column="service_phone" jdbcType="VARCHAR" property="servicePhone"/> | |||||
| <result column="img_url" jdbcType="VARCHAR" property="imgUrl"/> | |||||
| <result column="img_url_h" jdbcType="VARCHAR" property="imgUrlH"/> | |||||
| <result column="weap_note" jdbcType="VARCHAR" property="weapNote"/> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`name`,`group`,`country`,`province`,`city`,`addr`, | |||||
| `total_area`,`operating_area`,`park_area`,`park_place_number`,`pay_id`,`service_phone`, | `total_area`,`operating_area`,`park_area`,`park_place_number`,`pay_id`,`service_phone`, | ||||
| `img_url`,`img_url_h`,`wiwide_key`,`wiwide_url`, `weap_note`,`token`,`expired_time` | |||||
| `img_url`,`img_url_h`, `weap_note` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != name "> | |||||
| and `name` like concat('%', #{name},'%') | |||||
| </if> | |||||
| <if test=" null != group "> | |||||
| and `group` like concat('%', #{group},'%') | |||||
| </if> | |||||
| <if test=" null != country "> | |||||
| and `country` like concat('%', #{country},'%') | |||||
| </if> | |||||
| <if test=" null != province "> | |||||
| and `province` like concat('%', #{province},'%') | |||||
| </if> | |||||
| <if test=" null != city "> | |||||
| and `city` like concat('%', #{city},'%') | |||||
| </if> | |||||
| <if test=" null != addr "> | |||||
| and `addr` like concat('%', #{addr},'%') | |||||
| </if> | |||||
| <if test=" null != wiwideId "> | |||||
| and `wiwide_id` like concat('%', #{wiwideId},'%') | |||||
| </if> | |||||
| <if test=" null != totalArea "> | |||||
| and `total_area` = #{totalArea} | |||||
| </if> | |||||
| <if test=" null != operatingArea "> | |||||
| and `operating_area` = #{operatingArea} | |||||
| </if> | |||||
| <if test=" null != parkArea "> | |||||
| and `park_area` = #{parkArea} | |||||
| </if> | |||||
| <if test=" null != parkPlaceNumber "> | |||||
| and `park_place_number` = #{parkPlaceNumber} | |||||
| </if> | |||||
| <if test=" null != payId "> | |||||
| and `pay_id` = #{payId} | |||||
| </if> | |||||
| <if test=" null != servicePhone "> | |||||
| and `service_phone` = #{servicePhone} | |||||
| </if> | |||||
| <if test=" null != imgUrl "> | |||||
| and `img_url` = #{imgUrl} | |||||
| </if> | |||||
| <if test=" null != imgUrlH "> | |||||
| and `img_ur_h` = #{imgUrlH} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxMall" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_mall | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <update id="updateToken" parameterType="com.iformall.domain.po.WxMall"> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != name "> | |||||
| and `name` like concat('%', #{name},'%') | |||||
| </if> | |||||
| <if test=" null != group "> | |||||
| and `group` like concat('%', #{group},'%') | |||||
| </if> | |||||
| <if test=" null != country "> | |||||
| and `country` like concat('%', #{country},'%') | |||||
| </if> | |||||
| <if test=" null != province "> | |||||
| and `province` like concat('%', #{province},'%') | |||||
| </if> | |||||
| <if test=" null != city "> | |||||
| and `city` like concat('%', #{city},'%') | |||||
| </if> | |||||
| <if test=" null != addr "> | |||||
| and `addr` like concat('%', #{addr},'%') | |||||
| </if> | |||||
| <if test=" null != totalArea "> | |||||
| and `total_area` = #{totalArea} | |||||
| </if> | |||||
| <if test=" null != operatingArea "> | |||||
| and `operating_area` = #{operatingArea} | |||||
| </if> | |||||
| <if test=" null != parkArea "> | |||||
| and `park_area` = #{parkArea} | |||||
| </if> | |||||
| <if test=" null != parkPlaceNumber "> | |||||
| and `park_place_number` = #{parkPlaceNumber} | |||||
| </if> | |||||
| <if test=" null != servicePhone "> | |||||
| and `service_phone` = #{servicePhone} | |||||
| </if> | |||||
| <if test=" null != imgUrl "> | |||||
| and `img_url` = #{imgUrl} | |||||
| </if> | |||||
| <if test=" null != imgUrlH "> | |||||
| and `img_ur_h` = #{imgUrlH} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxMall" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from wx_mall | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| <update id="updateToken" parameterType="com.iformall.domain.po.WxMall"> | |||||
| update wx_mall set token=#{token},expired_time=#{expiredTime} where id=#{id} | update wx_mall set token=#{token},expired_time=#{expiredTime} where id=#{id} | ||||
| </update> | </update> | ||||
| </mapper> | </mapper> | ||||
| @@ -0,0 +1,54 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.WxWiwideInfoMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxWiWideInfo"> | |||||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||||
| <result column="wiwide_id" jdbcType="VARCHAR" property="wiwideId"/> | |||||
| <result column="wiwide_key" jdbcType="VARCHAR" property="wiwideKey"/> | |||||
| <result column="wiwide_url" jdbcType="VARCHAR" property="wiwideUrl"/> | |||||
| <result column="token" jdbcType="VARCHAR" property="token"/> | |||||
| <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime"/> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`wiwide_id`,`wiwide_key`,`wiwide_url`, `token`,`expired_time` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != wiwideId "> | |||||
| and `wiwide_id` like concat('%', #{wiwideId},'%') | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxWiWideInfo" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from wx_wiwide_info | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| <update id="updateToken" parameterType="com.iformall.domain.po.WxWiWideInfo"> | |||||
| update wx_wiwide_info set token=#{token},expired_time=#{expiredTime} where id=#{id} | |||||
| </update> | |||||
| </mapper> | |||||