provider.price.set.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <?php defined('InShopNC') or exit('Access Invalid!'); ?>
  2. <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/3.16.0/math.min.js"></script>
  3. <script>
  4. math.config({
  5. number: 'BigNumber',
  6. precision: 20
  7. });
  8. </script>
  9. <style>
  10. .disInput {
  11. background: #ccc;
  12. cursor: not-allowed;
  13. }
  14. .spec_table {
  15. width: 420px;
  16. border-right: 1px solid #CBE9F3;
  17. }
  18. .spec_table .batch {
  19. vertical-align: middle;
  20. display: inline-block;
  21. *display: inline
  22. /*IE7*/
  23. ;
  24. margin-left: 4px;
  25. position: relative;
  26. z-index: 1;
  27. *zoom: 1
  28. /*IE7*/
  29. ;
  30. }
  31. .spec_table .batch i {
  32. cursor: pointer;
  33. }
  34. .spec_table .batch-input {
  35. background-color: #FFF;
  36. white-space: nowrap;
  37. padding: 4px 9px;
  38. border: solid 1px #BCE8F1;
  39. position: absolute;
  40. z-index: 1;
  41. top: -70px;
  42. left: -75px;
  43. box-shadow: 3px 3px 0 rgba(153, 153, 153, 0.25);
  44. }
  45. .spec_table .batch-input h6 {
  46. font-size: 12px;
  47. color: #555;
  48. }
  49. .spec_table .batch-input .text {
  50. vertical-align: middle;
  51. clear: both;
  52. padding: 0 4px;
  53. margin-right: 4px;
  54. }
  55. .spec_table .batch-input .arrow {
  56. background: url(<?php echo SHOP_SITE_URL; ?>/templates/default/images/seller/ncsc_bg_img.png) no-repeat -240px -20px;
  57. display: block;
  58. width: 10px;
  59. height: 5px;
  60. margin-left: -5px;
  61. bottom: -5px;
  62. left: 50%;
  63. position: absolute;
  64. z-index: 2;
  65. }
  66. .spec_table .batch-input a.close {
  67. font-size: 11px;
  68. line-height: 12px;
  69. color: #BCE8F1;
  70. text-decoration: none;
  71. background-color: #FFF;
  72. text-align: center;
  73. display: block;
  74. width: 12px;
  75. height: 12px;
  76. border-radius: 7px;
  77. border: solid 1px #BCE8F1;
  78. top: -7px;
  79. right: -7px;
  80. position: absolute;
  81. z-index: 2;
  82. }
  83. .spec_table .text.price {
  84. width: 40px;
  85. }
  86. </style>
  87. <div class="page">
  88. <div class="fixed-bar">
  89. <div class="item-title">
  90. <h3>通道管理</h3>
  91. <ul class="tab-base">
  92. <li><a href="index.php?act=provider&op=index"><span><?php echo $lang['nc_manage'] ?></span></a></li>
  93. <li><a href="index.php?act=provider&op=provider_amount"><span>调款记录</span></a></li>
  94. <li><a href="JavaScript:void(0);" class="current"><span>价格设置</span></a></li>
  95. </ul>
  96. </div>
  97. </div>
  98. <div class="fixed-empty"></div>
  99. <form id="price_form" enctype="multipart/form-data" method="post">
  100. <input type="hidden" name="form_submit" value="ok" />
  101. <input type="hidden" name="provider_id" value="<?php echo $_GET['provider_id'] ?>" />
  102. <table class="table tb-type2">
  103. <tbody>
  104. <tr class="noborder">
  105. <td colspan="2">
  106. <label>通道名称:</label>
  107. <label><?php echo $output['provider_name']; ?></label>
  108. </td>
  109. </tr>
  110. <tr class="noborder">
  111. <td class="vatop rowform">
  112. <label>通道质量:</label>
  113. <label data-quality="<?php echo $output['quality']; ?>"><?php echo $output['quality_text']; ?></label>
  114. </td>
  115. </tr>
  116. <tr class="noborder">
  117. <td colspan="2" class="required"><label class="validation" for="mchid">编辑后延迟生效日期:</label></td>
  118. </tr>
  119. <tr class="noborder">
  120. <td class="vatop rowform">
  121. <select id="selectEffectType">
  122. <option value="0">立即生效</option>
  123. <option value="1">延迟生效</option>
  124. </select>
  125. </td>
  126. <td class="vatop rowform">
  127. <input class="txt date" style="display:none;" type="text" id="startTime" name="effect_time" placeholder="" value="<?php echo date("Y-m-d H:i:s", $output['effect_time']); ?>" autocomplete="off" style="width:120px" />
  128. </td>
  129. <td class="vatop tips" style="color: red"></td>
  130. </tr>
  131. <tr>
  132. <td colspan="2" class="required"><label class="validation" for="password">价格:</label></td>
  133. </tr>
  134. <tr class="noborder" style="border-bottom: 1px solid #CBE9F3;">
  135. <?php foreach ($output['amounts'] as $card_type => $datas) { ?>
  136. <td>
  137. <table class="spec_table tb-type2 setTable">
  138. <tr class="w500">
  139. <th class="w150 align-center">卡类型</th>
  140. <th class="w150 align-center">面额</th>
  141. <th class="w150 align-center">
  142. 价格
  143. <div class="batch" style="display: none;"><i class="icon-edit" title="批量操作"></i>
  144. <div class="batch-input" style="display:none;">
  145. <h6>批量设置费率(百分比):</h6>
  146. <a href="javascript:void(0)" class="close">X</a>
  147. <input name="" type="text" class="text price" />%
  148. <a href="javascript:void(0)" class="ncsc-btn-mini" data-type="price">设置</a><span class="arrow"></span>
  149. </div>
  150. </div>
  151. </th>
  152. <th class="w150 align-center">
  153. 费率(%)
  154. <div class="batch" style="display: inline-block"><i class="icon-edit" title="批量操作"></i>
  155. <div class="batch-input" style="display:none;">
  156. <h6>批量设置费率(百分比):</h6>
  157. <a href="javascript:void(0)" class="close">X</a>
  158. <input name="" type="text" class="text price" />%
  159. <a href="javascript:void(0)" class="ncsc-btn-mini-price" data-type="price">设置</a><span class="arrow"></span>
  160. </div>
  161. </div>
  162. </th>
  163. </tr>
  164. <tbody class="tbody">
  165. <?php foreach ($datas as $spec => $val) { ?>
  166. <tr class="w500">
  167. <td class="w150 align-center">
  168. <?php echo $output['all_specs'][$card_type]['goods_name']; ?>
  169. <input type="hidden" name="card_types[]" value="<?php echo $card_type; ?>">
  170. </td>
  171. <td class="w150 align-center">
  172. <?php echo $spec; ?>
  173. <input type="hidden" class="num" name="specs[]" value="<?php echo $spec; ?>">
  174. </td>
  175. <td class="w150 align-center tdVal">
  176. <input type="text" name="<?php echo "price-{$card_type}-{$spec}" ?>" class="txt price changePrice <?php if ($val['opened'] == 0) echo 'disInput' ?>" <?php if ($val['opened'] == 0) echo 'disabled' ?> data-opened="<?php echo $val['opened']; ?>" value="<?php echo $val['price']; ?>">
  177. </td>
  178. <td class="w150 align-center">
  179. <input type="text" style="width:100px;" data-type="rate" min="0" max="200" <?php if ($val['opened'] == 0) echo 'disabled' ?>>
  180. </td>
  181. </tr>
  182. <?php } ?>
  183. </tbody>
  184. </table>
  185. </td>
  186. <?php } ?>
  187. </tr>
  188. </tbody>
  189. <tfoot>
  190. <tr class="tfoot">
  191. <td colspan="15"><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span><?php echo $lang['nc_submit']; ?></span></a></td>
  192. </tr>
  193. </tfoot>
  194. </table>
  195. </form>
  196. </div>
  197. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/laydate/laydate.js"></script>
  198. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/dialog/dialog.js" id="dialog_js" charset="utf-8"></script>
  199. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery-ui/jquery.ui.js"></script>
  200. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/ajaxfileupload/ajaxfileupload.js"></script>
  201. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery.Jcrop/jquery.Jcrop.js"></script>
  202. <link href="<?php echo RESOURCE_SITE_URL; ?>/js/jquery.Jcrop/jquery.Jcrop.min.css" rel="stylesheet" type="text/css" id="cssfile2" />
  203. <script type="text/javascript">
  204. $(function() {
  205. let maxDecimal = (number) => {
  206. return String(number).replace(/^(.*\..{4}).*$/, "$1")
  207. }
  208. var effect_time = <?php echo json_encode($output['effect_time']) ?> * 1000;
  209. var curDate = new Date().getTime();
  210. if (effect_time > curDate) {
  211. $('#selectEffectType').val('1');
  212. $('#startTime').show();
  213. var date = new Date(effect_time);
  214. var year = date.getFullYear();
  215. var month = date.getMonth() + 1;
  216. var day = date.getDate();
  217. var hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
  218. var min = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
  219. var sed = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
  220. if (month < 10) {
  221. month = '0' + month;
  222. }
  223. if (day < 10) {
  224. day = '0' + day;
  225. }
  226. var nowTime = year + '-' + month + '-' + day + ' ' + hour + ':' + min + ':' + sed;
  227. laydate.render({
  228. elem: '#startTime',
  229. type: 'datetime',
  230. value: nowTime,
  231. min: new Date().getTime()
  232. });
  233. }
  234. // laydate.render({
  235. // elem: '#startTime',
  236. // type: 'datetime'
  237. // });
  238. const tdVals = $('.tdVal');
  239. for (let i = 0; i < tdVals.length; i++) {
  240. let rateInput = tdVals.eq(i).next().find('input');
  241. let price = tdVals.eq(i).find('.price').val();
  242. let amountPrice = tdVals.eq(i).find('.price').attr('name').split('-')[2];
  243. if (tdVals.eq(i).find('input').attr('data-opened') == 1) {
  244. rateInput.val(maxDecimal(math.format(math.multiply(math.divide(math.bignumber(price), math.bignumber(amountPrice)), math.bignumber(100)))));
  245. } else {
  246. rateInput.val('--');
  247. }
  248. }
  249. $('.txt.price').on('input', function() {
  250. var val = $(this).val();
  251. console.log('val', val);
  252. $(this).val(maxDecimal(val));
  253. })
  254. $('#selectEffectType').on('change', function() {
  255. const val = $(this).val();
  256. if (val == 0) {
  257. $(this).attr('name', 'effect_time')
  258. $('#startTime').attr('name', '');
  259. $('#startTime').hide()
  260. } else {
  261. var date = new Date();
  262. var year = date.getFullYear();
  263. var month = date.getMonth() + 1;
  264. var day = date.getDate();
  265. if (month < 10) {
  266. month = '0' + month;
  267. }
  268. if (day < 10) {
  269. day = '0' + day;
  270. }
  271. var nowTime = year + '-' + month + '-' + day + ' ' + '00' + ':' + '00' + ':' + '00';
  272. $(this).attr('name', '')
  273. $('#startTime').attr('name', 'effect_time');
  274. $('#startTime').show()
  275. laydate.render({
  276. elem: '#startTime',
  277. type: 'datetime',
  278. value: nowTime,
  279. min: nowTime
  280. });
  281. }
  282. })
  283. //按钮先执行验证再提交表单
  284. $("#submitBtn").click(function() {
  285. if ($('#startTime').is(':visible')) {
  286. const curTime = new Date().getTime();
  287. const selectTime = new Date($('#startTime').val()).getTime();
  288. if (selectTime < curTime) {
  289. alert('延迟生效时间小于当前时间,请重新选择');
  290. return;
  291. }
  292. }
  293. $("#price_form").submit();
  294. });
  295. // $('#price_form').validate({
  296. // errorPlacement: function(error, element) {
  297. // error.appendTo(element.parent().parent().prev().find('td:first'));
  298. // },
  299. // rules: {
  300. // effect_time: {
  301. // required: true,
  302. // },
  303. // },
  304. // messages: {
  305. // effect_time: {
  306. // required: '延迟生效秒数不能为空',
  307. // },
  308. // }
  309. // });
  310. // 批量设置价格、库存、预警值
  311. $('.batch > .icon-edit').click(function() {
  312. $('.batch > .batch-input').hide();
  313. $(this).next().show();
  314. });
  315. $('.batch-input > .close').click(function() {
  316. $(this).parent().hide();
  317. });
  318. $('.batch-input > .ncsc-btn-mini').click(function() {
  319. var _value = $(this).prev().val();
  320. var _type = $(this).attr('data-type');
  321. _type = '.' + _type;
  322. // console.log('_type', _type)
  323. var trs = $(this).parents('.setTable').children('.tbody').children()
  324. var trsArr = []
  325. trs.each(function() {
  326. let res = $(this).find('td').eq(1).text().replace(/[\ \r\n]+/g, "");
  327. // console.log('res', res)
  328. trsArr.push(res)
  329. })
  330. // console.log('trsArr', trsArr)
  331. var _valArr = []
  332. if (_value && _value > 0 && _value <= 200) {
  333. for (var i = 0; i < trsArr.length; i++) {
  334. _valArr[i] = maxDecimal(math.eval(trsArr[i] * _value / 100));
  335. }
  336. // console.log('_valArr', _valArr, trsArr)
  337. let vals = $(this).parents('.setTable').children('.tbody').find(_type)
  338. // console.log('vals', vals)
  339. for (let j = 0; j < vals.length; j++) {
  340. // console.log('vals[j]', j, vals[j], _valArr[j])
  341. if ($(vals[j]).attr('data-opened') == 1) {
  342. vals[j].value = _valArr[j]
  343. }
  344. }
  345. // console.log('_valArr', _valArr)
  346. } else if (_value && _value == 0 && _value <= 200) {
  347. for (let i = 0; i < trsArr.length; i++) {
  348. _valArr[i] = 0
  349. }
  350. // console.log('_valArr', _valArr, trsArr)
  351. let vals = $(this).parents('.setTable').children('.tbody').find(_type)
  352. console.log('vals', vals)
  353. for (let j = 0; j < vals.length; j++) {
  354. // console.log('vals[j]', j, vals[j], _valArr[j])
  355. if ($(vals[j]).attr('data-opened') == 1) {
  356. vals[j].value = _valArr[j]
  357. }
  358. }
  359. // console.log('_valArr', _valArr)
  360. }
  361. $(this).parents('.setTable').children('.tbody').find('input[data-type="rate"]').val(maxDecimal(_value));
  362. $(this).parent().hide();
  363. $(this).prev().val('');
  364. });
  365. $('input[data-type="rate"]').on('input', function() {
  366. var val = $(this).val();
  367. var changeInputName = $(this).parent('td').prev().find('input').attr('name');
  368. var amountPrice = changeInputName.split('-')[2];
  369. // $(this).parent('td').siblings('.tdVal').find('input').val(maxDecimal(math.eval(amountPrice * val / 100)))
  370. if (val) {
  371. $(this).parent('td').siblings('.tdVal').find('input').val(maxDecimal(math.format(
  372. math.divide(math.multiply(math.bignumber(amountPrice), math.bignumber(val)), math.bignumber(100))
  373. )))
  374. } else {
  375. $(this).parent('td').siblings('.tdVal').find('input').val('')
  376. }
  377. })
  378. $('.changePrice').on('input', function() {
  379. const val = $(this).val();
  380. const amountPrice = $(this).attr('name').split('-')[2];
  381. const rateInput = $(this).parent().next().find('input');
  382. // rateInput.val(maxDecimal(math.eval(val / amountPrice * 100)));
  383. if (val) {
  384. rateInput.val(maxDecimal(math.format(math.multiply(math.divide(math.bignumber(val), math.bignumber(amountPrice)), math.bignumber(100)))));
  385. } else {
  386. rateInput.val('')
  387. }
  388. })
  389. $('.ncsc-btn-mini-price').on('click', function() {
  390. const val = $(this).prev().val();
  391. $(this).parents('tbody').eq(0).find('.ncsc-btn-mini').prev().val(val);
  392. $(this).parents('tbody').eq(0).find('.ncsc-btn-mini').trigger('click');
  393. })
  394. });
  395. </script>