28 changed files with 1098 additions and 544 deletions
@ -0,0 +1,15 @@ |
|||
<component name="libraryTable"> |
|||
<library name="bcprov-ext-jdk15on-1.46"> |
|||
<CLASSES> |
|||
<root url="jar://$PROJECT_DIR$/../jar/bcprov-ext-jdk15on-1.46.jar!/" /> |
|||
<root url="jar://$PROJECT_DIR$/../jar/commons-codec-1.3.jar!/" /> |
|||
<root url="jar://$PROJECT_DIR$/../jar/commons-httpclient-3.0.1.jar!/" /> |
|||
<root url="jar://$PROJECT_DIR$/../jar/commons-lang-2.3.jar!/" /> |
|||
<root url="jar://$PROJECT_DIR$/../jar/commons-logging-1.1.jar!/" /> |
|||
<root url="jar://$PROJECT_DIR$/../jar/hiiposm_engine_simple_2.0.0.34.jar!/" /> |
|||
<root url="jar://$PROJECT_DIR$/../jar/securityAPI-client.jar!/" /> |
|||
</CLASSES> |
|||
<JAVADOC /> |
|||
<SOURCES /> |
|||
</library> |
|||
</component> |
|||
@ -0,0 +1,23 @@ |
|||
package com.base.springcloud.constant; |
|||
|
|||
public interface PaymentConstant { |
|||
|
|||
String CHARACTER_SET = "00"; // 字符集默认 : 00 - GBK
|
|||
String CALLBACK_URL = "www.baidu.com"; // 页面通知地址
|
|||
String NOTIFY_URL = "www.baidu.com"; // 后台通知地址
|
|||
String SIGN_TYPE = "RSA"; // 签名类型
|
|||
|
|||
String WAIT = "W"; // 等待付款
|
|||
String SUECCESS = "S"; // 支付成功
|
|||
String REFUND = "R"; // 退款成功
|
|||
String CANCLE = "C"; // 撤销
|
|||
|
|||
String WEC = "WEC"; // 微信
|
|||
String QRCWC = "QRCWC"; |
|||
|
|||
String AL = "AL"; // 支付宝
|
|||
String QRCAL = "QRCAL"; |
|||
|
|||
String CP = "CP"; // 云闪付
|
|||
String QRCCP = "QRCCP"; |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
package com.base.springcloud.controller; |
|||
|
|||
import com.base.springcloud.base.CommonResult; |
|||
import com.base.springcloud.constant.ErrorConstant; |
|||
import com.base.springcloud.entity.Order; |
|||
import com.base.springcloud.service.PaymentService; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@RestController |
|||
@Slf4j |
|||
@Api(tags="支付管理") |
|||
@RequestMapping("/payment") |
|||
public class PaymentController { |
|||
|
|||
@Autowired |
|||
private PaymentService paymentService; |
|||
|
|||
@ApiOperation(value = "native下单", notes = "微信native下单") |
|||
@PostMapping("/nativePlaceOrder") |
|||
public CommonResult nativePlaceOrder(@RequestBody Order order) { |
|||
String codeUrl = paymentService.placeOrder(order); |
|||
return new CommonResult(ErrorConstant.SUECCESS.getCode(), ErrorConstant.SUECCESS.getMessage(), codeUrl); |
|||
} |
|||
} |
|||
@ -1,17 +0,0 @@ |
|||
package com.base.springcloud.dao; |
|||
|
|||
import com.base.springcloud.entity.Merchant; |
|||
|
|||
public interface MerchantMapper { |
|||
int deleteByPrimaryKey(String id); |
|||
|
|||
int insert(Merchant record); |
|||
|
|||
int insertSelective(Merchant record); |
|||
|
|||
Merchant selectByPrimaryKey(String id); |
|||
|
|||
int updateByPrimaryKeySelective(Merchant record); |
|||
|
|||
int updateByPrimaryKey(Merchant record); |
|||
} |
|||
@ -1,28 +0,0 @@ |
|||
package com.base.springcloud.entity; |
|||
|
|||
import com.base.springcloud.base.BaseEntity; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class Merchant extends BaseEntity { |
|||
|
|||
private String id; |
|||
|
|||
private String merchantId; |
|||
|
|||
private String merchantName; |
|||
|
|||
private String cityStoreName; |
|||
|
|||
private String storeBrandName; |
|||
|
|||
private String signType; |
|||
|
|||
private String privateKey; |
|||
|
|||
private String deviceInfo; |
|||
|
|||
private String spbillCreateIp; |
|||
|
|||
private String notifyUrl; |
|||
} |
|||
@ -1,8 +1,5 @@ |
|||
package com.base.springcloud.service; |
|||
|
|||
import com.base.springcloud.entity.Merchant; |
|||
|
|||
public interface MerchantService { |
|||
|
|||
void merchantAdd(Merchant merchant); |
|||
} |
|||
|
|||
@ -0,0 +1,9 @@ |
|||
package com.base.springcloud.service; |
|||
|
|||
import com.base.springcloud.entity.Order; |
|||
|
|||
public interface PaymentService { |
|||
|
|||
// 下单
|
|||
String placeOrder(Order order); |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
package com.base.springcloud.service; |
|||
|
|||
import com.base.springcloud.entity.Order; |
|||
|
|||
public interface WecPaymentService { |
|||
|
|||
String nativePay(Order order); |
|||
} |
|||
@ -1,14 +1,9 @@ |
|||
package com.base.springcloud.service.imp; |
|||
|
|||
import com.base.springcloud.entity.Merchant; |
|||
import com.base.springcloud.service.MerchantService; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class MerchantServiceImp implements MerchantService { |
|||
|
|||
@Override |
|||
public void merchantAdd(Merchant merchant) { |
|||
// TODO 添加商户逻辑
|
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,29 @@ |
|||
package com.base.springcloud.service.imp; |
|||
|
|||
import com.base.springcloud.constant.PaymentConstant; |
|||
import com.base.springcloud.dao.OrderMapper; |
|||
import com.base.springcloud.entity.Order; |
|||
import com.base.springcloud.service.OrderService; |
|||
import com.base.springcloud.util.DecimalUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
import java.util.UUID; |
|||
|
|||
@Service |
|||
public class OrderServiceImp implements OrderService { |
|||
|
|||
@Autowired |
|||
private OrderMapper orderMapper; |
|||
|
|||
@Override |
|||
public void registerOrder(Order order) { |
|||
order.setId(UUID.randomUUID().toString().replace("-", "")); |
|||
order.setTimeStamp(new Date()); |
|||
order.setOrderState(PaymentConstant.WAIT); |
|||
order.setOrderAmount(DecimalUtils.divide(order.getOrderAmount(),new BigDecimal(100))); |
|||
orderMapper.insert(order); |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
package com.base.springcloud.service.imp; |
|||
|
|||
import com.base.springcloud.entity.Order; |
|||
import com.base.springcloud.service.OrderService; |
|||
import com.base.springcloud.service.PaymentService; |
|||
import com.base.springcloud.service.WecPaymentService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class PaymentServiceImp implements PaymentService { |
|||
|
|||
@Autowired |
|||
private OrderService orderService; |
|||
|
|||
@Autowired |
|||
private WecPaymentService wecPaymentService; |
|||
|
|||
@Override |
|||
public String placeOrder(Order order){ |
|||
// 参数检查
|
|||
parameterCheck(order); |
|||
// 登记订单
|
|||
orderService.registerOrder(order); |
|||
// 请求微信生成二维码
|
|||
String codeUrl = wecPaymentService.nativePay(order); |
|||
return codeUrl; |
|||
} |
|||
|
|||
// 参数检查
|
|||
private void parameterCheck(Order order) { |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,95 @@ |
|||
package com.base.springcloud.service.imp; |
|||
|
|||
import com.base.springcloud.constant.PaymentConstant; |
|||
import com.base.springcloud.entity.Order; |
|||
import com.base.springcloud.service.WecPaymentService; |
|||
import com.base.springcloud.util.DateUtil; |
|||
import com.hisun.iposm.HiCASignUtil2; |
|||
import com.hisun.iposm.HiiposmUtil; |
|||
import org.apache.commons.lang.StringUtils; |
|||
import org.apache.commons.lang.text.StrBuilder; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class WecPaymentServiceImp implements WecPaymentService { |
|||
|
|||
Logger logger = LoggerFactory.getLogger(WecPaymentServiceImp.class); |
|||
|
|||
@Override |
|||
public String nativePay(Order order) { |
|||
String res = ""; |
|||
HiiposmUtil util = new HiiposmUtil(); |
|||
String merchantId = "888027018000004"; |
|||
String privateKey = "308204bc020100300d06092a864886f70d0101010500048204a6308204a202010002820101008fe86bc46878d127d0bd59b8d0ed81b5dd4066a8af2729ade7df76d4022ee9535de274d0a786e654bea82c6a6450c64cc428a79326583accbcf7724d38b5895dcd9eb542a8078ba0d9d8d2a69bd5890966aacdb6daea387b52ed662c2fef8932bd0f69155d7c1729d9da004920508dd4be72e78a0c33cbf847d3c4bce0cf2e42190e5166fea223544c1c0d7dc0fda964adc1deffce527fb75c13c802c37dd6071f071c220a8f6036c72fae13bf78c02b7fdefdc771298f05b85e341ec7e521d9d7b2d535bc16bae35c6d7b8abc670c5da46b4404ea164915d6cdd102c170c542839b0a386ce9eb46a741a11678320271d53253087c5ca44ac7851507cef9787902030100010282010061d895eda55b005b22029cce9cbfe041d77dc24f4f48417e8cf9d3c1b2fa528aec7add1241d5e72617bc20f6f5de35f65c298846f4fb687f6cbc926b0ef3dfc277dc4142611d4042cddc2ede3976a7064d583526ef11f1f5681d222b492c850c8a9fbfc3571cd8630c4cbd84fb03ca6bac52543bf8afff2f8126ebcdc0cd1d95abc8bc00d310240b16a3afbc5d0ac88a60005a2a0f149246513a4b2375142f2f41d1f84db337e834d65c76ff54291e0d45051be37dceaa7468f4becf3547905dba823ee9b5b449e24c97ea2fd74387a121018e595592735ae7234563bf1c204cd5e523169fb80838f6154c046b01f847f22e348d09210ad737ba1a9b43fbf50102818100de15a6916a0244c461305c8d8f0bd1df1f82279f9b4ae70966f61fc25d310825ccef8305146500f16154674be702f3d5f4ec639e9e03fd040c925ea1df18b19c1255f996045cd5dcd68dc0782b7760f9ce3f4279972a1a49f3a4cb8f0e2d2f2f5698667004cfdeca84335665870d95c2ab625074b73afba33aab1481be5c04dd02818100a5e278390b618190c686e8bbe91a29c2e8e9cdbea419b2725f5f7e59378f6c25fada22ff1cec891d250b75511c866c54f93d3ca05bba9e65eff2f29aab14a7ea3e83c73d9c876eaf6fc11504c5093ada16de6dac3588369ffb11f8154582d4ce3310d5fefdd94a6f18090a4a68e0ef85d4a8898b6b26e020986d0fef81a2ea4d02818036dce65f39ef0189f9f0768cc9efc392f937b00e2fd0db2e696f17fd6e0434dd11b9818679b951f84f71086ba9d002e8b22ecb955db7e283638fad2d13ee07c2648d34b128b6be6665e272cfbcfd2ac9cb77b9364c6fac3ae4a3ab5dd5c4b7c95bfd1e21422f0ffcbb97eb19fdb90f6c1de695b59fa6448fd86877126e3251490281807934611d6518687fecdeb3fc60d49200ed07b022046b163c853d13e7823614122818ec8b348a0ba134e90b5e29967a5f18014b63ebc20e6c73073386194cad67f5277a13a5643b568a342cf460375f3dec89b6dea5fa91d710aecf725368c5aea8173c14e54bb81c36169ce343805ee28d405bc777925f1ed1e0964d2c8e69dd02818073bfa2ced7b2911b5c8f9534bc5b0de8c13afeaf6d60ce5f0e6d3f732eb23a0c98586cbade606181b6c78825605c5d4b600f89aa08624c65dd649ffb093a914afe55b39943d1e10f509c67f5e344c73deaa5a10f94154a0df705942f98d8193675addb33d841a5a09f20c388898fda30b974cb9a4a6a74d5212d11a1f394971d"; |
|||
String req_url = "https://ipos.10086.cn/cps/cmpayService"; |
|||
String type = "AggregPayAmt"; |
|||
String version = "1.0.0"; |
|||
String deviceInfo = "sb001"; |
|||
String spbillCreateIp = "8.8.8.8"; |
|||
String storeBrand = "RBS-MD"; |
|||
String cityBranchNm = "RBS-PP"; |
|||
String createDate = DateUtil.getYearMonthDay2(); |
|||
|
|||
|
|||
// 签名数据
|
|||
StringBuilder signDate = new StringBuilder(); |
|||
signDate.append(PaymentConstant.CHARACTER_SET); |
|||
signDate.append(PaymentConstant.CALLBACK_URL); |
|||
signDate.append(PaymentConstant.NOTIFY_URL); |
|||
signDate.append(merchantId); |
|||
signDate.append(order.getRequestNo()); |
|||
signDate.append(PaymentConstant.SIGN_TYPE); |
|||
signDate.append(type); |
|||
signDate.append(version); |
|||
signDate.append(order.getOrderAmount()); |
|||
signDate.append(createDate); |
|||
switch (order.getOrderType()){ |
|||
case PaymentConstant.WEC : signDate.append(PaymentConstant.QRCWC); break; |
|||
case PaymentConstant.AL : signDate.append(PaymentConstant.QRCAL); break; |
|||
case PaymentConstant.CP : signDate.append(PaymentConstant.QRCCP); break; |
|||
} |
|||
signDate.append(order.getOrderNo()); |
|||
signDate.append(order.getGoodName()); |
|||
signDate.append(order.getReserved()); |
|||
logger.warn("signData:{}",signDate.toString()); |
|||
try{ |
|||
HiCASignUtil2 rsa = new HiCASignUtil2(privateKey, "111"); |
|||
StrBuilder requestParam = new StrBuilder(); |
|||
requestParam.append("hmac=").append(rsa.sign(signDate.toString())); |
|||
requestParam.append("&characterSet=").append(PaymentConstant.CHARACTER_SET); |
|||
requestParam.append("&callbackUrl=").append(PaymentConstant.CALLBACK_URL); |
|||
requestParam.append("¬ifyUrl=").append(PaymentConstant.NOTIFY_URL); |
|||
requestParam.append("&merchantId=").append(merchantId); |
|||
requestParam.append("&requestId=").append(order.getRequestNo()); |
|||
requestParam.append("&signType=").append(PaymentConstant.SIGN_TYPE); |
|||
requestParam.append("&type=").append(type); |
|||
requestParam.append("&version=").append(version); |
|||
requestParam.append("&amount=").append(order.getOrderAmount()); |
|||
requestParam.append("&orderDate=").append(createDate); |
|||
requestParam.append("&payWay="); |
|||
switch (order.getOrderType()){ |
|||
case PaymentConstant.WEC : requestParam.append(PaymentConstant.QRCWC); break; |
|||
case PaymentConstant.AL : requestParam.append(PaymentConstant.QRCAL); break; |
|||
case PaymentConstant.CP : requestParam.append(PaymentConstant.QRCCP); break; |
|||
} |
|||
requestParam.append("&orderId=").append(order.getOrderNo()); |
|||
requestParam.append("&productName=").append(order.getGoodName()); |
|||
requestParam.append("&reserved1=").append(order.getReserved()); |
|||
requestParam.append("&deviceInfo=").append(deviceInfo); |
|||
requestParam.append("&spbillCreateIp=").append(spbillCreateIp); |
|||
requestParam.append("&storeBrand=").append(storeBrand); |
|||
requestParam.append("&cityBranchNm=").append(cityBranchNm); |
|||
logger.warn("requestParam:{}",requestParam.toString()); |
|||
res = util.sendAndRecv(req_url, requestParam.toString(), PaymentConstant.CHARACTER_SET); |
|||
logger.warn(res); |
|||
}catch (Exception e){ |
|||
e.printStackTrace(); |
|||
} |
|||
return StringUtils.isNotBlank(res)?util.getValue(res, "sessionId"):""; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
package com.base.springcloud.service; |
|||
|
|||
import com.base.springcloud.entity.Order; |
|||
|
|||
public interface OrderService { |
|||
|
|||
// 订单登记
|
|||
void registerOrder(Order order); |
|||
} |
|||
@ -0,0 +1,532 @@ |
|||
package com.base.springcloud.util; |
|||
|
|||
import java.text.DateFormat; |
|||
import java.text.ParseException; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.Calendar; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 基于SimpleDateFormat的日期工具类 |
|||
* @author zql |
|||
* |
|||
* SimpleDateFormat 是线程不安全的类,一般不要定义为 static变量,如果定义为static,必须加锁,或者使用 DateUtils工具类。 |
|||
* 正例:注意线程安全,使用 DateUtils。亦推荐如下处理: |
|||
* private static final ThreadLocal<DateFormat> df = new ThreadLocal<DateFormat>() { |
|||
* @Override |
|||
* protected DateFormat initialValue() { |
|||
* return new SimpleDateFormat("yyyy-MM-dd"); |
|||
* } |
|||
* }; |
|||
* 说明:如果是JDK8 的应用,可以使用Instant代替Date,LocalDateTime代替Calendar, |
|||
* DateTimeFormatter代替 SimpleDateFormat,官方给出的解释:simple beautiful strong immutable thread-safe。 |
|||
* |
|||
*/ |
|||
public class DateUtil { |
|||
|
|||
/** |
|||
* 年,格式:yyyy |
|||
*/ |
|||
private final static SimpleDateFormat YEAR = new SimpleDateFormat("yyyy"); |
|||
/** |
|||
* 月,格式:MM |
|||
*/ |
|||
private final static SimpleDateFormat MONTH = new SimpleDateFormat("MM"); |
|||
/** |
|||
* 日,格式:dd |
|||
*/ |
|||
private final static SimpleDateFormat DAY = new SimpleDateFormat("dd"); |
|||
/** |
|||
* 小时,格式:HH |
|||
*/ |
|||
private final static SimpleDateFormat HOUR = new SimpleDateFormat("HH"); |
|||
/** |
|||
* 分钟,格式:mm |
|||
*/ |
|||
private final static SimpleDateFormat MINUTE = new SimpleDateFormat("mm"); |
|||
/** |
|||
* 秒钟,格式:ss |
|||
*/ |
|||
private final static SimpleDateFormat SECOND = new SimpleDateFormat("ss"); |
|||
/** |
|||
* 年月日,格式:yyyy-MM-dd |
|||
*/ |
|||
private final static SimpleDateFormat YEAR_MONTH_DAY = new SimpleDateFormat("yyyy-MM-dd"); |
|||
/** |
|||
* 年月日,格式:yyyyMMdd |
|||
*/ |
|||
private final static SimpleDateFormat YEAR_MONTH_DAY2 = new SimpleDateFormat("yyyyMMdd"); |
|||
/** |
|||
* 年月日时分秒,格式:yyyy-MM-dd HH:mm:ss |
|||
*/ |
|||
private final static SimpleDateFormat DATE = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|||
|
|||
/** |
|||
* 获取系统当前年份,yyyy格式 |
|||
* |
|||
* @return |
|||
*/ |
|||
public static String getYear() { |
|||
return YEAR.format(new Date()); |
|||
} |
|||
|
|||
/** |
|||
* 获取系统当前月份,MM格式 |
|||
* |
|||
* @return |
|||
*/ |
|||
public static String getMonth() { |
|||
return MONTH.format(new Date()); |
|||
} |
|||
|
|||
/** |
|||
* 获取系统当前日期,dd格式 |
|||
* |
|||
* @return |
|||
*/ |
|||
public static String getDay() { |
|||
return DAY.format(new Date()); |
|||
} |
|||
|
|||
/** |
|||
* 获取系统当前小时,HH格式 |
|||
* |
|||
* @return |
|||
*/ |
|||
public static String getHour() { |
|||
return HOUR.format(new Date()); |
|||
} |
|||
|
|||
/** |
|||
* 获取系统当前分钟,mm格式 |
|||
* |
|||
* @return |
|||
*/ |
|||
public static String getMinute() { |
|||
return MINUTE.format(new Date()); |
|||
} |
|||
|
|||
/** |
|||
* 获取系统当前秒钟,ss格式 |
|||
* |
|||
* @return |
|||
*/ |
|||
public static String getSecond() { |
|||
return SECOND.format(new Date()); |
|||
} |
|||
|
|||
/** |
|||
* 获取系统当前年月日,yyyy-MM-dd格式 |
|||
* |
|||
* @return |
|||
*/ |
|||
public static String getYearMonthDay() { |
|||
return YEAR_MONTH_DAY.format(new Date()); |
|||
} |
|||
|
|||
/** |
|||
* 获取系统当前年月日,yyyyMMdd格式 |
|||
* |
|||
* @return |
|||
*/ |
|||
public static String getYearMonthDay2() { |
|||
return YEAR_MONTH_DAY2.format(new Date()); |
|||
} |
|||
|
|||
/** |
|||
* 获取系统当前日期时间,yyyy-MM-dd HH:mm:ss格式 |
|||
* |
|||
* @return |
|||
*/ |
|||
public static String getDate() { |
|||
return DATE.format(new Date()); |
|||
} |
|||
|
|||
/** |
|||
* 根据传入的int数字获取系统当前时间 |
|||
* |
|||
* @param format 格式类型</br> |
|||
* 11 格式:yyyy-MM</br> |
|||
* 12 格式:MM-dd</br> |
|||
* 13 格式:yyyy-MM-dd</br> |
|||
* 14 格式:yyyy-MM-dd HH:mm</br> |
|||
* 15 格式:yyyy-MM-dd HH:mm:ss</br> |
|||
* 21 格式:yyyyMM</br> |
|||
* 22 格式:MMdd</br> |
|||
* 23 格式:yyyyMMdd</br> |
|||
* 24 格式:yyyyMMddHHmm</br> |
|||
* 25 格式:yyyyMMddHHmmss</br> |
|||
* 31 格式:yyyy/MM</br> |
|||
* 32 格式:MM/dd</br> |
|||
* 33 格式:yyyy/MM/dd</br> |
|||
* 34 格式:yyyy/MM/dd HH:mm</br> |
|||
* 35 格式:yyyy/MM/dd HH:mm:ss</br> |
|||
* 41 格式:yyyy年MM月</br> |
|||
* 42 格式:MM月dd日</br> |
|||
* 43 格式:yyyy年MM月dd日</br> |
|||
* 44 格式:yyyy年MM月dd日 HH时mm分</br> |
|||
* 45 格式:yyyy年MM月dd日 HH时mm分ss秒</br> |
|||
* 51 格式:HH:mm</br> |
|||
* 52 格式:HH:mm:ss</br> |
|||
* 53 格式:HH时mm分</br> |
|||
* 54 格式:HH时mm分ss秒</br> |
|||
* 默认格式yyyy-MM-dd |
|||
* @return 自定义的日期格式,共有24种 |
|||
*/ |
|||
public static String getDateString(int format){ |
|||
return getDefinedFormat(getYear(), getMonth(), getMonth(), getHour(), getMinute(), getSecond(),format); |
|||
} |
|||
|
|||
/** |
|||
* 时间戳转换为日期格式,根据传入的int数字获取确定要转换成的格式 |
|||
* |
|||
* @param times 时间戳 |
|||
* @param format 格式类型</br> |
|||
* 11 格式:yyyy-MM</br> |
|||
* 12 格式:MM-dd</br> |
|||
* 13 格式:yyyy-MM-dd</br> |
|||
* 14 格式:yyyy-MM-dd HH:mm</br> |
|||
* 15 格式:yyyy-MM-dd HH:mm:ss</br> |
|||
* 21 格式:yyyyMM</br> |
|||
* 22 格式:MMdd</br> |
|||
* 23 格式:yyyyMMdd</br> |
|||
* 24 格式:yyyyMMddHHmm</br> |
|||
* 25 格式:yyyyMMddHHmmss</br> |
|||
* 31 格式:yyyy/MM</br> |
|||
* 32 格式:MM/dd</br> |
|||
* 33 格式:yyyy/MM/dd</br> |
|||
* 34 格式:yyyy/MM/dd HH:mm</br> |
|||
* 35 格式:yyyy/MM/dd HH:mm:ss</br> |
|||
* 41 格式:yyyy年MM月</br> |
|||
* 42 格式:MM月dd日</br> |
|||
* 43 格式:yyyy年MM月dd日</br> |
|||
* 44 格式:yyyy年MM月dd日 HH时mm分</br> |
|||
* 45 格式:yyyy年MM月dd日 HH时mm分ss秒</br> |
|||
* 51 格式:HH:mm</br> |
|||
* 52 格式:HH:mm:ss</br> |
|||
* 53 格式:HH时mm分</br> |
|||
* 54 格式:HH时mm分ss秒</br> |
|||
* 默认格式yyyy-MM-dd |
|||
* @return 自定义的日期格式,共有24种 |
|||
*/ |
|||
public static String getDateString(String times, int format){ |
|||
long lt = new Long(times); |
|||
Date date = new Date(lt); |
|||
String year = YEAR.format(date); |
|||
String month = MONTH.format(date); |
|||
String day = DAY.format(date); |
|||
String hour = HOUR.format(date); |
|||
String minute = MINUTE.format(date); |
|||
String second = SECOND.format(date); |
|||
return getDefinedFormat(year, month, day, hour, minute, second, format); |
|||
} |
|||
|
|||
/** |
|||
* 把日期类型转换成字符串形式,根据传入的int数字获取确定要转换成的格式 |
|||
* |
|||
* @param date Date类型的日期 |
|||
* @param format 格式类型</br> |
|||
* 11 格式:yyyy-MM</br> |
|||
* 12 格式:MM-dd</br> |
|||
* 13 格式:yyyy-MM-dd</br> |
|||
* 14 格式:yyyy-MM-dd HH:mm</br> |
|||
* 15 格式:yyyy-MM-dd HH:mm:ss</br> |
|||
* 21 格式:yyyyMM</br> |
|||
* 22 格式:MMdd</br> |
|||
* 23 格式:yyyyMMdd</br> |
|||
* 24 格式:yyyyMMddHHmm</br> |
|||
* 25 格式:yyyyMMddHHmmss</br> |
|||
* 31 格式:yyyy/MM</br> |
|||
* 32 格式:MM/dd</br> |
|||
* 33 格式:yyyy/MM/dd</br> |
|||
* 34 格式:yyyy/MM/dd HH:mm</br> |
|||
* 35 格式:yyyy/MM/dd HH:mm:ss</br> |
|||
* 41 格式:yyyy年MM月</br> |
|||
* 42 格式:MM月dd日</br> |
|||
* 43 格式:yyyy年MM月dd日</br> |
|||
* 44 格式:yyyy年MM月dd日 HH时mm分</br> |
|||
* 45 格式:yyyy年MM月dd日 HH时mm分ss秒</br> |
|||
* 51 格式:HH:mm</br> |
|||
* 52 格式:HH:mm:ss</br> |
|||
* 53 格式:HH时mm分</br> |
|||
* 54 格式:HH时mm分ss秒</br> |
|||
* 默认格式yyyy-MM-dd |
|||
* @return 自定义的日期格式,共有24种 |
|||
*/ |
|||
public static String getDateString(Date date, int format){ |
|||
String year = YEAR.format(date); |
|||
String month = MONTH.format(date); |
|||
String day = DAY.format(date); |
|||
String hour = HOUR.format(date); |
|||
String minute = MINUTE.format(date); |
|||
String second = SECOND.format(date); |
|||
return getDefinedFormat(year, month, day, hour, minute, second, format); |
|||
} |
|||
|
|||
/** |
|||
* 自定义日期字符串 |
|||
* |
|||
* @param year 年 |
|||
* @param month 月 |
|||
* @param day 日 |
|||
* @param hour 时 |
|||
* @param minute 分 |
|||
* @param second 秒 |
|||
* @param format 格式类型</br> |
|||
* 11 格式:yyyy-MM</br> |
|||
* 12 格式:MM-dd</br> |
|||
* 13 格式:yyyy-MM-dd</br> |
|||
* 14 格式:yyyy-MM-dd HH:mm</br> |
|||
* 15 格式:yyyy-MM-dd HH:mm:ss</br> |
|||
* 21 格式:yyyyMM</br> |
|||
* 22 格式:MMdd</br> |
|||
* 23 格式:yyyyMMdd</br> |
|||
* 24 格式:yyyyMMddHHmm</br> |
|||
* 25 格式:yyyyMMddHHmmss</br> |
|||
* 31 格式:yyyy/MM</br> |
|||
* 32 格式:MM/dd</br> |
|||
* 33 格式:yyyy/MM/dd</br> |
|||
* 34 格式:yyyy/MM/dd HH:mm</br> |
|||
* 35 格式:yyyy/MM/dd HH:mm:ss</br> |
|||
* 41 格式:yyyy年MM月</br> |
|||
* 42 格式:MM月dd日</br> |
|||
* 43 格式:yyyy年MM月dd日</br> |
|||
* 44 格式:yyyy年MM月dd日 HH时mm分</br> |
|||
* 45 格式:yyyy年MM月dd日 HH时mm分ss秒</br> |
|||
* 51 格式:HH:mm</br> |
|||
* 52 格式:HH:mm:ss</br> |
|||
* 53 格式:HH时mm分</br> |
|||
* 54 格式:HH时mm分ss秒</br> |
|||
* 默认格式yyyy-MM-dd |
|||
* @return |
|||
*/ |
|||
public static String getDefinedFormat(String year, String month, String day, String hour, String minute, String second, int format){ |
|||
String dateStr = null; |
|||
switch (format) { |
|||
case 11: |
|||
dateStr = year + "-" + month; |
|||
break; |
|||
case 12: |
|||
dateStr = month + "-" +day; |
|||
break; |
|||
case 13: |
|||
dateStr = year + "-" + month + "-" +day; |
|||
break; |
|||
case 14: |
|||
dateStr = year + "-" + month + "-" +day + " " + hour +":"+minute; |
|||
break; |
|||
case 15: |
|||
dateStr = year + "-" + month + "-" +day + " " + hour +":" + minute + ":" + second; |
|||
break; |
|||
case 21: |
|||
dateStr = year + month; |
|||
break; |
|||
case 22: |
|||
dateStr = month + day; |
|||
break; |
|||
case 23: |
|||
dateStr = year + month + day; |
|||
break; |
|||
case 24: |
|||
dateStr = year + month +day + hour + minute; |
|||
break; |
|||
case 25: |
|||
dateStr = year + month + day + hour + minute + second; |
|||
break; |
|||
case 31: |
|||
dateStr = year + "/" + month; |
|||
break; |
|||
case 32: |
|||
dateStr = month + "/" +day; |
|||
break; |
|||
case 33: |
|||
dateStr = year + "/" + month + "/" +day; |
|||
break; |
|||
case 34: |
|||
dateStr = year + "/" + month + "/" +day + " " + hour +":"+minute; |
|||
break; |
|||
case 35: |
|||
dateStr = year + "/" + month + "/" +day + " " + hour +":" + minute + ":" + second; |
|||
break; |
|||
case 41: |
|||
dateStr = year + "年" + month + "月"; |
|||
break; |
|||
case 42: |
|||
dateStr = month + "月" +day + "日"; |
|||
break; |
|||
case 43: |
|||
dateStr = year + "年" + month + "月" +day + "日"; |
|||
break; |
|||
case 44: |
|||
dateStr = year + "年" + month + "月" +day + "日" +" "+ hour + "时" + minute +"分"; |
|||
break; |
|||
case 45: |
|||
dateStr = year + "年" + month + "月" +day + "日" +" "+ hour + "时" + minute + "分" +second+ "秒"; |
|||
break; |
|||
case 51: |
|||
dateStr = hour + ":" + minute; |
|||
break; |
|||
case 52: |
|||
dateStr = hour + ":" + minute + ":" +second; |
|||
break; |
|||
case 53: |
|||
dateStr = hour + "时" + minute + "分"; |
|||
break; |
|||
case 54: |
|||
dateStr = hour + "时" + minute + "分" +second + "秒"; |
|||
break; |
|||
default: |
|||
dateStr = year + "-" +month+ "-" + day; |
|||
} |
|||
return dateStr; |
|||
} |
|||
|
|||
/** |
|||
* 获取SimpleDateFormat的日期 |
|||
* |
|||
* @param date 传入的日期 |
|||
* @param format 自定义格式,例:yyyy-MM-dd |
|||
* @return |
|||
*/ |
|||
public static String getSimpleDateFormat(Date date, String format){ |
|||
SimpleDateFormat sdf = new SimpleDateFormat(format); |
|||
return sdf.format(date); |
|||
} |
|||
|
|||
/** |
|||
* 日期比较 |
|||
* |
|||
* @param startDate 开始日期,格式yyyy-MM-dd |
|||
* @param endDate 结束日期,格式yyyy-MM-dd |
|||
* @return 如果startDate>endDate,返回1,startDate=endDate返回0,startDate<endDate返回-1 |
|||
*/ |
|||
public static Integer compareDate(String startDate, String endDate) { |
|||
if (fomatDate(startDate) == null || fomatDate(endDate) == null) { |
|||
return null; |
|||
} |
|||
int r = 0; |
|||
if (fomatDate(startDate).getTime() > fomatDate(endDate).getTime()) { |
|||
r = 1; |
|||
} |
|||
if (fomatDate(startDate).getTime() < fomatDate(endDate).getTime()) { |
|||
r = -1; |
|||
} |
|||
return r; |
|||
} |
|||
|
|||
/** |
|||
* 格式化日期 |
|||
* |
|||
* @param dateStr日期字符串,格式:yyyy-MM-dd |
|||
* @return 返回null说明格式错误 |
|||
*/ |
|||
public static Date fomatDate(String dateStr) { |
|||
try { |
|||
return YEAR_MONTH_DAY.parse(dateStr); |
|||
} catch (ParseException e) { |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 校验日期是否合法,格式:yyyy-MM-dd |
|||
* |
|||
* @param dateStr日期字符串 |
|||
* @return |
|||
*/ |
|||
public static boolean isValidDate(String dateStr) { |
|||
try { |
|||
YEAR_MONTH_DAY.parse(dateStr); |
|||
return true; |
|||
} catch (Exception e) { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 校验日期是否合法 |
|||
* |
|||
* @param dateStr 日期字符串 |
|||
* @param format 格式,例:yyyy-MM-dd |
|||
* @return |
|||
*/ |
|||
public static boolean isValidDateFormat(String dateStr, String format) { |
|||
DateFormat fmt = new SimpleDateFormat(format); |
|||
try { |
|||
fmt.parse(dateStr); |
|||
return true; |
|||
} catch (Exception e) { |
|||
// 如果throw java.text.ParseException或者NullPointerException,就说明格式不对
|
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 时间相减得到年份,不够365天算0年 |
|||
* |
|||
* @param startDate 开始日期,格式yyyy-MM-dd |
|||
* @param endDate 结束日期,格式yyyy-MM-dd |
|||
* @return 返回相隔的年数,null表示格式不正确出现异常 |
|||
*/ |
|||
public static Integer getDiffYear(String startDate, String endDate) { |
|||
try { |
|||
int years = (int) (((fomatDate(endDate).getTime() - fomatDate(startDate).getTime()) / (1000 * 60 * 60 * 24)) / 365); |
|||
return years; |
|||
} catch (Exception e) { |
|||
// 如果throw,就说明格式不对
|
|||
return null; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 时间相减得到天数 |
|||
* |
|||
* @param startDate 开始日期,格式yyyy-MM-dd |
|||
* @param endDate 结束日期,格式yyyy-MM-dd |
|||
* @return 返回相隔的天数,null表示格式不正确出现异常 |
|||
*/ |
|||
public static Integer getDaySub(String startDate, String endDate){ |
|||
try { |
|||
int days = (int) (((fomatDate(endDate).getTime() - fomatDate(startDate).getTime()) / (1000 * 60 * 60 * 24))); |
|||
return days; |
|||
} catch (Exception e) { |
|||
// 如果throw,就说明格式不对
|
|||
return null; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 得到n天之后的日期 |
|||
* |
|||
* @param days |
|||
* @return |
|||
*/ |
|||
public static String getAfterDayDate(int days) { |
|||
// java.util包
|
|||
Calendar canlendar = Calendar.getInstance(); |
|||
// 日期相减,如果不够减将会向月变动
|
|||
canlendar.add(Calendar.DATE, days); |
|||
Date date = canlendar.getTime(); |
|||
|
|||
return DATE.format(date); |
|||
} |
|||
|
|||
/** |
|||
* 得到n天之后是周几 |
|||
* |
|||
* @param days |
|||
* @return |
|||
*/ |
|||
public static String getAfterDayWeek(int days) { |
|||
// java.util包
|
|||
Calendar canlendar = Calendar.getInstance(); |
|||
// 日期相减,如果不够减将会向月变动
|
|||
canlendar.add(Calendar.DATE, days); |
|||
Date date = canlendar.getTime(); |
|||
|
|||
SimpleDateFormat sdf = new SimpleDateFormat("E"); |
|||
|
|||
return sdf.format(date); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,251 @@ |
|||
package com.base.springcloud.util; |
|||
|
|||
import java.math.BigDecimal; |
|||
|
|||
public class DecimalUtils { |
|||
|
|||
/** |
|||
* 加法计算(result = x + y) |
|||
* |
|||
* @param x 被加数(可为null) |
|||
* @param y 加数 (可为null) |
|||
* @return 和 (可为null) |
|||
* @author dengcs |
|||
*/ |
|||
public static BigDecimal add(BigDecimal x, BigDecimal y) { |
|||
if (x == null) { |
|||
return y; |
|||
} |
|||
if (y == null) { |
|||
return x; |
|||
} |
|||
return x.add(y); |
|||
} |
|||
|
|||
/** |
|||
* 加法计算(result = a + b + c + d) |
|||
* |
|||
* @param a 被加数(可为null) |
|||
* @param b 加数(可为null) |
|||
* @param c 加数(可为null) |
|||
* @param d 加数(可为null) |
|||
* @return BigDecimal (可为null) |
|||
* @author dengcs |
|||
*/ |
|||
public static BigDecimal add(BigDecimal a, BigDecimal b, BigDecimal c, BigDecimal d) { |
|||
BigDecimal ab = add(a, b); |
|||
BigDecimal cd = add(c, d); |
|||
return add(ab, cd); |
|||
} |
|||
|
|||
/** |
|||
* 累加计算(result=x + result) |
|||
* |
|||
* @param x 被加数(可为null) |
|||
* @param result 和 (可为null,若被加数不为为null,result默认值为0) |
|||
* @return result 和 (可为null) |
|||
* @author dengcs |
|||
*/ |
|||
public static BigDecimal accumulate(BigDecimal x, BigDecimal result) { |
|||
if (x == null) { |
|||
return result; |
|||
} |
|||
if (result == null) { |
|||
result = new BigDecimal("0"); |
|||
} |
|||
return result.add(x); |
|||
} |
|||
|
|||
/** |
|||
* 减法计算(result = x - y) |
|||
* |
|||
* @param x 被减数(可为null) |
|||
* @param y 减数(可为null) |
|||
* @return BigDecimal 差 (可为null) |
|||
* @author dengcs |
|||
*/ |
|||
public static BigDecimal subtract(BigDecimal x, BigDecimal y) { |
|||
if (x == null || y == null) { |
|||
return null; |
|||
} |
|||
return x.subtract(y); |
|||
} |
|||
|
|||
/** |
|||
* 乘法计算(result = x × y) |
|||
* |
|||
* @param x 乘数(可为null) |
|||
* @param y 乘数(可为null) |
|||
* @return BigDecimal 积 |
|||
* @author dengcs |
|||
*/ |
|||
public static BigDecimal multiply(BigDecimal x, BigDecimal y) { |
|||
if (x == null || y == null) { |
|||
return null; |
|||
} |
|||
return x.multiply(y); |
|||
} |
|||
|
|||
/** |
|||
* 除法计算(result = x ÷ y) |
|||
* |
|||
* @param x 被除数(可为null) |
|||
* @param y 除数(可为null) |
|||
* @return 商 (可为null,四舍五入,默认保留20位小数) |
|||
* @author dengcs |
|||
*/ |
|||
public static BigDecimal divide(BigDecimal x, BigDecimal y) { |
|||
if (x == null || y == null || y.compareTo(BigDecimal.ZERO) == 0) { |
|||
return null; |
|||
} |
|||
// 结果为0.000..时,不用科学计数法展示
|
|||
return stripTrailingZeros(x.divide(y, 20, BigDecimal.ROUND_HALF_UP)); |
|||
} |
|||
|
|||
/** |
|||
* 转为字符串(防止返回可续计数法表达式) |
|||
* |
|||
* @param x 要转字符串的小数 |
|||
* @return String |
|||
* @author dengcs |
|||
*/ |
|||
public static String toPlainString(BigDecimal x) { |
|||
if (x == null) { |
|||
return null; |
|||
} |
|||
return x.toPlainString(); |
|||
} |
|||
|
|||
/** |
|||
* 保留小数位数 |
|||
* |
|||
* @param x 目标小数 |
|||
* @param scale 要保留小数位数 |
|||
* @return BigDecimal 结果四舍五入 |
|||
* @author dengcs |
|||
*/ |
|||
public static BigDecimal scale(BigDecimal x, int scale) { |
|||
if (x == null) { |
|||
return null; |
|||
} |
|||
return x.setScale(scale, BigDecimal.ROUND_HALF_UP); |
|||
} |
|||
|
|||
/** |
|||
* 整型转为BigDecimal |
|||
* |
|||
* @param x(可为null) |
|||
* @return BigDecimal (可为null) |
|||
* @author dengcs |
|||
*/ |
|||
public static BigDecimal toBigDecimal(Integer x) { |
|||
if (x == null) { |
|||
return null; |
|||
} |
|||
return new BigDecimal(x.toString()); |
|||
} |
|||
|
|||
/** |
|||
* 长整型转为BigDecimal |
|||
* |
|||
* @param x(可为null) |
|||
* @return BigDecimal (可为null) |
|||
* @author dengcs |
|||
*/ |
|||
public static BigDecimal toBigDecimal(Long x) { |
|||
if (x == null) { |
|||
return null; |
|||
} |
|||
return new BigDecimal(x.toString()); |
|||
} |
|||
|
|||
/** |
|||
* 双精度型转为BigDecimal |
|||
* |
|||
* @param x(可为null) |
|||
* @return BigDecimal (可为null) |
|||
* @author dengcs |
|||
*/ |
|||
public static BigDecimal toBigDecimal(Double x) { |
|||
if (x == null) { |
|||
return null; |
|||
} |
|||
return new BigDecimal(x.toString()); |
|||
} |
|||
|
|||
/** |
|||
* 单精度型转为BigDecimal |
|||
* |
|||
* @param x(可为null) |
|||
* @return BigDecimal (可为null) |
|||
* @author dengcs |
|||
*/ |
|||
public static BigDecimal toBigDecimal(Float x) { |
|||
if (x == null) { |
|||
return null; |
|||
} |
|||
return new BigDecimal(x.toString()); |
|||
} |
|||
|
|||
/** |
|||
* 字符串型转为BigDecimal |
|||
* |
|||
* @param x(可为null) |
|||
* @return BigDecimal (可为null) |
|||
* @author dengcs |
|||
*/ |
|||
public static BigDecimal toBigDecimal(String x) { |
|||
if (x == null) { |
|||
return null; |
|||
} |
|||
return new BigDecimal(x); |
|||
} |
|||
|
|||
/** |
|||
* 对象类型转为BigDecimal |
|||
* |
|||
* @param x(可为null) |
|||
* @return BigDecimal (可为null) |
|||
* @author dengcs |
|||
*/ |
|||
public static BigDecimal toBigDecimal(Object x) { |
|||
if (x == null) { |
|||
return null; |
|||
} |
|||
BigDecimal result = null; |
|||
try { |
|||
result = new BigDecimal(x.toString()); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
/** |
|||
* 倍数计算,用于单位换算 |
|||
* |
|||
* @param x 目标数(可为null) |
|||
* @param multiple 倍数 (可为null) |
|||
* @return BigDecimal (可为null) |
|||
* @author dengcs |
|||
*/ |
|||
public static BigDecimal multiple(BigDecimal x, Integer multiple) { |
|||
if (x == null || multiple == null) { |
|||
return null; |
|||
} |
|||
return DecimalUtils.multiply(x, toBigDecimal(multiple)); |
|||
} |
|||
|
|||
/** |
|||
* 去除小数点后的0(如: 输入1.000返回1) |
|||
* |
|||
* @param x 目标数(可为null) |
|||
* @return |
|||
*/ |
|||
public static BigDecimal stripTrailingZeros(BigDecimal x) { |
|||
if (x == null) { |
|||
return null; |
|||
} |
|||
return x.stripTrailingZeros(); |
|||
} |
|||
} |
|||
@ -1,472 +0,0 @@ |
|||
<?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.base.springcloud.dao.MerchantMapper"> |
|||
<resultMap id="BaseResultMap" type="com.base.springcloud.entity.Merchant"> |
|||
<id column="id" jdbcType="VARCHAR" property="id" /> |
|||
<result column="merchant_id" jdbcType="VARCHAR" property="merchantId" /> |
|||
<result column="merchant_name" jdbcType="VARCHAR" property="merchantName" /> |
|||
<result column="city_store_name" jdbcType="VARCHAR" property="cityStoreName" /> |
|||
<result column="store_brand_name" jdbcType="VARCHAR" property="storeBrandName" /> |
|||
<result column="sign_type" jdbcType="VARCHAR" property="signType" /> |
|||
<result column="private_key" jdbcType="VARCHAR" property="privateKey" /> |
|||
<result column="device_info" jdbcType="VARCHAR" property="deviceInfo" /> |
|||
<result column="spbill_create_ip" jdbcType="VARCHAR" property="spbillCreateIp" /> |
|||
<result column="notify_url" jdbcType="VARCHAR" property="notifyUrl" /> |
|||
<result column="time_stamp" jdbcType="TIMESTAMP" property="timeStamp" /> |
|||
</resultMap> |
|||
<sql id="Base_Column_List"> |
|||
id, merchant_id, merchant_name, city_store_name, store_brand_name, sign_type, private_key, |
|||
device_info, spbill_create_ip, notify_url, time_stamp |
|||
</sql> |
|||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from pay_merchant |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</select> |
|||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String"> |
|||
delete from pay_merchant |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</delete> |
|||
<insert id="insert" parameterType="com.base.springcloud.entity.Merchant"> |
|||
insert into pay_merchant (id, merchant_id, merchant_name, |
|||
city_store_name, store_brand_name, sign_type, |
|||
private_key, device_info, spbill_create_ip, |
|||
notify_url, time_stamp) |
|||
values (#{id,jdbcType=VARCHAR}, #{merchantId,jdbcType=VARCHAR}, #{merchantName,jdbcType=VARCHAR}, |
|||
#{cityStoreName,jdbcType=VARCHAR}, #{storeBrandName,jdbcType=VARCHAR}, #{signType,jdbcType=VARCHAR}, |
|||
#{privateKey,jdbcType=VARCHAR}, #{deviceInfo,jdbcType=VARCHAR}, #{spbillCreateIp,jdbcType=VARCHAR}, |
|||
#{notifyUrl,jdbcType=VARCHAR}, #{timeStamp,jdbcType=TIMESTAMP}) |
|||
</insert> |
|||
<insert id="insertSelective" parameterType="com.base.springcloud.entity.Merchant"> |
|||
insert into pay_merchant |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
id, |
|||
</if> |
|||
<if test="merchantId != null"> |
|||
merchant_id, |
|||
</if> |
|||
<if test="merchantName != null"> |
|||
merchant_name, |
|||
</if> |
|||
<if test="cityStoreName != null"> |
|||
city_store_name, |
|||
</if> |
|||
<if test="storeBrandName != null"> |
|||
store_brand_name, |
|||
</if> |
|||
<if test="signType != null"> |
|||
sign_type, |
|||
</if> |
|||
<if test="privateKey != null"> |
|||
private_key, |
|||
</if> |
|||
<if test="deviceInfo != null"> |
|||
device_info, |
|||
</if> |
|||
<if test="spbillCreateIp != null"> |
|||
spbill_create_ip, |
|||
</if> |
|||
<if test="notifyUrl != null"> |
|||
notify_url, |
|||
</if> |
|||
<if test="timeStamp != null"> |
|||
time_stamp, |
|||
</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
#{id,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="merchantId != null"> |
|||
#{merchantId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="merchantName != null"> |
|||
#{merchantName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="cityStoreName != null"> |
|||
#{cityStoreName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="storeBrandName != null"> |
|||
#{storeBrandName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="signType != null"> |
|||
#{signType,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="privateKey != null"> |
|||
#{privateKey,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="deviceInfo != null"> |
|||
#{deviceInfo,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="spbillCreateIp != null"> |
|||
#{spbillCreateIp,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="notifyUrl != null"> |
|||
#{notifyUrl,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="timeStamp != null"> |
|||
#{timeStamp,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
</trim> |
|||
</insert> |
|||
<update id="updateByPrimaryKeySelective" parameterType="com.base.springcloud.entity.Merchant"> |
|||
update pay_merchant |
|||
<set> |
|||
<if test="merchantId != null"> |
|||
merchant_id = #{merchantId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="merchantName != null"> |
|||
merchant_name = #{merchantName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="cityStoreName != null"> |
|||
city_store_name = #{cityStoreName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="storeBrandName != null"> |
|||
store_brand_name = #{storeBrandName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="signType != null"> |
|||
sign_type = #{signType,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="privateKey != null"> |
|||
private_key = #{privateKey,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="deviceInfo != null"> |
|||
device_info = #{deviceInfo,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="spbillCreateIp != null"> |
|||
spbill_create_ip = #{spbillCreateIp,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="notifyUrl != null"> |
|||
notify_url = #{notifyUrl,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="timeStamp != null"> |
|||
time_stamp = #{timeStamp,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
</set> |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<update id="updateByPrimaryKey" parameterType="com.base.springcloud.entity.Merchant"> |
|||
update pay_merchant |
|||
set merchant_id = #{merchantId,jdbcType=VARCHAR}, |
|||
merchant_name = #{merchantName,jdbcType=VARCHAR}, |
|||
city_store_name = #{cityStoreName,jdbcType=VARCHAR}, |
|||
store_brand_name = #{storeBrandName,jdbcType=VARCHAR}, |
|||
sign_type = #{signType,jdbcType=VARCHAR}, |
|||
private_key = #{privateKey,jdbcType=VARCHAR}, |
|||
device_info = #{deviceInfo,jdbcType=VARCHAR}, |
|||
spbill_create_ip = #{spbillCreateIp,jdbcType=VARCHAR}, |
|||
notify_url = #{notifyUrl,jdbcType=VARCHAR}, |
|||
time_stamp = #{timeStamp,jdbcType=TIMESTAMP} |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<resultMap id="BaseResultMap" type="com.base.springcloud.entity.Merchant"> |
|||
<constructor> |
|||
<idArg column="id" javaType="java.lang.String" jdbcType="VARCHAR" /> |
|||
<arg column="merchant_id" javaType="java.lang.String" jdbcType="VARCHAR" /> |
|||
<arg column="merchant_name" javaType="java.lang.String" jdbcType="VARCHAR" /> |
|||
<arg column="city_store_name" javaType="java.lang.String" jdbcType="VARCHAR" /> |
|||
<arg column="store_brand_name" javaType="java.lang.String" jdbcType="VARCHAR" /> |
|||
<arg column="time_stamp" javaType="java.util.Date" jdbcType="TIMESTAMP" /> |
|||
</constructor> |
|||
</resultMap> |
|||
<sql id="Base_Column_List"> |
|||
id, merchant_id, merchant_name, city_store_name, store_brand_name, time_stamp |
|||
</sql> |
|||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from pay_merchant |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</select> |
|||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String"> |
|||
delete from pay_merchant |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</delete> |
|||
<insert id="insert" parameterType="com.base.springcloud.entity.Merchant"> |
|||
insert into pay_merchant (id, merchant_id, merchant_name, |
|||
city_store_name, store_brand_name, time_stamp |
|||
) |
|||
values (#{id,jdbcType=VARCHAR}, #{merchantId,jdbcType=VARCHAR}, #{merchantName,jdbcType=VARCHAR}, |
|||
#{cityStoreName,jdbcType=VARCHAR}, #{storeBrandName,jdbcType=VARCHAR}, #{timeStamp,jdbcType=TIMESTAMP} |
|||
) |
|||
</insert> |
|||
<insert id="insertSelective" parameterType="com.base.springcloud.entity.Merchant"> |
|||
insert into pay_merchant |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
id, |
|||
</if> |
|||
<if test="merchantId != null"> |
|||
merchant_id, |
|||
</if> |
|||
<if test="merchantName != null"> |
|||
merchant_name, |
|||
</if> |
|||
<if test="cityStoreName != null"> |
|||
city_store_name, |
|||
</if> |
|||
<if test="storeBrandName != null"> |
|||
store_brand_name, |
|||
</if> |
|||
<if test="timeStamp != null"> |
|||
time_stamp, |
|||
</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
#{id,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="merchantId != null"> |
|||
#{merchantId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="merchantName != null"> |
|||
#{merchantName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="cityStoreName != null"> |
|||
#{cityStoreName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="storeBrandName != null"> |
|||
#{storeBrandName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="timeStamp != null"> |
|||
#{timeStamp,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
</trim> |
|||
</insert> |
|||
<update id="updateByPrimaryKeySelective" parameterType="com.base.springcloud.entity.Merchant"> |
|||
update pay_merchant |
|||
<set> |
|||
<if test="merchantId != null"> |
|||
merchant_id = #{merchantId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="merchantName != null"> |
|||
merchant_name = #{merchantName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="cityStoreName != null"> |
|||
city_store_name = #{cityStoreName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="storeBrandName != null"> |
|||
store_brand_name = #{storeBrandName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="timeStamp != null"> |
|||
time_stamp = #{timeStamp,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
</set> |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<update id="updateByPrimaryKey" parameterType="com.base.springcloud.entity.Merchant"> |
|||
update pay_merchant |
|||
set merchant_id = #{merchantId,jdbcType=VARCHAR}, |
|||
merchant_name = #{merchantName,jdbcType=VARCHAR}, |
|||
city_store_name = #{cityStoreName,jdbcType=VARCHAR}, |
|||
store_brand_name = #{storeBrandName,jdbcType=VARCHAR}, |
|||
time_stamp = #{timeStamp,jdbcType=TIMESTAMP} |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<resultMap id="BaseResultMap" type="com.base.springcloud.entity.Merchant"> |
|||
<id column="id" jdbcType="VARCHAR" property="id" /> |
|||
<result column="merchant_id" jdbcType="VARCHAR" property="merchantId" /> |
|||
<result column="merchant_name" jdbcType="VARCHAR" property="merchantName" /> |
|||
<result column="city_store_name" jdbcType="VARCHAR" property="cityStoreName" /> |
|||
<result column="store_brand_name" jdbcType="VARCHAR" property="storeBrandName" /> |
|||
<result column="time_stamp" jdbcType="TIMESTAMP" property="timeStamp" /> |
|||
</resultMap> |
|||
<sql id="Base_Column_List"> |
|||
id, merchant_id, merchant_name, city_store_name, store_brand_name, time_stamp |
|||
</sql> |
|||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from pay_merchant |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</select> |
|||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String"> |
|||
delete from pay_merchant |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</delete> |
|||
<insert id="insert" parameterType="com.base.springcloud.entity.Merchant"> |
|||
insert into pay_merchant (id, merchant_id, merchant_name, |
|||
city_store_name, store_brand_name, time_stamp |
|||
) |
|||
values (#{id,jdbcType=VARCHAR}, #{merchantId,jdbcType=VARCHAR}, #{merchantName,jdbcType=VARCHAR}, |
|||
#{cityStoreName,jdbcType=VARCHAR}, #{storeBrandName,jdbcType=VARCHAR}, #{timeStamp,jdbcType=TIMESTAMP} |
|||
) |
|||
</insert> |
|||
<insert id="insertSelective" parameterType="com.base.springcloud.entity.Merchant"> |
|||
insert into pay_merchant |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
id, |
|||
</if> |
|||
<if test="merchantId != null"> |
|||
merchant_id, |
|||
</if> |
|||
<if test="merchantName != null"> |
|||
merchant_name, |
|||
</if> |
|||
<if test="cityStoreName != null"> |
|||
city_store_name, |
|||
</if> |
|||
<if test="storeBrandName != null"> |
|||
store_brand_name, |
|||
</if> |
|||
<if test="timeStamp != null"> |
|||
time_stamp, |
|||
</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
#{id,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="merchantId != null"> |
|||
#{merchantId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="merchantName != null"> |
|||
#{merchantName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="cityStoreName != null"> |
|||
#{cityStoreName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="storeBrandName != null"> |
|||
#{storeBrandName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="timeStamp != null"> |
|||
#{timeStamp,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
</trim> |
|||
</insert> |
|||
<update id="updateByPrimaryKeySelective" parameterType="com.base.springcloud.entity.Merchant"> |
|||
update pay_merchant |
|||
<set> |
|||
<if test="merchantId != null"> |
|||
merchant_id = #{merchantId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="merchantName != null"> |
|||
merchant_name = #{merchantName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="cityStoreName != null"> |
|||
city_store_name = #{cityStoreName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="storeBrandName != null"> |
|||
store_brand_name = #{storeBrandName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="timeStamp != null"> |
|||
time_stamp = #{timeStamp,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
</set> |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<update id="updateByPrimaryKey" parameterType="com.base.springcloud.entity.Merchant"> |
|||
update pay_merchant |
|||
set merchant_id = #{merchantId,jdbcType=VARCHAR}, |
|||
merchant_name = #{merchantName,jdbcType=VARCHAR}, |
|||
city_store_name = #{cityStoreName,jdbcType=VARCHAR}, |
|||
store_brand_name = #{storeBrandName,jdbcType=VARCHAR}, |
|||
time_stamp = #{timeStamp,jdbcType=TIMESTAMP} |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<resultMap id="BaseResultMap" type="com.base.springcloud.entity.Merchant"> |
|||
<id column="id" jdbcType="VARCHAR" property="id" /> |
|||
<result column="merchant_id" jdbcType="VARCHAR" property="merchantId" /> |
|||
<result column="merchant_name" jdbcType="VARCHAR" property="merchantName" /> |
|||
<result column="city_store_name" jdbcType="VARCHAR" property="cityStoreName" /> |
|||
<result column="store_brand_name" jdbcType="VARCHAR" property="storeBrandName" /> |
|||
<result column="time_stamp" jdbcType="TIMESTAMP" property="timeStamp" /> |
|||
</resultMap> |
|||
<sql id="Base_Column_List"> |
|||
id, merchant_id, merchant_name, city_store_name, store_brand_name, time_stamp |
|||
</sql> |
|||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from pay_merchant |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</select> |
|||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String"> |
|||
delete from pay_merchant |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</delete> |
|||
<insert id="insert" parameterType="com.base.springcloud.entity.Merchant"> |
|||
insert into pay_merchant (id, merchant_id, merchant_name, |
|||
city_store_name, store_brand_name, time_stamp |
|||
) |
|||
values (#{id,jdbcType=VARCHAR}, #{merchantId,jdbcType=VARCHAR}, #{merchantName,jdbcType=VARCHAR}, |
|||
#{cityStoreName,jdbcType=VARCHAR}, #{storeBrandName,jdbcType=VARCHAR}, #{timeStamp,jdbcType=TIMESTAMP} |
|||
) |
|||
</insert> |
|||
<insert id="insertSelective" parameterType="com.base.springcloud.entity.Merchant"> |
|||
insert into pay_merchant |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
id, |
|||
</if> |
|||
<if test="merchantId != null"> |
|||
merchant_id, |
|||
</if> |
|||
<if test="merchantName != null"> |
|||
merchant_name, |
|||
</if> |
|||
<if test="cityStoreName != null"> |
|||
city_store_name, |
|||
</if> |
|||
<if test="storeBrandName != null"> |
|||
store_brand_name, |
|||
</if> |
|||
<if test="timeStamp != null"> |
|||
time_stamp, |
|||
</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
#{id,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="merchantId != null"> |
|||
#{merchantId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="merchantName != null"> |
|||
#{merchantName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="cityStoreName != null"> |
|||
#{cityStoreName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="storeBrandName != null"> |
|||
#{storeBrandName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="timeStamp != null"> |
|||
#{timeStamp,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
</trim> |
|||
</insert> |
|||
<update id="updateByPrimaryKeySelective" parameterType="com.base.springcloud.entity.Merchant"> |
|||
update pay_merchant |
|||
<set> |
|||
<if test="merchantId != null"> |
|||
merchant_id = #{merchantId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="merchantName != null"> |
|||
merchant_name = #{merchantName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="cityStoreName != null"> |
|||
city_store_name = #{cityStoreName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="storeBrandName != null"> |
|||
store_brand_name = #{storeBrandName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="timeStamp != null"> |
|||
time_stamp = #{timeStamp,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
</set> |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<update id="updateByPrimaryKey" parameterType="com.base.springcloud.entity.Merchant"> |
|||
update pay_merchant |
|||
set merchant_id = #{merchantId,jdbcType=VARCHAR}, |
|||
merchant_name = #{merchantName,jdbcType=VARCHAR}, |
|||
city_store_name = #{cityStoreName,jdbcType=VARCHAR}, |
|||
store_brand_name = #{storeBrandName,jdbcType=VARCHAR}, |
|||
time_stamp = #{timeStamp,jdbcType=TIMESTAMP} |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
</mapper> |
|||
Loading…
Reference in new issue