Commit c9d4270e authored by 周健威's avatar 周健威

Merge branch 'dev' into base-modify

# Conflicts:
#	xx-order/xx-order-api/src/main/java/com/xxfc/platform/order/contant/enumerate/OrderTypeEnum.java
parents 4dd966e5 c76fea50
...@@ -68,6 +68,7 @@ public class XxLogInterceptor{ ...@@ -68,6 +68,7 @@ public class XxLogInterceptor{
} }
}catch (BaseException e){ }catch (BaseException e){
commonLogService.initCommonLogLastPart(xxLogEntity, ObjectRestResponse.createFailedResult(e.getStatus(), e.getMessage())); commonLogService.initCommonLogLastPart(xxLogEntity, ObjectRestResponse.createFailedResult(e.getStatus(), e.getMessage()));
throw e;
}catch (Exception e){ }catch (Exception e){
commonLogService.initCommonLogLastPart(xxLogEntity, ObjectRestResponse.createFailedResult(500, e.getMessage())); commonLogService.initCommonLogLastPart(xxLogEntity, ObjectRestResponse.createFailedResult(500, e.getMessage()));
throw e; throw e;
......
...@@ -39,6 +39,14 @@ public interface UserFeign { ...@@ -39,6 +39,14 @@ public interface UserFeign {
@RequestMapping(value = "/public/userinfo-by-uid") @RequestMapping(value = "/public/userinfo-by-uid")
public ObjectRestResponse<UserDTO> userinfoByUid(@RequestParam("uid") Integer uid); public ObjectRestResponse<UserDTO> userinfoByUid(@RequestParam("uid") Integer uid);
/**
* id获取用户信息
* @param id
* @return
*/
@RequestMapping(value = "/public/app/userinfo-by-id")
public ObjectRestResponse<AppUserDTO> userDetailById(@RequestParam("id") Integer id);
/** /**
*status:0-判断是否认证过,1-认证成功后修改用户认证状态 *status:0-判断是否认证过,1-认证成功后修改用户认证状态
......
...@@ -22,10 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -22,10 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.lang.reflect.InvocationTargetException;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
/** /**
* ${DESCRIPTION} * ${DESCRIPTION}
...@@ -70,14 +68,30 @@ public class PublicController { ...@@ -70,14 +68,30 @@ public class PublicController {
ObjectRestResponse userDetailByToken(String token) throws Exception { ObjectRestResponse userDetailByToken(String token) throws Exception {
String username = userAuthUtil.getInfoFromToken(token).getId(); String username = userAuthUtil.getInfoFromToken(token).getId();
if (username == null) { if (username == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE); throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户名不存在!");}});
} }
AppUserDTO userDTO=new AppUserDTO();
Integer userid = Integer.parseInt(username); Integer userid = Integer.parseInt(username);
return ObjectRestResponse.succ(getAppUserInfoById(userid));
}
@RequestMapping(value = "/app/userinfo-by-id", method = RequestMethod.GET)
public @ResponseBody
ObjectRestResponse<AppUserDTO> userDetailById(Integer id) throws Exception {
if (id == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户名不存在!");}});
}
return ObjectRestResponse.succ(getAppUserInfoById(id));
}
private AppUserDTO getAppUserInfoById(Integer userid) throws IllegalAccessException, InvocationTargetException {
AppUserDTO userDTO=new AppUserDTO();
//获取用户基础信息 //获取用户基础信息
AppUserVo userVo = detailBiz.getUserInfoById(userid); AppUserVo userVo = detailBiz.getUserInfoById(userid);
if (userVo == null) { if (userVo == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE); throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户不存在!");}});
} }
Integer id= userVo.getId(); Integer id= userVo.getId();
Integer positionId=userVo.getPositionId(); Integer positionId=userVo.getPositionId();
...@@ -94,7 +108,7 @@ public class PublicController { ...@@ -94,7 +108,7 @@ public class PublicController {
userDTO.setPositionName(userPosition.getName()); userDTO.setPositionName(userPosition.getName());
} }
userDTO.setId(id); userDTO.setId(id);
return new ObjectRestResponse<AppUserDetail>().rel(true).data(userDTO); return userDTO;
} }
@RequestMapping(value = "/userinfo-by-uid", method = RequestMethod.GET) @RequestMapping(value = "/userinfo-by-uid", method = RequestMethod.GET)
......
...@@ -17,7 +17,14 @@ public enum OrderTypeEnum { ...@@ -17,7 +17,14 @@ public enum OrderTypeEnum {
*/ */
private String desc; private String desc;
private static Map<Integer,String> codeAndDesc = new HashMap<Integer, String>(); public static Map<Integer, OrderTypeEnum> codeAndDesc = new HashMap<Integer, OrderTypeEnum>();
//Maps.newHashMap();
static{
for(OrderTypeEnum enumE : OrderTypeEnum.values()){
codeAndDesc.put(enumE.getCode(), enumE);
}
}
OrderTypeEnum(Integer code, String desc){ OrderTypeEnum(Integer code, String desc){
this.code=code; this.code=code;
......
...@@ -19,11 +19,11 @@ public enum RefundTypeEnum { ...@@ -19,11 +19,11 @@ public enum RefundTypeEnum {
private static Map<Integer,String> codeAndDesc = new HashMap<Integer, String>(); private static Map<Integer,String> codeAndDesc = new HashMap<Integer, String>();
//Maps.newHashMap(); //Maps.newHashMap();
// static{ static{
// for(VehicleBookRecordStatus constantType : VehicleBookRecordStatus.values()){ for(RefundTypeEnum enumE : RefundTypeEnum.values()){
// codeAndDesc.put(constantType.getCode(),constantType.getDesc()); codeAndDesc.put(enumE.getCode(),enumE.getDesc());
// } }
// } }
RefundTypeEnum(Integer code, String desc){ RefundTypeEnum(Integer code, String desc){
this.code=code; this.code=code;
......
package com.xxfc.platform.order.biz; package com.xxfc.platform.order.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.dto.UserMemberDTO; import com.github.wxiaoqi.security.admin.dto.UserMemberDTO;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
...@@ -19,6 +21,7 @@ import com.xxfc.platform.order.pojo.order.OrderListVo; ...@@ -19,6 +21,7 @@ import com.xxfc.platform.order.pojo.order.OrderListVo;
import com.xxfc.platform.order.pojo.order.OrderPageVO; import com.xxfc.platform.order.pojo.order.OrderPageVO;
import com.xxfc.platform.order.pojo.order.OrderVehicleCrosstownDto; import com.xxfc.platform.order.pojo.order.OrderVehicleCrosstownDto;
import com.xxfc.platform.tour.feign.TourFeign; import com.xxfc.platform.tour.feign.TourFeign;
import com.xxfc.platform.universal.dto.SmsTemplateDTO;
import com.xxfc.platform.universal.feign.ThirdFeign; import com.xxfc.platform.universal.feign.ThirdFeign;
import com.xxfc.platform.universal.vo.OrderRefundVo; import com.xxfc.platform.universal.vo.OrderRefundVo;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
...@@ -387,7 +390,10 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -387,7 +390,10 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
* @param orderNo * @param orderNo
* @param tradeNo * @param tradeNo
*/ */
@Transactional
public void payNotifyHandle(String orderNo, String tradeNo, Integer type) { public void payNotifyHandle(String orderNo, String tradeNo, Integer type) {
OrderRentVehicleDetail orvd = new OrderRentVehicleDetail();
OrderMemberDetail omd = new OrderMemberDetail();
BaseOrder baseOrder = this.selectOne(new BaseOrder() {{ BaseOrder baseOrder = this.selectOne(new BaseOrder() {{
setNo(orderNo); setNo(orderNo);
}}); }});
...@@ -406,23 +412,25 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -406,23 +412,25 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
if(OrderTypeEnum.MEMBER.getCode().equals(baseOrder.getType())) { if(OrderTypeEnum.MEMBER.getCode().equals(baseOrder.getType())) {
//直接设置订单完成 //直接设置订单完成
updateOrder.setStatus(OrderStatusEnum.ORDER_FINISH.getCode()); updateOrder.setStatus(OrderStatusEnum.ORDER_FINISH.getCode());
OrderMemberDetail omd = orderMemberDetailBiz.selectOne(new OrderMemberDetail(){{ omd = orderMemberDetailBiz.selectOne(new OrderMemberDetail(){{
setOrderId(baseOrder.getId()); setOrderId(baseOrder.getId());
}}); }});
//触发会员效益 //触发会员效益
ObjectRestResponse orr = userFeign.buyMember(new UserMemberDTO() {{ UserMemberDTO userMemberDTO = new UserMemberDTO() {{
setUserId(baseOrder.getUserId()); setUserId(baseOrder.getUserId());
setDiscount(omd.getRebate());
setIsBind(ISBIND_BIND); setIsBind(ISBIND_BIND);
setMemberLevel(omd.getMemberLevel()); }};
setRentFreeDays(omd.getRentFreeNum()); userMemberDTO.setMemberLevel(omd.getMemberLevel());
setTotalNumber(omd.getRentFreeNum()); userMemberDTO.setRentFreeDays(omd.getRentFreeNum());
}}); userMemberDTO.setTotalNumber(omd.getRentFreeNum());
userMemberDTO.setDiscount(omd.getRebate());
ObjectRestResponse orr = userFeign.buyMember(userMemberDTO);
log.info("orr.getStatus() : " + orr.getStatus() ); log.info("orr.getStatus() : " + orr.getStatus() );
}else if(OrderTypeEnum.RENT_VEHICLE.getCode().equals(baseOrder.getType())) { }else if(OrderTypeEnum.RENT_VEHICLE.getCode().equals(baseOrder.getType())) {
updateOrder.setStatus(OrderStatusEnum.ORDER_TOSTART.getCode()); updateOrder.setStatus(OrderStatusEnum.ORDER_TOSTART.getCode());
OrderRentVehicleDetail orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail(){{ orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail(){{
setOrderId(baseOrder.getId()); setOrderId(baseOrder.getId());
}}); }});
//车辆预定审核通过 //车辆预定审核通过
...@@ -441,7 +449,49 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -441,7 +449,49 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
//站点总人数添加 //站点总人数添加
tourFeign.updateTourGoodPersonNum(otd.getVerificationId(), TourFeign.TOTAL_PERSON, otd.getTotalNumber()); tourFeign.updateTourGoodPersonNum(otd.getVerificationId(), TourFeign.TOTAL_PERSON, otd.getTotalNumber());
} }
try {
this.updateSelectiveByIdRe(updateOrder); this.updateSelectiveByIdRe(updateOrder);
}finally {
OrderTypeEnum orderTypeEnum = OrderTypeEnum.codeAndDesc.get(baseOrder.getType());
AppUserDTO appUserDTO = userFeign.userDetailById(baseOrder.getUserId()).getData();
Integer smstype;
List<String> smsParams = new ArrayList<String>();
smsParams.add(baseOrder.getRealAmount().toString());
switch (orderTypeEnum) {
case RentVehicle:
if(orvd.getFreeDays() > 0) {
smstype = SmsTemplateDTO.RENT_MEMENT;
smsParams.add(orvd.getFreeDays().toString());
smsParams.add(appUserDTO.getRentFreeDays().toString());
}else {
smstype = SmsTemplateDTO.RENT_NORMAL;
}
thirdFeign.sendTemplate(new SmsTemplateDTO(){{
setPhoneNumbers(appUserDTO.getUsername());
setType(smstype);
setParams(smsParams.toArray(new String[smsParams.size()]));
}});
break;
case TOUR:
thirdFeign.sendTemplate(new SmsTemplateDTO(){{
setPhoneNumbers(appUserDTO.getUsername());
setType(SmsTemplateDTO.TOUR);
setParams(smsParams.toArray(new String[smsParams.size()]));
}});
break;
case MEMBER:
smsParams.add(omd.getRentFreeNum().toString());
smsParams.add(appUserDTO.getRentFreeDays().toString());
thirdFeign.sendTemplate(new SmsTemplateDTO(){{
setPhoneNumbers(appUserDTO.getUsername());
setType(SmsTemplateDTO.MEMENT);
setParams(smsParams.toArray(new String[smsParams.size()]));
}});
break;
default:
break;
}
}
} else { } else {
log.error(" order has payed , orderNo:{}, tradeNo:{} ", orderNo, tradeNo); log.error(" order has payed , orderNo:{}, tradeNo:{} ", orderNo, tradeNo);
} }
......
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
from tour_good g from tour_good g
LEFT JOIN tour_good_tag tag ON g.id=tag.good_id LEFT JOIN tour_good_tag tag ON g.id=tag.good_id
LEFT JOIN tour_tag t ON tag.tag_id=t.id LEFT JOIN tour_tag t ON tag.tag_id=t.id
where g.recommend=1 and g.status=1 and g.is_del=0 where g.recommend=1 and g.status=1 and g.is_del=0 and t.is_del=0
GROUP BY g.id GROUP BY g.id
ORDER BY g.rank DESC ,g.id DESC ORDER BY g.rank DESC ,g.id DESC
limit #{start,jdbcType=INTEGER},#{size,jdbcType=INTEGER} limit #{start,jdbcType=INTEGER},#{size,jdbcType=INTEGER}
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
LEFT JOIN tour_good_tag tag ON g.id=tag.good_id LEFT JOIN tour_good_tag tag ON g.id=tag.good_id
LEFT JOIN tour_tag t ON tag.tag_id=t.id LEFT JOIN tour_tag t ON tag.tag_id=t.id
<where> <where>
g.is_del=0 g.is_del=0 and t.is_del=0
<if test="params.name != null and params.name != ''"> <if test="params.name != null and params.name != ''">
and (g.`name` like CONCAT('%',#{params.name},'%') or g.introduce like CONCAT('%',#{params.name},'%')) and (g.`name` like CONCAT('%',#{params.name},'%') or g.introduce like CONCAT('%',#{params.name},'%'))
</if> </if>
......
...@@ -50,6 +50,16 @@ ...@@ -50,6 +50,16 @@
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
<version>4.5</version> <version>4.5</version>
</dependency> </dependency>
<!-- 短信机-->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
</dependencies> </dependencies>
......
package com.xxfc.platform.universal.dto;
import lombok.Data;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/3 17:51
*/
@Data
public class SmsTemplateDTO {
public static final int RENT_NORMAL = 1;
public static final int RENT_MEMENT = 2;
public static final int TOUR = 3;
public static final int MEMENT = 4;
//类型:1-租车订单通知(普通用户),2-租车订单短信(会员权益),3-旅游订单短信,4-加入会员通知
private Integer type;
//手机号码(多个短信逗号隔开)
private String phoneNumbers;
//参数
private String[] params;
}
...@@ -3,6 +3,7 @@ package com.xxfc.platform.universal.feign; ...@@ -3,6 +3,7 @@ package com.xxfc.platform.universal.feign;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.universal.dto.RegionDTO; import com.xxfc.platform.universal.dto.RegionDTO;
import com.xxfc.platform.universal.dto.SmsTemplateDTO;
import com.xxfc.platform.universal.entity.Dictionary; import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.entity.OrderRefund; import com.xxfc.platform.universal.entity.OrderRefund;
import com.xxfc.platform.universal.vo.*; import com.xxfc.platform.universal.vo.*;
...@@ -29,6 +30,9 @@ public interface ThirdFeign { ...@@ -29,6 +30,9 @@ public interface ThirdFeign {
@RequestMapping(value = "/sms/app/unauth/sendCode", method = RequestMethod.GET) @RequestMapping(value = "/sms/app/unauth/sendCode", method = RequestMethod.GET)
//发送短信模板消息 //发送短信模板消息
public JSONObject sendCode(@RequestParam("phone") String phone, @RequestParam("code")String code, @RequestParam("templateCode")String templateCode ); public JSONObject sendCode(@RequestParam("phone") String phone, @RequestParam("code")String code, @RequestParam("templateCode")String templateCode );
//云通讯短信机
@RequestMapping(value = "/sms/app/unauth/sendTemplate", method = RequestMethod.POST)
public ObjectRestResponse sendTemplate(SmsTemplateDTO smsTemplateDTO);
@RequestMapping(value = "/file/app/unauth/uploadFiles", method = RequestMethod.POST) @RequestMapping(value = "/file/app/unauth/uploadFiles", method = RequestMethod.POST)
public JSONObject uploadFiles(@RequestParam(value = "files") MultipartFile[] files); public JSONObject uploadFiles(@RequestParam(value = "files") MultipartFile[] files);
@RequestMapping(value = "/pay/app/wx", method = RequestMethod.POST) @RequestMapping(value = "/pay/app/wx", method = RequestMethod.POST)
......
package com.xxfc.platform.universal.utils;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class CCPRestSmsUtils {
public static CCPRestSDK restAPI;
static {
restAPI = new CCPRestSDK();
restAPI.init("app.cloopen.com", "8883");
restAPI.setAccount("8aaf070865e6b6eb0165ecd776700559",
"3fe5e2f053674f23b029a9a9fc9503f0");
restAPI.setAppId("8a216da86812593601684bec10581ab5");
}
public static Map<String, Object> sendTemplateSMS(String phoneNumbers, String[] params, String templateId) {
HashMap<String, Object> result = null;
result = restAPI.sendTemplateSMS(phoneNumbers, templateId, params);
System.out.println("SDKTestGetSubAccounts result=" + result);
if ("000000".equals(result.get("statusCode"))) {
// 正常返回输出data包体信息(map)
HashMap<String, Object> data = (HashMap<String, Object>) result.get("data");
Set<String> keySet = data.keySet();
for (String key : keySet) {
Object object = data.get(key);
System.out.println(key + " = " + object);
}
} else {
// 异常返回输出错误码和错误信息
System.out.println("错误码=" + result.get("statusCode") + " 错误信息= " + result.get("statusMsg"));
}
return result;
}
}
\ No newline at end of file
package com.xxfc.platform.universal.utils;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.Principal;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
public class CcopHttpClient
{
public DefaultHttpClient registerSSL(String hostname, String protocol, int port, String scheme)
throws NoSuchAlgorithmException, KeyManagementException
{
DefaultHttpClient httpclient = new DefaultHttpClient();
SSLContext ctx = SSLContext.getInstance(protocol);
X509TrustManager tm = new X509TrustManager()
{
public void checkClientTrusted(X509Certificate[] chain,String authType)
throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] chain,String authType)
throws CertificateException {
if ((chain == null) || (chain.length == 0))
throw new IllegalArgumentException("null or zero-length certificate chain");
if ((authType == null) || (authType.length() == 0))
throw new IllegalArgumentException("null or zero-length authentication type");
boolean br = false;
Principal principal = null;
for (X509Certificate x509Certificate : chain) {
principal = x509Certificate.getSubjectX500Principal();
if (principal != null) {
br = true;
return;
}
}
if (!(br))
throw new CertificateException("服务端证书验证失败!");
}
public X509Certificate[] getAcceptedIssuers()
{
return new X509Certificate[0];
}
};
ctx.init(null, new TrustManager[] { tm }, new SecureRandom());
SSLSocketFactory socketFactory = new SSLSocketFactory(ctx, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
Scheme sch = new Scheme(scheme, port, socketFactory);
httpclient.getConnectionManager().getSchemeRegistry().register(sch);
return httpclient;
}
}
\ No newline at end of file
/*
* Copyright (c) 2014 The CCP project authors. All Rights Reserved.
*
* Use of this source code is governed by a Beijing Speedtong Information Technology Co.,Ltd license
* that can be found in the LICENSE file in the root of the web site.
*
* http://www.yuntongxun.com
*
* An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package com.xxfc.platform.universal.utils;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateUtil
{
public static final int DEFAULT = 0;
public static final int YM = 1;
public static final int YMR_SLASH = 11;
public static final int NO_SLASH = 2;
public static final int YM_NO_SLASH = 3;
public static final int DATE_TIME = 4;
public static final int DATE_TIME_NO_SLASH = 5;
public static final int DATE_HM = 6;
public static final int TIME = 7;
public static final int HM = 8;
public static final int LONG_TIME = 9;
public static final int SHORT_TIME = 10;
public static final int DATE_TIME_LINE = 12;
public static String dateToStr(Date date, String pattern)
{
if ((date == null) || (date.equals("")))
return null;
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
return formatter.format(date);
}
public static String dateToStr(Date date) {
return dateToStr(date, "yyyy/MM/dd");
}
public static String dateToStr(Date date, int type) {
switch (type)
{
case 0:
return dateToStr(date);
case 1:
return dateToStr(date, "yyyy/MM");
case 2:
return dateToStr(date, "yyyyMMdd");
case 11:
return dateToStr(date, "yyyy-MM-dd");
case 3:
return dateToStr(date, "yyyyMM");
case 4:
return dateToStr(date, "yyyy/MM/dd HH:mm:ss");
case 5:
return dateToStr(date, "yyyyMMddHHmmss");
case 6:
return dateToStr(date, "yyyy/MM/dd HH:mm");
case 7:
return dateToStr(date, "HH:mm:ss");
case 8:
return dateToStr(date, "HH:mm");
case 9:
return dateToStr(date, "HHmmss");
case 10:
return dateToStr(date, "HHmm");
case 12:
return dateToStr(date, "yyyy-MM-dd HH:mm:ss");
}
throw new IllegalArgumentException("Type undefined : " + type);
}
}
\ No newline at end of file
/*
* Copyright (c) 2014 The CCP project authors. All Rights Reserved.
*
* Use of this source code is governed by a Beijing Speedtong Information Technology Co.,Ltd license
* that can be found in the LICENSE file in the root of the web site.
*
* http://www.yuntongxun.com
*
* An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package com.xxfc.platform.universal.utils;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import cn.hutool.core.codec.Base64;
public class EncryptUtil
{
private static final String UTF8 = "utf-8";
public String md5Digest(String src) throws NoSuchAlgorithmException, UnsupportedEncodingException
{
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] b = md.digest(src.getBytes("utf-8"));
return byte2HexStr(b);
}
public String base64Encoder(String src) throws UnsupportedEncodingException
{
// BASE64Encoder encoder = new BASE64Encoder();
return Base64.encode(src.getBytes("utf-8"));
}
public String base64Decoder(String dest)
throws NoSuchAlgorithmException, IOException
{
// BASE64Decoder decoder = new BASE64Decoder();
return new String(Base64.decode(dest), "utf-8");
}
private String byte2HexStr(byte[] b)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < b.length; ++i) {
String s = Integer.toHexString(b[i] & 0xFF);
if (s.length() == 1) {
sb.append("0");
}
sb.append(s.toUpperCase());
}
return sb.toString();
}
}
\ No newline at end of file
package com.xxfc.platform.universal.utils;
public class PublicMsg {
public final static String UEDITOR_CONFIG = "{\n" +
" \"imageActionName\": \"uploadimage\",\n" +
" \"imageFieldName\": \"upfile\",\n" +
" \"imageMaxSize\": 2048000,\n" +
" \"imageAllowFiles\": [\".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\"],\n" +
" \"imageCompressEnable\": true,\n" +
" \"imageCompressBorder\": 1600,\n" +
" \"imageInsertAlign\": \"none\",\n" +
" \"imageUrlPrefix\": \"\",\n" +
" \"imagePathFormat\": \"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}\",\n" +
"\n" +
" \"scrawlActionName\": \"uploadscrawl\",\n" +
" \"scrawlFieldName\": \"upfile\",\n" +
" \"scrawlPathFormat\": \"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}\",\n" +
" \"scrawlMaxSize\": 2048000,\n" +
" \"scrawlUrlPrefix\": \"\",\n" +
" \"scrawlInsertAlign\": \"none\",\n" +
"\n" +
" \"snapscreenActionName\": \"uploadimage\",\n" +
" \"snapscreenPathFormat\": \"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}\",\n" +
" \"snapscreenUrlPrefix\": \"\",\n" +
" \"snapscreenInsertAlign\": \"none\",\n" +
"\n" +
" \"catcherLocalDomain\": [\"127.0.0.1\", \"localhost\", \"img.baidu.com\"],\n" +
" \"catcherActionName\": \"catchimage\",\n" +
" \"catcherFieldName\": \"source\",\n" +
" \"catcherPathFormat\": \"/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}\",\n" +
" \"catcherUrlPrefix\": \"\",\n" +
" \"catcherMaxSize\": 2048000,\n" +
" \"catcherAllowFiles\": [\".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\"],\n" +
"\n" +
" \"videoActionName\": \"uploadvideo\",\n" +
" \"videoFieldName\": \"upfile\",\n" +
" \"videoPathFormat\": \"/ueditor/jsp/upload/video/{yyyy}{mm}{dd}/{time}{rand:6}\",\n" +
" \"videoUrlPrefix\": \"\",\n" +
" \"videoMaxSize\": 102400000,\n" +
" \"videoAllowFiles\": [\n" +
" \".flv\", \".swf\", \".mkv\", \".avi\", \".rm\", \".rmvb\", \".mpeg\", \".mpg\",\n" +
" \".ogg\", \".ogv\", \".mov\", \".wmv\", \".mp4\", \".webm\", \".mp3\", \".wav\", \".mid\"],\n" +
"\n" +
" \"fileActionName\": \"uploadfile\",\n" +
" \"fileFieldName\": \"upfile\",\n" +
" \"filePathFormat\": \"/ueditor/jsp/upload/file/{yyyy}{mm}{dd}/{time}{rand:6}\",\n" +
" \"fileUrlPrefix\": \"\",\n" +
" \"fileMaxSize\": 51200000,\n" +
" \"fileAllowFiles\": [\n" +
" \".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\",\n" +
" \".flv\", \".swf\", \".mkv\", \".avi\", \".rm\", \".rmvb\", \".mpeg\", \".mpg\",\n" +
" \".ogg\", \".ogv\", \".mov\", \".wmv\", \".mp4\", \".webm\", \".mp3\", \".wav\", \".mid\",\n" +
" \".rar\", \".zip\", \".tar\", \".gz\", \".7z\", \".bz2\", \".cab\", \".iso\",\n" +
" \".doc\", \".docx\", \".xls\", \".xlsx\", \".ppt\", \".pptx\", \".pdf\", \".txt\", \".md\", \".xml\"\n" +
" ],\n" +
"\n" +
" \"imageManagerActionName\": \"listimage\",\n" +
" \"imageManagerListPath\": \"/ueditor/jsp/upload/image/\",\n" +
" \"imageManagerListSize\": 20,\n" +
" \"imageManagerUrlPrefix\": \"\",\n" +
" \"imageManagerInsertAlign\": \"none\",\n" +
" \"imageManagerAllowFiles\": [\".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\"],\n" +
"\n" +
" \"fileManagerActionName\": \"listfile\",\n" +
" \"fileManagerListPath\": \"/ueditor/jsp/upload/file/\",\n" +
" \"fileManagerUrlPrefix\": \"\",\n" +
" \"fileManagerListSize\": 20,\n" +
" \"fileManagerAllowFiles\": [\n" +
" \".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\",\n" +
" \".flv\", \".swf\", \".mkv\", \".avi\", \".rm\", \".rmvb\", \".mpeg\", \".mpg\",\n" +
" \".ogg\", \".ogv\", \".mov\", \".wmv\", \".mp4\", \".webm\", \".mp3\", \".wav\", \".mid\",\n" +
" \".rar\", \".zip\", \".tar\", \".gz\", \".7z\", \".bz2\", \".cab\", \".iso\",\n" +
" \".doc\", \".docx\", \".xls\", \".xlsx\", \".ppt\", \".pptx\", \".pdf\", \".txt\", \".md\", \".xml\"\n" +
" ] \n" +
"\n" +
"}";
/**
* Ueditor的返回状态类型
*/
public enum UeditorMsg{
SUCCESS("SUCCESS"),ERROR("上传失败");
private String v;
UeditorMsg(String v){
this.v =v;
}
public String get(){
return this.v;
}
}
}
\ No newline at end of file
package com.xxfc.platform.universal.vo;
import lombok.Data;
@Data
public class Ueditor {
private String url;
private String original;
private String state;
private String title;
}
...@@ -27,6 +27,12 @@ ...@@ -27,6 +27,12 @@
<dependency> <dependency>
<groupId>com.aliyun</groupId> <groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId> <artifactId>aliyun-java-sdk-core</artifactId>
<exclusions>
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
</exclusions>
<version>4.4.2</version> <version>4.4.2</version>
</dependency> </dependency>
<dependency> <dependency>
......
package com.xxfc.platform.universal.biz;
import com.xxfc.platform.universal.utils.CCPRestSmsUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class CCPRestSmsBiz{
//租车订单通知(普通用户)1
public static final String TEMPLATE_ID_ORDER = "457270";
//租车订单短信(会员权益)2
public static final String TEMPLATE_ID_ORDER_MEMBER = "457271";
//旅游订单短信3
public static final String TEMPLATE_ID_ORDER_TOUR = "457272";
//加入会员通知4
public static final String TEMPLATE_ID_MEMBER = "457273";
//发送模板消息
public void sendTemplateSMS(Integer type,String phoneNumbers,String[]params){
switch (type){
case 1 :
CCPRestSmsUtils.sendTemplateSMS(phoneNumbers,params,TEMPLATE_ID_ORDER);
break;
case 2 :
CCPRestSmsUtils.sendTemplateSMS(phoneNumbers,params,TEMPLATE_ID_ORDER_MEMBER);
break;
case 3 :
CCPRestSmsUtils.sendTemplateSMS(phoneNumbers,params,TEMPLATE_ID_ORDER_TOUR);
break;
case 4 :
CCPRestSmsUtils.sendTemplateSMS(phoneNumbers,params,TEMPLATE_ID_MEMBER);
break;
}
}
}
...@@ -3,15 +3,15 @@ package com.xxfc.platform.universal.controller; ...@@ -3,15 +3,15 @@ package com.xxfc.platform.universal.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.result.JsonResultUtil; import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
import com.xxfc.platform.universal.biz.CCPRestSmsBiz;
import com.xxfc.platform.universal.dto.SmsTemplateDTO;
import com.xxfc.platform.universal.service.SmsService; import com.xxfc.platform.universal.service.SmsService;
import com.xxfc.platform.universal.service.UploadService; import com.xxfc.platform.universal.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
...@@ -29,6 +29,9 @@ public class SmsController { ...@@ -29,6 +29,9 @@ public class SmsController {
@Autowired @Autowired
SmsService smsService; SmsService smsService;
@Autowired
CCPRestSmsBiz smsBiz;
@RequestMapping(value = "/app/unauth/send", method = RequestMethod.GET) //匹配的是href中的download请求 @RequestMapping(value = "/app/unauth/send", method = RequestMethod.GET) //匹配的是href中的download请求
public JSONObject sendSms(@RequestParam("phone") String phone) throws Exception { public JSONObject sendSms(@RequestParam("phone") String phone) throws Exception {
return smsService.smsCode(phone); return smsService.smsCode(phone);
...@@ -40,5 +43,17 @@ public class SmsController { ...@@ -40,5 +43,17 @@ public class SmsController {
@RequestParam("templateCode")String templateCode ) throws Exception { @RequestParam("templateCode")String templateCode ) throws Exception {
return smsService.smsByCode(phone,code,templateCode); return smsService.smsByCode(phone,code,templateCode);
} }
@RequestMapping(value = "/app/unauth/sendTemplate", method = RequestMethod.POST)
public ObjectRestResponse sendTemplate(@RequestBody SmsTemplateDTO smsTemplateDTO) throws Exception {
if(smsTemplateDTO==null){
return ObjectRestResponse.createDefaultFail();
}
Integer type=smsTemplateDTO.getType();
String[] params=smsTemplateDTO.getParams();
String phoneNumbers=smsTemplateDTO.getPhoneNumbers();
smsBiz.sendTemplateSMS(type,phoneNumbers,params);
return ObjectRestResponse.succ();
}
} }
...@@ -4,16 +4,17 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,16 +4,17 @@ import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.util.result.JsonResultUtil; import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
import com.xxfc.platform.universal.service.UploadService; import com.xxfc.platform.universal.service.UploadService;
import com.xxfc.platform.universal.utils.PublicMsg;
import com.xxfc.platform.universal.vo.Ueditor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
/** /**
* 图片上传 * 图片上传
...@@ -96,5 +97,24 @@ public class UploadController{ ...@@ -96,5 +97,24 @@ public class UploadController{
return JsonResultUtil.createDefaultFail(); return JsonResultUtil.createDefaultFail();
} }
//以下是图片上传的方法
@RequestMapping(value="/app/unauth/ueditor")
@ResponseBody
public String ueditor(HttpServletRequest request) {
return PublicMsg.UEDITOR_CONFIG;
}
@RequestMapping(value="/app/unauth/ueditor", method = RequestMethod.POST)
public Ueditor imgUpload(MultipartFile upfile) throws Exception {
Ueditor ueditor = new Ueditor();
ueditor.setUrl(uploadService.uploadFile(upfile,"admin"));
ueditor.setOriginal(upfile.getOriginalFilename());
ueditor.setState("SUCCESS");
ueditor.setTitle(upfile.getOriginalFilename());
return ueditor;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment