php 生成订单号201807205598981

举报
lxw1844912514 发表于 2022/03/27 01:09:35 2022/03/27
【摘要】 php版 /** * 生成唯一订单号 */ public function build_order_no() { $no = date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid()...

php版


    
  1. /**
  2. * 生成唯一订单号
  3. */
  4. public function build_order_no()
  5. {
  6. $no = date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
  7. //检测是否存在
  8. $db = M('Order');
  9. $info = $db->where(array('number'=>$no))->find();
  10. (!empty($info)) && $no = $this->build_order_no();
  11. return $no;
  12. }

 js版


    
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>支付宝电脑网站支付</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <style>
  7. *{
  8. margin:0;
  9. padding:0;
  10. }
  11. ul,ol{
  12. list-style:none;
  13. }
  14. body{
  15. font-family: "Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;
  16. }
  17. .tab-head{
  18. margin-left:120px;
  19. margin-bottom:10px;
  20. }
  21. .tab-content{
  22. clear:left;
  23. display: none;
  24. }
  25. h2{
  26. border-bottom: solid #02aaf1 2px;
  27. width: 200px;
  28. height: 25px;
  29. margin: 0;
  30. float: left;
  31. text-align: center;
  32. font-size: 16px;
  33. }
  34. .selected{
  35. color: #FFFFFF;
  36. background-color: #02aaf1;
  37. }
  38. .show{
  39. clear:left;
  40. display: block;
  41. }
  42. .hidden{
  43. display:none;
  44. }
  45. .new-btn-login-sp{
  46. padding: 1px;
  47. display: inline-block;
  48. width: 75%;
  49. }
  50. .new-btn-login {
  51. background-color: #02aaf1;
  52. color: #FFFFFF;
  53. font-weight: bold;
  54. border: none;
  55. width: 100%;
  56. height: 30px;
  57. border-radius: 5px;
  58. font-size: 16px;
  59. }
  60. #main{
  61. width:100%;
  62. margin:0 auto;
  63. font-size:14px;
  64. }
  65. .red-star{
  66. color:#f00;
  67. width:10px;
  68. display:inline-block;
  69. }
  70. .null-star{
  71. color:#fff;
  72. }
  73. .content{
  74. margin-top:5px;
  75. }
  76. .content dt{
  77. width:100px;
  78. display:inline-block;
  79. float: left;
  80. margin-left: 20px;
  81. color: #666;
  82. font-size: 13px;
  83. margin-top: 8px;
  84. }
  85. .content dd{
  86. margin-left:120px;
  87. margin-bottom:5px;
  88. }
  89. .content dd input {
  90. width: 85%;
  91. height: 28px;
  92. border: 0;
  93. -webkit-border-radius: 0;
  94. -webkit-appearance: none;
  95. }
  96. #foot{
  97. margin-top:10px;
  98. position: absolute;
  99. bottom: 15px;
  100. width: 100%;
  101. }
  102. .foot-ul{
  103. width: 100%;
  104. }
  105. .foot-ul li {
  106. width: 100%;
  107. text-align:center;
  108. color: #666;
  109. }
  110. .note-help {
  111. color: #999999;
  112. font-size: 12px;
  113. line-height: 130%;
  114. margin-top: 5px;
  115. width: 100%;
  116. display: block;
  117. }
  118. #btn-dd{
  119. margin: 20px;
  120. text-align: center;
  121. }
  122. .foot-ul{
  123. width: 100%;
  124. }
  125. .one_line{
  126. display: block;
  127. height: 1px;
  128. border: 0;
  129. border-top: 1px solid #eeeeee;
  130. width: 100%;
  131. margin-left: 20px;
  132. }
  133. .am-header {
  134. display: -webkit-box;
  135. display: -ms-flexbox;
  136. display: box;
  137. width: 100%;
  138. position: relative;
  139. padding: 7px 0;
  140. -webkit-box-sizing: border-box;
  141. -ms-box-sizing: border-box;
  142. box-sizing: border-box;
  143. background: #1D222D;
  144. height: 50px;
  145. text-align: center;
  146. -webkit-box-pack: center;
  147. -ms-flex-pack: center;
  148. box-pack: center;
  149. -webkit-box-align: center;
  150. -ms-flex-align: center;
  151. box-align: center;
  152. }
  153. .am-header h1 {
  154. -webkit-box-flex: 1;
  155. -ms-flex: 1;
  156. box-flex: 1;
  157. line-height: 18px;
  158. text-align: center;
  159. font-size: 18px;
  160. font-weight: 300;
  161. color: #fff;
  162. }
  163. </style>
  164. </head>
  165. <body text=#000000 bgColor="#ffffff" leftMargin=0 topMargin=4>
  166. <header class="am-header">
  167. <h1>支付宝电脑网站支付体验入口页</h1>
  168. </header>
  169. <div id="main">
  170. <div id="tabhead" class="tab-head">
  171. <h2 id="tab1" class="selected" name="tab">付 款</h2>
  172. </div>
  173. <form name=alipayment action="{:url('payment')}" method=post target="_blank">
  174. <div id="body1" class="show" name="divcontent">
  175. <dl class="content">
  176. <dt>商户订单号
  177. :</dt>
  178. <dd>
  179. <input id="WIDout_trade_no" name="WIDout_trade_no" />{$number}
  180. </dd>
  181. <hr class="one_line">
  182. <dt>订单名称
  183. :</dt>
  184. <dd>
  185. <input id="WIDsubject" name="WIDsubject" />
  186. </dd>
  187. <hr class="one_line">
  188. <dt>付款金额
  189. :</dt>
  190. <dd>
  191. <input id="WIDtotal_amount" name="WIDtotal_amount" />
  192. </dd>
  193. <hr class="one_line">
  194. <dt>商品描述:</dt>
  195. <dd>
  196. <input id="WIDbody" name="WIDbody" />
  197. </dd>
  198. <hr class="one_line">
  199. <dt></dt>
  200. <dd id="btn-dd">
  201. <span class="new-btn-login-sp">
  202. <button class="new-btn-login" name="pay_type" value="alipay" type="submit" style="text-align:center;">付 款</button>
  203. </span>
  204. <span class="note-help">如果您点击“付款”按钮,即表示您同意该次的执行操作。</span>
  205. </dd>
  206. </dl>
  207. </div>
  208. </form>
  209. <div id="foot">
  210. <ul class="foot-ul">
  211. <li>
  212. 支付宝版权所有 2015-2018 ALIPAY.COM
  213. </li>
  214. </ul>
  215. </div>
  216. </div>
  217. </body>
  218. <script language="javascript">
  219. var tabs = document.getElementsByName('tab');
  220. var contents = document.getElementsByName('divcontent');
  221. (function changeTab(tab) {
  222. for(var i = 0, len = tabs.length; i < len; i++) {
  223. tabs[i].onmouseover = showTab;
  224. }
  225. })();
  226. function showTab() {
  227. for(var i = 0, len = tabs.length; i < len; i++) {
  228. if(tabs[i] === this) {
  229. tabs[i].className = 'selected';
  230. contents[i].className = 'show';
  231. } else {
  232. tabs[i].className = '';
  233. contents[i].className = 'tab-content';
  234. }
  235. }
  236. }
  237. function GetDateNow() {
  238. var vNow = new Date();
  239. var sNow = "";
  240. sNow += String(vNow.getFullYear());
  241. sNow += String(vNow.getMonth() + 1);
  242. sNow += String(vNow.getDate());
  243. sNow += String(vNow.getHours());
  244. sNow += String(vNow.getMinutes());
  245. sNow += String(vNow.getSeconds());
  246. sNow += String(vNow.getMilliseconds());
  247. document.getElementById("WIDout_trade_no").value = sNow;
  248. document.getElementById("WIDsubject").value = "测试";
  249. document.getElementById("WIDtotal_amount").value = "0.01";
  250. }
  251. GetDateNow();
  252. </script>

 

 

 
  

文章来源: blog.csdn.net,作者:lxw1844912514,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/lxw1844912514/article/details/100029274

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。