oprefund_goods_dointegral.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <style>
  2. .line_p{line-height:26px;font-size:13px;margin-top:5px;}
  3. .goods_refund_form th{border: 1px solid #efefef;line-height: 34px;}
  4. .goods_refund_form td{border: 1px solid #efefef;line-height: 34px;}
  5. .w100{width:100px;}
  6. .lh30{line-height:30px;font-size:13px;}
  7. .mrt8{margin-top:8px;}
  8. .blu{color:blue;}
  9. </style>
  10. <form class="form-horizontal form-validate" action="{:U('order/oprefund_goods_do')}" method="post" enctype="multipart/form-data">
  11. <input type='hidden' name='id' value='{$id}' />
  12. <input type='hidden' name='order_goods_id' value='{$order_goods_id}' />
  13. <div class="modal-dialog">
  14. <div class="modal-content">
  15. <div class="modal-header">
  16. <button data-dismiss="modal" class="close" type="button">×</button>
  17. <h4 class="modal-title">退款</h4>
  18. </div>
  19. <div class="modal-body" style = "padding: 10px;" >
  20. <div style="display: flex">
  21. <div class="goods_refund_form" style="width:100%;display: flex;flex-direction: column;justify-content: center;align-items: flex-start;padding-left: 5px">
  22. <table style="border: 1px solid #efefef;width:100%;">
  23. <tr>
  24. <th style="width:40%;text-align:center;">商品标题</th>
  25. <th style="width:20%;text-align:center;">商品数量</th>
  26. <th style="width:30%;text-align:center;">商品价格</th>
  27. </tr>
  28. <tr>
  29. <td style="overflow: visible;text-align:center;padding-top: 10px;">
  30. {$order_goods_info['name']}
  31. </td>
  32. <td style="text-align:center;">
  33. {$total_quantity}个<?php if($has_refund_quantity > 0){ ?>(已退{$has_refund_quantity})<?php } ?>
  34. </td>
  35. <td style="text-align:center;">
  36. 积分{:round($order_goods_info['price'] ,2)}
  37. </td>
  38. </tr>
  39. </table>
  40. </div>
  41. <div style="clear:both;"></div>
  42. </div>
  43. <p class="lh30 mrt8"><label class="w100">退款数量:</label>可退<b class="blu">{$total_quantity}</b>个<?php if($has_refund_quantity > 0){ ?>(已退{$has_refund_quantity})<?php } ?></p>
  44. <?php if($total_quantity > 0){ ?>
  45. <p class="lh30 ">
  46. <label class="w100">
  47. <label><input type="checkbox" id="ckall" value ="1" />&nbsp;全选</label>
  48. </label>
  49. <?php for( $i =0; $i < $total_quantity; $i++ ){ ?>
  50. <label><input type="checkbox" class="ref_goods" value ="1" />&nbsp;{$order_goods_info['name']}</label>
  51. <?php } ?>
  52. <?php for( $i =0; $i < $has_refund_quantity; $i++ ){ ?>
  53. <label><input type="checkbox" disabled /><font style="text-decoration:line-through;">&nbsp;{$order_goods_info['name']}(已退款)</font></label>
  54. <?php } ?>
  55. </p>
  56. <?php } ?>
  57. <?php
  58. $total = $free_tongji;//-$order_goods_info['voucher_credit']-$order_goods_info['fullreduction_money'];
  59. $score_for_money = $order_goods_info['score_for_money'];
  60. $free_tongji = $total;
  61. if($free_tongji < 0){
  62. $free_tongji = 0;
  63. }
  64. $refund_one_money = round( $free_tongji/$total_quantity , 2);
  65. $refund_one_score = intval( $use_score/$order_goods_info['quantity'] );
  66. ?>
  67. <?php if( !empty( $score_for_money ) && $score_for_money > 0 ){ ?>
  68. <p class="lh30"><label class="w100">积分抵扣:</label>¥{$score_for_money}</p>
  69. <?php } ?>
  70. <p class="lh30"><label class="w100">最多退积分:</label>{$free_tongji}</p>
  71. <p class="lh30" style="display:none;" > <!--style="display:none;"-->
  72. <label class="w100">选中商品最多退款积分:</label>
  73. <input type="text" style="padding:2px;height:25px;border: 1px solid #ccc;" name="refund_money2" id="refund_money2" placeholder="退款金额" value="0" />
  74. </p>
  75. <p class="lh30">
  76. <label class="w100">退款积分:</label>
  77. <input type="text" style="padding:2px;height:25px;border: 1px solid #ccc;" name="refund_money" id="refund_money" placeholder="退款积分" value="0" />
  78. </p>
  79. <div style="height:8px;"></div>
  80. <?php if($is_has_refund_deliveryfree == 1){ ?>
  81. <p class="line_p">
  82. <label class="w100">配送费:</label>
  83. <?php if($shipping_fare <= 0){ ?>
  84. &nbsp;0
  85. <?php }else{ ?>
  86. <input type="checkbox" id="is_refund_shippingfare" name="is_refund_shippingfare" checked value ="1" />&nbsp;
  87. <?php if( $delivery == 'express' ){ ?>
  88. 可退“快递配送费” ¥<?php echo $shipping_fare - $has_refund_quantity * round( 1/($total_quantity+$has_refund_quantity) * $shipping_fare,2); ?>,选中退配送费:¥ <input type="text" disabled="disabled" name="select_shipping_fare" id="select_shipping_fare" style="padding:2px;height:25px;border: 0px; background: #fff;width:100px;" value="0" />
  89. <?php }else if( $delivery == 'localtown_delivery' ){ ?>
  90. 可退“同城配送费” ¥<?php echo $shipping_fare - $has_refund_quantity * round( 1/($total_quantity+$has_refund_quantity) * $shipping_fare,2); ?>,选中退配送费:¥ <input type="text" disabled="disabled" name="select_shipping_fare" id="select_shipping_fare" style="padding:2px;height:25px;border: 0px ; background: #fff;width:100px;" value="0" />
  91. <?php }else if( $delivery == 'tuanz_send' ){ ?>
  92. 可退“团长配送费” ¥<?php echo $shipping_fare - $has_refund_quantity * round( 1/($total_quantity+$has_refund_quantity) * $shipping_fare,2); ?>,选中退配送费:¥ <input type="text" disabled="disabled" name="select_shipping_fare" id="select_shipping_fare" style="padding:2px;height:25px;border: 0px ; background: #fff;width:100px;" value="0" />
  93. <?php } ?>
  94. <?php } ?>
  95. </p>
  96. <?php }else{ ?>
  97. <p class="line_p">
  98. <label class="w100">配送费:&nbsp;&nbsp;&nbsp;&nbsp;后台设置不退配送费</label>
  99. </p>
  100. <?php } ?>
  101. <p class="line_p">
  102. <label class="w100">其他操作:</label>
  103. <input type="checkbox" id="is_back_sellcount" checked name="is_back_sellcount" value ="1" />&nbsp;
  104. 退库存以及减销量&nbsp;<input type="text" name="refund_quantity" id="refund_quantity" style="padding:2px;height:25px;border: 1px solid #ccc;width:100px;" value="0" />&nbsp;个(最多可退{$total_quantity}个)
  105. <?php if( $use_score > 0 ){ ?>
  106. &nbsp;&nbsp;&nbsp;&nbsp;
  107. <label>
  108. <input type="checkbox" id="is_back_scorecount" name="is_back_scorecount" value ="1" />&nbsp;退<font id="refund_scorecount">0</font>积分
  109. </label>
  110. <?php } ?>
  111. </p>
  112. <p style="line-height:26px;font-size:13px;">佣金:<span class="label label-success">{$commiss_state}</span></p>
  113. <p style="margin-top:10px;line-height:16px;font-size:12px;color:#9e9696;">
  114. 备注:1.佣金指社区团购团长提成,团长分销提成,会员分销提成。<br/>
  115. 2当佣金“已结算”,本页面操作不会影响已经结算的所有佣金。<br/>
  116. 3.当佣金“未结算”,本页面操作会重新计算佣金金额,计算公式:商品退款金额占商品可退总金额比重*原来应结佣金<br/>
  117. 4.所退配送费计算公式=均摊,退款金额/全部商品金额*运费<br/>
  118. </p>
  119. </div>
  120. <div class="modal-footer">
  121. <input type="hidden" id="real_refund_quantity" name="real_refund_quantity" value="0" />
  122. <button class="btn btn-primary" type="submit" id="ck_opgoodsrefund">提交</button>
  123. <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
  124. </div>
  125. </div>
  126. </form>
  127. <script>
  128. var free_tongji = {$free_tongji};
  129. var shipping_fare = {$shipping_fare};
  130. var use_score = {$use_score};
  131. var total_quantity = {$total_quantity};
  132. var info_quantity = {$order_goods_info['quantity']};
  133. var has_refund_quantity = {$has_refund_quantity};
  134. var refund_one_money = {$refund_one_money};
  135. $(function(){
  136. $('.ref_goods').click(function(){
  137. sum_refund_money_quantity();
  138. })
  139. $('#ck_opgoodsrefund').click(function(){
  140. var loadingIndex = layer.load();
  141. var ck_arr = [];
  142. $('.ref_goods').each(function(){
  143. if( $(this).is(':checked') ) {
  144. ck_arr.push(1);
  145. }
  146. })
  147. if(ck_arr.length <=0 )
  148. {
  149. layer.msg('请选择退款商品');
  150. layer.close(loadingIndex);
  151. return false;
  152. }
  153. if( $('#is_back_sellcount').is(':checked') )
  154. {
  155. var refund_quantity = $('#refund_quantity').val();
  156. refund_quantity = parseInt(refund_quantity);
  157. if( ck_arr.length < refund_quantity)
  158. {
  159. layer.msg('退库存以及销量数量不能大于选中商品数量');
  160. layer.close(loadingIndex);
  161. return false;
  162. }
  163. var refund_money = $('#refund_money').val();
  164. var refund_money2 = $('#refund_money2').val();
  165. if( refund_money - refund_money2 > 0 )
  166. {
  167. layer.msg('退款积分大于选中商品最多退款积分');
  168. layer.close(loadingIndex);
  169. return false;
  170. }
  171. }
  172. $('#real_refund_quantity').val( ck_arr.length );
  173. })
  174. $('#ckall').click(function(){
  175. var obj = $(this);
  176. if( $(obj).is(':checked') )
  177. {
  178. $(".ref_goods").prop("checked", true);
  179. }else{
  180. $(".ref_goods").prop("checked", false);
  181. }
  182. sum_refund_money_quantity();
  183. })
  184. $('#is_refund_shippingfare').click(function(){
  185. var refund_money_str = $('#refund_money').val();
  186. var refund_money = parseFloat(refund_money_str);
  187. })
  188. })
  189. function sum_refund_money_quantity()
  190. {
  191. var ck_arr = [];
  192. var all_refund_count = $('.ref_goods').length;
  193. $('.ref_goods').each(function(){
  194. if( $(this).is(':checked') ) {
  195. ck_arr.push(1);
  196. }
  197. })
  198. var refund_count = ck_arr.length;
  199. var can_refund_money = (refund_count * (free_tongji/total_quantity) ).toFixed(2);
  200. var can_refund_score = (refund_count * (use_score/info_quantity) ).toFixed(2);
  201. console.log(can_refund_score);
  202. var is_has_refund_deliveryfree = $('#is_has_refund_deliveryfree').val();
  203. if( $('#is_refund_shippingfare').is(':checked') )
  204. {
  205. can_refund_money = can_refund_money + parseFloat(shipping_fare);
  206. if( can_refund_money > free_tongji + shipping_fare )
  207. {
  208. can_refund_money = free_tongji + shipping_fare;
  209. }
  210. }else{
  211. if(is_has_refund_deliveryfree == 0){
  212. can_refund_money = can_refund_money;
  213. }else{
  214. can_refund_money = can_refund_money - (shipping_fare/all_refund_count) * refund_count;
  215. }
  216. if( can_refund_money > free_tongji )
  217. {
  218. can_refund_money = free_tongji;
  219. }
  220. }
  221. /*can_refund_money = Math.floor(can_refund_money *100)/100;
  222. can_refund_score = Math.floor(can_refund_score *100)/100;*/
  223. can_refund_money = Math.floor(accMul(can_refund_money,100))/100;
  224. can_refund_score = Math.floor(accMul(can_refund_score,100))/100;
  225. can_refund_score = parseInt(can_refund_score);
  226. if(refund_count == 0){
  227. select_shipping_fare = 0;
  228. }else{
  229. select_shipping_fare =( shipping_fare - (total_quantity + has_refund_quantity - refund_count) * ( 1/( total_quantity + has_refund_quantity) * shipping_fare).toFixed(2) ).toFixed(2);
  230. }
  231. $('#refund_scorecount').html(can_refund_score);
  232. $('#refund_money').val(can_refund_money);
  233. $('#refund_money2').val(can_refund_money);
  234. $('#refund_quantity').val(refund_count);
  235. $('#select_shipping_fare').val(select_shipping_fare);
  236. }
  237. function accMul(num1,num2){
  238. var m=0,s1=num1.toString(),s2=num2.toString();
  239. try{m+=s1.split(".")[1].length}catch(e){};
  240. try{m+=s2.split(".")[1].length}catch(e){};
  241. return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m);
  242. }
  243. </script>