parent
5cf0af8aaa
commit
0e913ece8d
@ -0,0 +1,36 @@ |
|||||||
|
package com.hai.common; |
||||||
|
|
||||||
|
import java.util.Calendar; |
||||||
|
import java.util.Random; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Auther: 胡锐 |
||||||
|
* @Description: |
||||||
|
* @Date: 2021/3/18 21:07 |
||||||
|
*/ |
||||||
|
public class generateCode { |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @Author 胡锐 |
||||||
|
* @Description 生成卡卷销售码 21位 毫秒+随机字符串 |
||||||
|
* @Date 2021/3/18 21:08 |
||||||
|
**/ |
||||||
|
public static String couponSalesCode(Long merchantId,Long couponId) { |
||||||
|
// 默认3位时间毫秒
|
||||||
|
String val = merchantId + "" + couponId; |
||||||
|
Random random = new Random(); |
||||||
|
for (int i = 0; i < 21; i++) { |
||||||
|
// 输出字母还是数字
|
||||||
|
String charOrNum = random.nextInt(2) % 2 == 0 ? "char" : "num"; |
||||||
|
if ("char".equalsIgnoreCase(charOrNum)) { |
||||||
|
// 取得大写字母还是小写字母
|
||||||
|
int choice = random.nextInt(2) % 2 == 0 ? 65 : 97; |
||||||
|
val += (char) (choice + random.nextInt(26)); |
||||||
|
} else if ("num".equalsIgnoreCase(charOrNum)) { // 数字
|
||||||
|
val += String.valueOf(random.nextInt(10)); |
||||||
|
} |
||||||
|
} |
||||||
|
return val; |
||||||
|
} |
||||||
|
} |
@ -1,7 +1,45 @@ |
|||||||
package com.hai.dao; |
package com.hai.dao; |
||||||
|
|
||||||
|
import com.hai.entity.HighCouponCode; |
||||||
|
import org.apache.ibatis.annotations.Insert; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
/** |
/** |
||||||
* mapper扩展类 |
* mapper扩展类 |
||||||
*/ |
*/ |
||||||
public interface HighCouponCodeMapperExt { |
public interface HighCouponCodeMapperExt { |
||||||
|
|
||||||
|
@Insert({ |
||||||
|
"<script>", |
||||||
|
"insert into high_coupon_code (coupon_id, merchant_id, ", |
||||||
|
"order_id, sales_code, ", |
||||||
|
"sales_end_time, use_end_time, ", |
||||||
|
"create_time, receive_time, ", |
||||||
|
"consume_time, `status`, ", |
||||||
|
"operator_id, operator_name, ", |
||||||
|
"ext_1, ext_2, ext_3)", |
||||||
|
"values ", |
||||||
|
"<foreach collection='list' item='item' index='index' separator=','>", |
||||||
|
"(#{item.couponId,jdbcType=BIGINT}, " + |
||||||
|
"#{item.merchantId,jdbcType=BIGINT}," + |
||||||
|
"#{item.orderId,jdbcType=BIGINT}, " + |
||||||
|
"#{item.salesCode,jdbcType=VARCHAR}, ", |
||||||
|
"#{item.salesEndTime,jdbcType=TIMESTAMP}," + |
||||||
|
"#{item.useEndTime,jdbcType=TIMESTAMP}, ", |
||||||
|
"#{item.createTime,jdbcType=TIMESTAMP}, " + |
||||||
|
"#{item.receiveTime,jdbcType=TIMESTAMP}, ", |
||||||
|
"#{item.consumeTime,jdbcType=TIMESTAMP}," + |
||||||
|
"#{item.status,jdbcType=INTEGER}, ", |
||||||
|
"#{item.operatorId,jdbcType=BIGINT}, " + |
||||||
|
"#{item.operatorName,jdbcType=VARCHAR}, ", |
||||||
|
"#{item.ext1,jdbcType=VARCHAR}," + |
||||||
|
"#{item.ext2,jdbcType=VARCHAR}, " + |
||||||
|
"#{item.ext3,jdbcType=VARCHAR})", |
||||||
|
"</foreach>", |
||||||
|
"</script>" |
||||||
|
}) |
||||||
|
void insertList(@Param(value = "list") List<HighCouponCode> list); |
||||||
|
|
||||||
} |
} |
Loading…
Reference in new issue