orderForm.js 108 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367
  1. /**
  2. * Created by 837 on 2017/8/12.
  3. */
  4. var ctx = $("#ctx").val();
  5. var product_index = $('#product_index').val();
  6. // 订单促销活动
  7. var promotionsIds = [];
  8. var totalPromotions = [];
  9. var giftPromotionsIds = [];
  10. // 用户总优惠券
  11. var totalCoupons = [];
  12. // 当前商品可用优惠券
  13. var selectCoupons = [];
  14. // 勾选后的优惠金额
  15. var couponPrice = 0;
  16. // 添加订单true,修改订单false
  17. var initFlag = true;
  18. var orderStatus = 0;
  19. $(function () {
  20. /** 发票信息 start * */
  21. // var invoiceTitle=$("#orderInvoice\\.invoiceTitle").val();
  22. // if(invoiceTitle !='' && invoiceTitle !=null && invoiceTitle !='null'){
  23. var type = $("#orderInvoice\\.type").val();
  24. if (type == '1') {
  25. $("#invoiceTable").show();
  26. $("#addTaxInvoiceTable").hide();
  27. $("#invoice2").attr("checked", true);
  28. var invoiceTitleType = $("#orderInvoice\\.invoiceTitleType").val();
  29. if (invoiceTitleType == 0) {
  30. $('#orderInvoice_companyTitle').attr('disabled', true);
  31. $('#orderInvoice_companyTitle').attr('value', '');
  32. $('#orderInvoice_corporationTaxNum').attr('disabled', true);
  33. $('#orderInvoice_corporationTaxNum').attr('value', '');
  34. $($(":radio[name='normalTitle_r']").get(1)).attr("checked", 'checked');
  35. $('#orderInvoice_normalTitle').attr('name', 'orderInvoice.invoiceTitle');
  36. }
  37. if (invoiceTitleType == 1) {
  38. $('#orderInvoice_normalTitle').attr('disabled', true);
  39. $('#orderInvoice_normalTitle').attr('value', '');
  40. $('#orderInvoice_normalTitle').attr('name', '');
  41. $($(":radio[name='normalTitle_r']").get(0)).attr("checked", 'checked');
  42. $('#orderInvoice_companyTitle').attr('name', 'orderInvoice.invoiceTitle');
  43. }
  44. $("#orderInvoice\\.corporationTaxNum").attr('value', '');
  45. $("#orderInvoice\\.corporationTaxNum").attr('name', '');
  46. } else if (type == '2') {
  47. $("#invoiceTable").hide();
  48. $("#addTaxInvoiceTable").show();
  49. $("#invoice3").attr("checked", true);
  50. $("#orderInvoice_normalTitle").attr('disabled', true);
  51. $("#orderInvoice\\.invoiceTitleType").attr("value", '1');
  52. $('#orderInvoiceInvoiceTitle3').attr('name', 'orderInvoice.invoiceTitle');
  53. $($(":radio[name='normalTitle_r']").get(0)).attr("checked", 'checked');
  54. } else {
  55. $("#invoiceTable").hide();
  56. $("#addTaxInvoiceTable").hide();
  57. $("#invoice1").attr("checked", true);
  58. $("#orderInvoice_normalTitle").attr('disabled', true);
  59. $("#orderInvoice\\.invoiceTitleType").attr("value", '1');
  60. $("#orderInvoice_corporationTaxNum").attr('value', '');
  61. $("#orderInvoice_corporationTaxNum").attr('name', '');
  62. $($(":radio[name='normalTitle_r']").get(0)).attr("checked", 'checked');
  63. }
  64. //单存在输入时候默认为个人发票类型
  65. $("#orderInvoice\\.invoiceTitle").on('change', function () {
  66. $("#orderInvoice\\.type").val("1"); //优化发票修改
  67. });
  68. $(":radio[name='normalTitle_r']").click(function () {
  69. var index = $(":radio[name='normalTitle_r']").index($(this));
  70. $("#orderInvoice\\.corporationTaxNum").attr('value', '');
  71. $("#orderInvoice\\.corporationTaxNum").attr('name', '');
  72. $("#orderInvoiceInvoiceTitle3").attr('value', '');
  73. $("#orderInvoiceInvoiceTitle3").attr('name', '');
  74. if (index == 0) {
  75. //普通发票的 企业抬头被选中了
  76. $("#orderInvoice\\.invoiceTitleType").val("1");
  77. $("#orderInvoice_normalTitle").attr('disabled', true);
  78. $("#orderInvoice_normalTitle").attr('value', '');
  79. $("#orderInvoice_companyTitle").attr('disabled', false);
  80. $("#orderInvoice_corporationTaxNum").attr('disabled', false);
  81. $('#orderInvoice_companyTitle').attr('name', 'orderInvoice.invoiceTitle');
  82. $('#orderInvoice_corporationTaxNum').attr('name', 'orderInvoice.corporationTaxNum');
  83. } else {
  84. //普通发票的 个人抬头被选中了
  85. $("#orderInvoice\\.invoiceTitleType").val("0");
  86. $("#orderInvoice_companyTitle").attr('disabled', true);
  87. $("#orderInvoice_companyTitle").attr('value', '');
  88. $("#orderInvoice_corporationTaxNum").attr('disabled', true);
  89. $("#orderInvoice_corporationTaxNum").attr('value', '');
  90. $("#orderInvoice_normalTitle").attr('disabled', false);
  91. $('#orderInvoice_companyTitle').attr('name', '');
  92. $('#orderInvoice_normalTitle').attr('name', 'orderInvoice.invoiceTitle');
  93. }
  94. });
  95. $(":radio[name='invoice']").click(function () {
  96. var index = $(":radio[name='invoice']").index($(this));
  97. if (index == 1) { //选中第2个时,div显示
  98. $("#invoiceTable").hide();
  99. $("#addTaxInvoiceTable").show();
  100. $("#orderInvoice\\.type").val("2");
  101. $('#orderInvoice_corporationTaxNum').attr('name', '');
  102. $('#orderInvoice\\.corporationTaxNum').attr('name', 'orderInvoice.corporationTaxNum');
  103. $('#orderInvoice_companyTitle').attr('name', '');
  104. $('#orderInvoice_normalTitle').attr('name', '');
  105. $('#orderInvoiceInvoiceTitle3').attr('name', 'orderInvoice.invoiceTitle');
  106. } else if (index == 0) { //当被选中的不是第1个时,div隐藏
  107. $("#invoiceTable").hide();
  108. $("#addTaxInvoiceTable").hide();
  109. $("#orderInvoice\\.invoiceTitle").val("");
  110. $("#orderInvoice\\.type").val("0"); //优化发票修改
  111. } else { //选中增值税发票
  112. $("#invoiceTable").hide();
  113. $("#addTaxInvoiceTable").show();
  114. $("#orderInvoice\\.type").val("2");
  115. $('#orderInvoice_corporationTaxNum').attr('name', '');
  116. $('#orderInvoice\\.corporationTaxNum').attr('name', 'orderInvoice.corporationTaxNum');
  117. $('#orderInvoice_companyTitle').attr('name', '');
  118. $('#orderInvoice_normalTitle').attr('name', '');
  119. $('#orderInvoiceInvoiceTitle3').attr('name', 'orderInvoice.invoiceTitle');
  120. }
  121. });
  122. /** 发票信息 end * */
  123. $("body").on('change', '.shopNote', function () {
  124. var self = $(this);
  125. var shopID = self.attr('data-shopid');
  126. var val = self.val();
  127. self.next('input[name=shopNote]').val(val + '=' + shopID);
  128. });
  129. /** 修改订单初始化 */
  130. var orderId = $("#orderID").val() * 1;
  131. orderStatus = $("#orderStatus").val() * 1;
  132. if (orderId && orderId > 0) {
  133. var userId = $("#inputForm").find("[name*='bpOrderUserinfo.userId']").val();
  134. // 获取用户总优惠券
  135. getUserCoupons(userId);
  136. // 修改订单初始化商品列表
  137. $('#product_index').val(0);
  138. product_index = 0;
  139. var productList = [];
  140. $('.productTable tbody tr:not(.gift)').each(function (index, element) {
  141. var data = JSON.parse($(this).attr("data-value"));
  142. data.shopId = data.shopID ? data.shopID : data.shopId;
  143. data.productId = data.productID ? data.productID : data.productId;
  144. if (data.productPromotion) {
  145. data.cmPromotion = {
  146. id: data.productPromotion.promotionsId,
  147. isNewRecord: data.productPromotion.isNewRecord,
  148. name: data.productPromotion.name,
  149. type: data.productPromotion.type,
  150. mode: data.productPromotion.mode,
  151. touchPrice: data.productPromotion.touchPrice,
  152. reducedPrice: data.productPromotion.reducedPrice,
  153. status: data.productPromotion.status,
  154. discount: data.productPromotion.discount
  155. };
  156. var tempProduct = {
  157. shopId: data.shopId,
  158. productId: data.productId,
  159. price: data.price,
  160. number: data.num,
  161. totalTax: data.totalAddedValueTax
  162. };
  163. data.productId = data.productID;
  164. data.shopId = data.shopID;
  165. var tempId = data.productPromotion.promotionsId;
  166. if (promotionsIds.indexOf(tempId) >= 0) {
  167. totalPromotions.forEach(function (item) {
  168. if (item.id * 1 === tempId) {
  169. for (var i = 0; i < item.promotionProducts.length; i++) {
  170. if (item.promotionProducts[i].productId == data.productId) {
  171. item.promotionProducts.splice(i--, 1);
  172. }
  173. }
  174. item.promotionProducts.push(tempProduct);
  175. }
  176. })
  177. } else {
  178. promotionsIds.push(tempId);
  179. var tempPromotions = JSON.parse(JSON.stringify(data.cmPromotion));
  180. if (tempPromotions.mode * 1 === 1) {
  181. tempPromotions.reducedPrice = data.price - tempPromotions.touchPrice;
  182. }
  183. if (data.cmPromotion.type * 1 === 3) {
  184. tempPromotions.shopId = data.shopId;
  185. }
  186. /*if(data.cmPromotion.mode*1 === 3){
  187. giftPromotionsIds.push(tempId);
  188. }*/
  189. tempPromotions.promotionProducts = [];
  190. tempPromotions.promotionProducts.push(tempProduct);
  191. totalPromotions.push(tempPromotions);
  192. }
  193. }
  194. data.productPromotion = null;
  195. productList.push(data);
  196. });
  197. $('.productTable tbody tr.gift').each(function (index, element) {
  198. var present = JSON.parse($(this).attr("data-value"));
  199. present.shopId = present.shopID ? present.shopID : present.shopId;
  200. present.productId = present.productID ? present.productID : present.productId;
  201. if (present.productType == 1) {
  202. productList.forEach(function (data) {
  203. if (present.productId == data.productId) {
  204. data.presentNum = present.num;
  205. }
  206. });
  207. }
  208. });
  209. $('.productTable').each(function (index, element) {
  210. $(this).prev('.order-rows').remove();
  211. $(this).remove();
  212. });
  213. initFlag = false;
  214. productList.forEach(function (data) {
  215. setProductList(data);
  216. });
  217. setOrderFee(); //设置底部订单金额
  218. initFlag = true;
  219. }
  220. });
  221. /************************添加会所 start**********************************************************/
  222. /**
  223. * 展示会所选择框
  224. * @param iframe
  225. */
  226. function showClubSelect(iframe) {
  227. top.$.jBox(iframe, {
  228. iframeScrolling: 'yes',
  229. width: $(top.document).width() - 100,
  230. height: $(top.document).height() - 160,
  231. persistent: true,
  232. // showScrolling: false,
  233. title: "选择会所",
  234. bottomText: '请选择一个会所',
  235. buttons: {
  236. "确定": '1',
  237. "关闭": '-1'
  238. },
  239. submit: function (v, h, f) {
  240. //确定
  241. var $jboxFrame = top.$('#jbox-iframe');
  242. var $mainFrame = top.$('#mainFrame');
  243. if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
  244. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  245. // console.log(items);
  246. if (items.length > 0) {
  247. //$jboxFrame[0].contentWindow.setBinding(items);
  248. setSingleSelect(items); //设置选中值
  249. // initStages();//初始化分期信息---分期功能目前已废弃
  250. $('.productTable,.order-rows').remove(); //重新选择会所时清空商品
  251. $('.productTotalFee,.payTotalFee,.payableAmount,.balancePayFee').text('0.00'); //清空金额
  252. $('#surplusBalance,#surplusBalance').text('0.00');
  253. $('.productCount').text('0');
  254. // 设置添加商品显示
  255. $(".addSecondHandProduct").show();
  256. return true;
  257. } else {
  258. top.$.jBox.tip("请选择...");
  259. return false;
  260. }
  261. }
  262. return true;
  263. }
  264. });
  265. }
  266. /**
  267. * 选择会所后设置用户信息
  268. * @param items
  269. */
  270. function setSingleSelect(items) {
  271. var info = eval('(' + items[0] + ')');
  272. $("#curProvince").val(info.province);
  273. $("#curCity").val(info.city);
  274. $("#curTown").val(info.town);
  275. loadProvince(); //加载地址下拉选项
  276. $("#bpOrderUserinfo\\.address").val(info.address); //设置详细地址
  277. console.log(info);
  278. $("#bpOrderUserinfo\\.clubId").val(info.id); //设置会所ID
  279. $("#bpOrderUserinfo\\.userId").val(info.userID);
  280. $("#inputForm").find("[name*='bpOrderUserinfo.province']").select2("val", info.province); //设置省份值
  281. $("#inputForm").find("[name*='bpOrderUserinfo.city']").select2("val", info.city);
  282. $("#inputForm").find("[name*='bpOrderUserinfo.town']").select2("val", info.town);
  283. $("#inputForm").find("[name*='bpOrderUserinfo.name']").val(info.name);
  284. $("#inputForm").find("[name*='bpOrderUserinfo.shouHuoRen']").val(info.linkMan1 ? info.linkMan1 : info.linkMan);
  285. $("#inputForm").find("[name*='bpOrderUserinfo.phonee']").val(info.contractPhone1 ? info.contractPhone1 : info.contractPhone);
  286. $("#inputForm").find("[name*='bpOrderUserinfo.mobile']").val(info.contractMobile1 ? info.contractMobile1 : info.contractMobile);
  287. $("#svipFlagLabel").text(1 == info.svipFlag ? '(超级会员)' : '');
  288. $("#availableBalance").html(info.ableUserMoney);
  289. //设置添加商品可见(会所添加添加运费订单公用此方法但是添加运费订单不需要添加商品)
  290. var ui = document.getElementById("shopSelected");
  291. var ui1 = document.getElementById("shopSelected1");
  292. if (ui) {
  293. ui.style.display = "";
  294. ui1.style.display = "none";
  295. }
  296. // 获取用户总优惠券
  297. getUserCoupons(info.userID);
  298. }
  299. function getUserCoupons(userId) {
  300. totalCoupons = [];
  301. $.get($("#ctx").val() + "/order/clubCouponList?userId=" + userId, function (data) {
  302. if (data.code * 1 === 0) {
  303. totalCoupons = data.couponList;
  304. // 展示可选优惠券列表
  305. getShownCouponList();
  306. }
  307. })
  308. }
  309. /************************添加会所 end**********************************************************/
  310. // 兑换优惠券
  311. $("#redeemCoupons").on("click", function () {
  312. var userId = $("#inputForm").find("[name*='bpOrderUserinfo.userId']").val();
  313. if (userId && userId * 1 > 0) {
  314. var html = '<div style="text-align:center;padding-top:12px;"><input id="couponsCode" name="couponsCode" type="text" maxlength="16" placeholder="请输入16位兑换码"></div>';
  315. var submit = function (v, h, f) {
  316. if (f.couponsCode == '' || isNaN(f.couponsCode)) {
  317. $.jBox.tip("请输入兑换码!", 'error', {focusId: "couponsCode"});
  318. }
  319. var bool = new RegExp("^[A-Za-z0-9]{16}$").test(f.couponsCode);
  320. if (!bool) {
  321. // 16位数字和字母
  322. $.jBox.tip("请输入正确的兑换码!", 'error', {focusId: "couponsCode"});
  323. } else {
  324. $.post($("#ctx").val() + "/coupon/cmCouponClub/redeem", {
  325. 'redemptionCode': f.couponsCode,
  326. 'userId': userId
  327. }, function (data) {
  328. if (0 === data.code * 1) {
  329. $.jBox.tip(data.msg, 'info');
  330. // 获取用户总优惠券
  331. getUserCoupons(userId);
  332. } else {
  333. $.jBox.tip(data.msg, 'error');
  334. }
  335. }, "JSON");
  336. }
  337. };
  338. $.jBox(html, {title: "兑换优惠券", buttons: {'立即兑换': true}, submit: submit});
  339. } else {
  340. alertx('请您先选择会所!');
  341. }
  342. });
  343. /************************商品相关 start**********************************************************/
  344. //设置商品(正常)
  345. function editShop(obj) {
  346. var $tr = obj.parents('tr');
  347. var data = $tr.attr("data-value");
  348. data = JSON.parse(data);
  349. var productID = (data.productId == undefined) ? data.productID : data.productId;
  350. var secondHandType = (data.secondHandType == undefined) ? 0 : data.secondHandType;
  351. var discount = (data.discount == undefined) ? 100 : data.discount;
  352. var productCategory = (data.productCategory == undefined) ? 1 : data.productCategory;
  353. var includexTax = (data.includexTax == undefined) ? 2 : data.includexTax;
  354. var invoiceType = (data.invoiceType == undefined) ? 3 : data.invoiceType;
  355. var taxRate = (data.taxRate == undefined) ? 0 : data.taxRate;
  356. var addedValueTax = (data.addedValueTax == undefined) ? 0 : data.addedValueTax;
  357. var totalAddedValueTax = (data.totalAddedValueTax == undefined) ? 0 : data.totalAddedValueTax;
  358. $.jBox.open("iframe:" + ctx + "/bulkpurchase/purchaseProduct/formOrderProduct?productId=" + productID +
  359. "&secondHandType=" +
  360. secondHandType + "&discount=" + discount + "&productCategory=" + productCategory + "&includedTax=" +
  361. includexTax +
  362. "&invoiceType=" + invoiceType + "&taxRate=" + taxRate + "&addedValueTax=" + addedValueTax +
  363. "&totalAddedValueTax" + totalAddedValueTax,
  364. "设置商品", $(top.document).width() - 240, $(top.document).height() - 200, {
  365. top: 36,
  366. persistent: true,
  367. buttons: {
  368. "确定": "ok",
  369. "关闭": true
  370. },
  371. // buttons:{"关闭":true},
  372. bottomText: "设置商品",
  373. submit: function (v, h, f) {
  374. if (v == "ok") {
  375. var $jboxFrame = $('#jbox-iframe');
  376. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  377. if (!items) {
  378. return false;
  379. } else {
  380. console.log(items[0]);
  381. setProductList(items[0], false); //设置商品列表
  382. // initStages();//初始化分期信息
  383. setOrderFee(); //设置底部订单金额
  384. }
  385. return true;
  386. }
  387. },
  388. loaded: function (h) {
  389. //$(".jbox-content", top.document).css("overflow-y","hidden");
  390. }
  391. });
  392. }
  393. // 展示可选优惠券列表
  394. function getShownCouponList() {
  395. selectCoupons = [];
  396. var couponProductIds = [];
  397. var couponProductList = [];
  398. $('.productTable tbody tr:not(.gift)').each(function (index, element) {
  399. var data = JSON.parse($(this).attr("data-value"));
  400. couponProductList.push(data);
  401. couponProductIds.push(data.productId);
  402. });
  403. totalCoupons.forEach(function (coupon) {
  404. var totalAmount = 0;
  405. var couponType = coupon.couponType * 1;
  406. couponProductList.forEach(function (item) {
  407. var productPrice = item.totalFee * 1;
  408. if (couponType === 0) {
  409. if (coupon.productType * 1 === 1) {
  410. //活动券-全商城商品
  411. totalAmount += productPrice;
  412. } else if (coupon.productType * 1 === 2) {
  413. //活动券-指定商品
  414. if (coupon.productIdList.length > 0 && coupon.productIdList.indexOf(item.productId * 1) >= 0) {
  415. totalAmount += productPrice;
  416. }
  417. }
  418. } else if (couponType === 1) {
  419. //品类券
  420. if (coupon.categoryType == item.commodityType) {
  421. totalAmount += productPrice;
  422. }
  423. } else if (couponType === 2 || couponType === 4) {
  424. //用户专享券或新用户券
  425. totalAmount += productPrice;
  426. } else if (couponType === 3) {
  427. //店铺券
  428. if (coupon.shopId == item.shopId) {
  429. totalAmount += productPrice;
  430. }
  431. }
  432. });
  433. if (totalAmount >= coupon.touchPrice) {
  434. selectCoupons.push(coupon);
  435. }
  436. });
  437. setPageCoupon();
  438. }
  439. // 设置页面显示
  440. function setPageCoupon() {
  441. var clubCouponId = $("#clubCouponId").val() * 1;
  442. var html = '<li><label><input type="radio" name="clubCouponId" id="bsy" value="0"><span class="couponDesc none">不使用优惠券</span></label></li>';
  443. selectCoupons.forEach(function (item) {
  444. var checked = '';
  445. var redemptionCode = '';
  446. if (clubCouponId === item.clubCouponId) {
  447. checked = 'checked="checked"';
  448. }
  449. if (!isNaN(item.redemptionCode)) {
  450. redemptionCode = '<span>兑换码:' + item.redemptionCode + '</span>';
  451. }
  452. html += '<li><label>';
  453. html += ' <input type="radio" name="clubCouponId" value="' + item.clubCouponId + '" ' + checked + '>';
  454. html += ' <span class="couponDesc">';
  455. html += ' <span>' + item.couponName + '</span>';
  456. html += redemptionCode;
  457. html += ' <span>' + item.couponDesc + '</span>';
  458. html += ' <span>有效期:' + item.receiveDate + ' - ' + item.useEndDate + '</span>';
  459. html += '</span></label></li>';
  460. });
  461. $("#couponBox").find(".couponContent").html(html);
  462. if (clubCouponId > 0) {
  463. $("#couponBox").find("input[name=clubCouponId][checked=checked]").trigger("change");
  464. }
  465. }
  466. // 勾选优惠券重新计算总价
  467. $("#couponBox").on("change", "input[name=clubCouponId]", function () {
  468. couponPrice = 0;
  469. var clubCouponId = $(this).val() * 1;
  470. selectCoupons.forEach(function (item) {
  471. if (item.clubCouponId * 1 === clubCouponId) {
  472. couponPrice = item.couponAmount;
  473. $("#clubCouponId").val(clubCouponId);
  474. $("#couponAmount").val(couponPrice);
  475. } else if (clubCouponId == 0) {
  476. couponPrice = 0;
  477. $("#clubCouponId").val('');
  478. $("#couponAmount").val(couponPrice);
  479. }
  480. });
  481. // 重新计算总价
  482. setOrderFee();
  483. });
  484. // 设置商品(二手)
  485. function orderSecondHandEditShop(obj) {
  486. var $tr = obj.parents('tr');
  487. var data = $tr.attr("data-value");
  488. data = JSON.parse(data);
  489. var productID = (data.productId == undefined) ? data.productID : data.productId;
  490. $.jBox.open("iframe:" + ctx + "/bulkpurchase/purchaseProduct/orderSecondHandProductForm?productId=" + productID,
  491. "设置商品", $(top.document).width() - 240, $(top.document).height() - 200, {
  492. top: 36,
  493. persistent: true,
  494. buttons: {
  495. "确定": "ok",
  496. "关闭": true
  497. },
  498. bottomText: "设置商品",
  499. submit: function (v, h, f) {
  500. if (v == "ok") {
  501. var $jboxFrame = $('#jbox-iframe');
  502. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  503. if (!items) {
  504. return false;
  505. } else {
  506. console.log(items[0]);
  507. setProductList(items[0], false); //设置商品列表
  508. setOrderFee(); //设置底部订单金额
  509. }
  510. return true;
  511. }
  512. },
  513. loaded: function (h) {
  514. }
  515. });
  516. }
  517. // 修改商品的时候统计下面的订单商品金额
  518. function setShopOrderFee(shopId) {
  519. var totalFee = 0;
  520. $($('#pTable_' + shopId)).find('.totalFee').each(function (index, element) {
  521. totalFee += Number($(this).html());
  522. });
  523. totalPromotions.forEach(function (item) {
  524. if (item.shopId == shopId && item.type == 3 && item.mode == 2) {
  525. var touchPrice = 0;
  526. item.promotionProducts.forEach(function (product) { //计算促销包含税费
  527. touchPrice += (product.number * product.price + product.totalTax * 1);
  528. });
  529. if (touchPrice >= item.touchPrice) {
  530. totalFee -= item.reducedPrice;
  531. }
  532. }
  533. });
  534. $($('#pTable_' + shopId)).prev('div').find('.bmd').html('¥' + totalFee.toFixed(2));
  535. }
  536. //删除商品
  537. function deleteShop(obj) {
  538. var $tr = obj.parents('tr');
  539. var $table = $tr.parents('table');
  540. // 协销赠品
  541. var productId = $tr.attr("id").split("_")[1];
  542. $('.productTable tbody tr.gift_' + productId).each(function (index, element) {
  543. $(this).remove();
  544. });
  545. // 促销
  546. var promotionsId = $tr.find('.tag').attr("data-id");
  547. var thisTouchPrice = 0;
  548. totalPromotions.forEach(function (item) {
  549. if (item.id == promotionsId) {
  550. for (var i = 0; i < item.promotionProducts.length; i++) {
  551. if (item.promotionProducts[i].productId == productId) {
  552. item.promotionProducts.splice(i--, 1);
  553. }
  554. }
  555. item.promotionProducts.forEach(function (p) {
  556. thisTouchPrice += p.number * p.price;
  557. });
  558. if (thisTouchPrice < item.touchPrice) {
  559. $('.productTable tbody tr.promotion_' + promotionsId).each(function (index, element) {
  560. $(this).remove();
  561. });
  562. }
  563. }
  564. });
  565. $tr.remove();
  566. if ($table.find('tr').length < 2) {
  567. //table里面没有商品了 table 也删掉 <2 是因为表头上有一个tr
  568. $table.prev('.order-rows').remove();
  569. $table.remove();
  570. }
  571. var shopId = $table.attr("id").split("_")[1];
  572. setShopOrderFee(shopId);
  573. setOrderFee(); //设置底部订单金额
  574. // initStages();//初始化分期信息
  575. //重新显示添加按钮(针对二手商品)
  576. $(".addSecondHandProduct").show();
  577. }
  578. function resetProductList(setData) {
  579. var productList = [];
  580. var productIdList = [];
  581. var skuIds = [];
  582. //var if (promotionsIds.indexOf(tempId)>=0) {
  583. $('.productTable tbody tr:not(.gift)').each(function (index, element) {
  584. var data = JSON.parse($(this).attr("data-value"));
  585. productList.push(data);
  586. if(data.skuStr){
  587. var strings = data.skuStr.split("/");
  588. var skuId = strings[0];
  589. skuIds.push(skuId);
  590. }else{
  591. var skuId=data.skuList[0].skuId;
  592. skuIds.push(skuId);
  593. }
  594. productIdList.push(data.productId);
  595. });
  596. $('.productTable').each(function (index, element) {
  597. $(this).prev('.order-rows').remove();
  598. $(this).remove();
  599. });
  600. promotionsIds = [];
  601. totalPromotions = [];
  602. giftPromotionsIds = [];
  603. if (!setData) { //删除
  604. productList.forEach(function (data) {
  605. setProductList(data, false);
  606. });
  607. } else {
  608. var skuId;
  609. if(setData.skuStr){
  610. var strings = setData.skuStr.split("/");
  611. skuId = strings[0];
  612. }else{
  613. skuId=setData.skuList[0].skuId;
  614. }
  615. if (skuIds.indexOf(skuId) >= 0) {
  616. //设置
  617. productList.forEach(function (data) {
  618. if (setData.productId == data.productId) {
  619. setProductList(setData, false);
  620. } else {
  621. setProductList(data, false);
  622. }
  623. });
  624. } else {
  625. //新增
  626. productList.forEach(function (data) {
  627. setProductList(data, false);
  628. });
  629. setProductList(setData, false);
  630. }
  631. }
  632. setOrderFee(); //设置底部订单金额
  633. }
  634. function deleteShopProduct(obj) {
  635. obj.parents('tr').remove();
  636. var $table = obj.parents('tr').parents('table');
  637. if ($table.find('tr').length < 2) {
  638. //table里面没有商品了 table 也删掉 <2 是因为表头上有一个tr
  639. $table.prev('.order-rows').remove();
  640. $table.remove();
  641. }
  642. resetProductList();
  643. if ($('.productTable tbody tr').length === 0) {
  644. setOrderFee();
  645. // 展示可选优惠券列表
  646. getShownCouponList();
  647. }
  648. $(".addSecondHandProduct").show();
  649. }
  650. function editShopProduct(obj) {
  651. var $tr = obj.parents('tr');
  652. var data = $tr.attr("data-value");
  653. data = JSON.parse(data);
  654. var userId = $("#inputForm").find("[name*='bpOrderUserinfo.userId']").val();
  655. var productID = (data.productId == undefined) ? data.productID : data.productId;
  656. var secondHandType = (data.secondHandType == undefined) ? 0 : data.secondHandType;
  657. var discount = (data.discount == undefined) ? 100 : data.discount;
  658. var productCategory = (data.productCategory == undefined) ? 1 : data.productCategory;
  659. var price = (data.price == undefined) ? 0 : data.price;
  660. var includedTax = (data.includedTax == undefined) ? 2 : data.includedTax;
  661. var invoiceType = (data.invoiceType == undefined) ? 3 : data.invoiceType;
  662. var taxRate = (data.taxRate == undefined) ? 0 : data.taxRate;
  663. var addedValueTax = (data.addedValueTax == undefined) ? 0 : data.addedValueTax;
  664. var totalAddedValueTax = (data.totalAddedValueTax == undefined) ? 0 : data.totalAddedValueTax;
  665. var couponsLogo = (data.couponsLogo == undefined) ? 1 : data.couponsLogo;
  666. var svipReduction = (data.svipReduction == undefined) ? 0 : data.svipReduction;
  667. var svipTaxReduction = (data.svipTaxReduction == undefined) ? 0 : data.svipTaxReduction;
  668. $.jBox.open("iframe:" + ctx + "/bulkpurchase/purchaseProduct/formOrderProduct?productId=" + productID +
  669. "&secondHandType=" + secondHandType +
  670. "&discount=" + discount + "&productCategory=" + productCategory + "&price=" + price + "&includedTax=" +
  671. includedTax + "&userId=" + userId +
  672. "&invoiceType=" + invoiceType + "&taxRate=" + taxRate + "&addedValueTax=" + addedValueTax +
  673. "&totalAddedValueTax=" + totalAddedValueTax + "&couponsLogo=" + couponsLogo + "&svipReduction=" + svipReduction +
  674. "&svipTaxReduction=" + svipTaxReduction,
  675. "设置商品", $(top.document).width() - 240, $(top.document).height() - 200, {
  676. top: 36,
  677. persistent: true,
  678. buttons: {
  679. "确定": "ok",
  680. "关闭": true
  681. },
  682. bottomText: "设置商品",
  683. submit: function (v, h, f) {
  684. if (v == "ok") {
  685. var $jboxFrame = $('#jbox-iframe');
  686. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  687. if (!items) {
  688. return false;
  689. } else {
  690. console.log('设置:' + items[0]);
  691. resetProductList(items[0]); //设置商品列表
  692. }
  693. return true;
  694. }
  695. },
  696. loaded: function (h) {
  697. }
  698. });
  699. }
  700. // 展示商品选择框
  701. function showShopSelect(iframe) {
  702. var userId = $("#inputForm").find("[name*='bpOrderUserinfo.userId']").val();
  703. iframe = iframe + "&userId=" + userId;
  704. top.$.jBox(iframe, {
  705. iframeScrolling: 'yes',
  706. width: $(top.document).width() - 100,
  707. height: $(top.document).height() - 160,
  708. persistent: true,
  709. title: "选择商品",
  710. bottomText: '请从可供选择的项目中选择一个',
  711. buttons: {
  712. "确定": '1',
  713. "关闭": '-1'
  714. },
  715. submit: function (v, h, f) {
  716. //确定
  717. var $jboxFrame = top.$('#jbox-iframe');
  718. var $mainFrame = top.$('#mainFrame');
  719. if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
  720. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  721. if (!items) {
  722. return false;
  723. } else if (items.length > 0) {
  724. console.log('添加:' + JSON.stringify(items[0]));
  725. resetProductList(items[0]); //设置商品列表
  726. return true;
  727. } else {
  728. top.$.jBox.tip("请选择...");
  729. return false;
  730. }
  731. }
  732. },
  733. });
  734. }
  735. // 展示优惠券详情
  736. function showCouponDetail(userId, productId) {
  737. var url = ctx + "/coupon/cmCoupon/productDetails?userId=" + userId + "&productId=" + productId;
  738. var title = '';
  739. title = "查看优惠券";
  740. top.$.jBox("iframe:" + url, {
  741. iframeScrolling: 'yes',
  742. width: $(top.document).width() - 600,
  743. height: $(top.document).height() - 250,
  744. persistent: true,
  745. title: title,
  746. buttons: {"确定": '1'}
  747. });
  748. }
  749. // 展示二手商品选择框
  750. function showSencondHandSelect(iframe) {
  751. var userId = $("#inputForm").find("[name*='bpOrderUserinfo.userId']").val();
  752. iframe = iframe + "&userId=" + userId;
  753. top.$.jBox(iframe, {
  754. iframeScrolling: 'yes',
  755. width: $(top.document).width() - 100,
  756. height: $(top.document).height() - 160,
  757. persistent: true,
  758. title: "选择商品",
  759. bottomText: '请从可供选择的项目中选择一个',
  760. buttons: {
  761. "确定": '1',
  762. "关闭": '-1'
  763. },
  764. submit: function (v, h, f) {
  765. //确定
  766. var $jboxFrame = top.$('#jbox-iframe');
  767. var $mainFrame = top.$('#mainFrame');
  768. if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
  769. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  770. if (!items) {
  771. return false;
  772. } else if (items.length > 0) {
  773. console.log($('.productTable'));
  774. $(('.producttable')).remove();
  775. setSeondHandProductList(items[0]); //设置二手商品列表
  776. // 隐藏商品添加入口
  777. $(".addSecondHandProduct").hide();
  778. return true;
  779. } else {
  780. top.$.jBox.tip("请选择...");
  781. return false;
  782. }
  783. }
  784. },
  785. });
  786. }
  787. /**
  788. * 设置商品列表(正常商品)
  789. * @param items
  790. */
  791. function setProductList(data) {
  792. console.log("设置" + JSON.stringify(data));
  793. var userId = $("#inputForm").find("[name*='bpOrderUserinfo.userId']").val();
  794. var orderStatus = $("#orderStatus").val() ? $("#orderStatus").val() * 1 : 0;
  795. data.productType = 0;
  796. var shopFee = data.shopFee;
  797. var cmPromotion = '';
  798. var ladderPrice = '';
  799. // 如果存在促销活动
  800. if (data.cmPromotion) {
  801. var tempId = data.cmPromotion.id * 1;
  802. data.promotionsId = data.cmPromotion.id;
  803. // 没有折扣,才享受促销优惠
  804. if (data.discount * 1 === 100) {
  805. var tempProduct = {
  806. shopId: data.shopId,
  807. productId: data.productId,
  808. price: data.price,
  809. number: data.num,
  810. totalTax: data.totalAddedValueTax
  811. };
  812. if (promotionsIds.indexOf(tempId) >= 0) {
  813. totalPromotions.forEach(function (item) {
  814. if (item.id * 1 === tempId) {
  815. for (var i = 0; i < item.promotionProducts.length; i++) {
  816. if (item.promotionProducts[i].productId == data.productId) {
  817. item.promotionProducts.splice(i--, 1);
  818. }
  819. }
  820. item.promotionProducts.push(tempProduct);
  821. }
  822. })
  823. } else {
  824. promotionsIds.push(tempId);
  825. var tempPromotions = JSON.parse(JSON.stringify(data.cmPromotion));
  826. if (tempPromotions.mode == 1) {
  827. tempPromotions.reducedPrice = data.price - tempPromotions.touchPrice;
  828. }
  829. if (data.cmPromotion.type == 3) {
  830. tempPromotions.shopId = data.shopId;
  831. }
  832. tempPromotions.promotionProducts = [];
  833. tempPromotions.promotionProducts.push(tempProduct);
  834. totalPromotions.push(tempPromotions);
  835. }
  836. if (data.cmPromotion.mode == 1) {
  837. data.totalFee = (data.cmPromotion.touchPrice * data.num + data.totalAddedValueTax * 1);
  838. cmPromotion = '<span class="tag" data-id="' + tempId + '"><em style="background:green">' + data
  839. .cmPromotion.name + '</em>优惠价:' + data.cmPromotion.touchPrice + '</span>';
  840. } else if (data.cmPromotion.mode == 2) {
  841. cmPromotion = '<span class="tag" data-id="' + tempId + '"><em style="background:#F60">' + data
  842. .cmPromotion.name + '</em>满' + data.cmPromotion.touchPrice + '减' + data.cmPromotion.reducedPrice +
  843. '</span>';
  844. } else if (data.cmPromotion.mode == 3) {
  845. cmPromotion = '<span class="tag" data-id="' + tempId + '"><em style="background:purple">' + data
  846. .cmPromotion.name + '</em>满' + data.cmPromotion.touchPrice + '赠送商品' + '</span>';
  847. }
  848. } else {
  849. cmPromotion = '<span class="red">有折扣,不享受促销优惠</span>'
  850. }
  851. } else {
  852. if (data.ladderPriceFlag * 1 === 1) {
  853. ladderPrice = '<br><a href="javascript:;" class="ladderPrice"><span>阶梯价格</span></a>';
  854. if (data.ladderPriceList && data.ladderPriceList.length > 0) {
  855. var ladder = '<p><span>起订量</span><span>价格</span></p>';
  856. for (var i = 0; i < data.ladderPriceList.length; i++) {
  857. ladder += '<p data-num="' + data.ladderPriceList[i].buyNum + '"><span>' + data.ladderPriceList[i]
  858. .buyNumRangeShow + '</span><span class="price">' + data.ladderPriceList[i].buyPrice +
  859. '</span></p>';
  860. }
  861. ladderPrice = '<br><a href="javascript:;" class="ladderPrice"><span>阶梯价格</span><div class="list">' +
  862. ladder + '</div></a>'
  863. }
  864. }
  865. }
  866. var cmCouponBtn = '---';
  867. if (data.couponsLogo * 1 === 2) {
  868. cmCouponBtn = '<a href="javascript:;" onclick="showCouponDetail(' + userId + ',' + data.productId + ')">查看</a>';
  869. }
  870. var skuStr = "<td>" + data.skuList[0].unit + "</td>";
  871. var skuIdStr = "<td>" + data.skuList[0].skuId + "</td>";
  872. var price = data.skuList[0].price;
  873. //未选择sku,默认sku[0],选择了sku,skustr不为空
  874. if (data.skuStr) {
  875. var strings = data.skuStr.split("/");
  876. var skuId = strings[0];
  877. var index = strings[1] * 1;
  878. skuStr = "<td>" + data.skuList[index].unit + "</td>";
  879. skuIdStr = "<td>" + skuId + "</td>";
  880. //price
  881. price = data.skuList[index].price;
  882. }
  883. var str =
  884. "<tr id='product_" + data.productId + "' data-value='" + JSON.stringify(data) + "' data-index='" +
  885. product_index + "'>" +
  886. "<td>" + data.productId + "</td>" +
  887. skuIdStr +
  888. "<td hidden><input type='hidden' name='orderProduct[" + product_index + "].enabledStatus' id='orderProduct" +
  889. product_index + ".enabledStatus' value='" + JSON.stringify(data) + "'/>" + data.shopId + "</td>" +
  890. "<td hidden>" + data.shopName + "</td>" +
  891. "<td class='fix-width'>" + data.name + "</td><td hidden></td>" +
  892. (data.productCategory == 2 ? "" : ("<td>" + data.shopName + "</td>")) +
  893. skuStr +
  894. "<td>" + data.num + (data.presentNum > 0 ? "(" + data.presentNum + ")" : "") + "</td>" +
  895. //价格
  896. (data.svipPriceFlag == 1 ? "<td>" + data.discountPrice :
  897. (data.discount * 1 === 100 && data.cmPromotion && data.cmPromotion.mode == 1 ? ("<td><del>" + price +
  898. "</del>") : ("<td>" + price))) +
  899. ((data.svipPriceFlag == 1 || (data.includedTax != null && data.includedTax != '' && data.includedTax != 2)) ? "<label style='color: red'>(" : "") +
  900. (data.svipPriceFlag == 1 ? "超级会员价" : "") +
  901. ((data.svipPriceFlag == 1 && (data.includedTax != null && data.includedTax != '' && data.includedTax != 2)) ? "," : "") +
  902. (data.includedTax == 1 ? "含税" : data.includedTax == 0 && (data
  903. .invoiceType == 1 || data.invoiceType == 2) ? "不含税-能开票" : data
  904. .includedTax != '' && data.includedTax == 0 && data.invoiceType == 3 ?
  905. "不含税-不能开票" : "") +
  906. ((data.svipPriceFlag == 1 || (data.includedTax != null && data.includedTax != '' && data.includedTax != 2)) ? ")</label>" : "") +
  907. "</td>" +
  908. "<td>" + data.discount + "</td>" +
  909. (data.discount * 1 === 100 && data.cmPromotion && data.cmPromotion.mode == 1 ? ("<td><del>" + data
  910. .discountPrice + "</del></td>") : ("<td>" + data.discountPrice +
  911. ladderPrice + "</td>")) +
  912. (data.includedTax != '' && (data.includedTax == 0 && data.invoiceType == 3) ? ("<td>---</td>") : data
  913. .includedTax == 2 ? ("<td>0%</td>") : ("<td>" + data.taxRate + "%</td>")) +
  914. (data.includedTax == 1 || (data.includedTax != '' && data.includedTax == 0 && data.invoiceType == 3) ? (
  915. "<td>---</td>") : data.addedValueTax == null ? ("<td>0</td>") : ("<td>" + data.addedValueTax + "</td>")) +
  916. (data.includedTax == 1 || (data.includedTax != '' && data.includedTax == 0 && data.invoiceType == 3) ? (
  917. "<td>---</td>") : data.totalAddedValueTax == null ? ("<td>0</td>") : ("<td>" + data.totalAddedValueTax +
  918. "</td>")) +
  919. "<td class='totalFee'>" + Number(data.totalFee).toFixed(2) + "</td>" +
  920. // "<td>"+ Math.round(shopFee*100)/100 +"</td>"+
  921. "<td>" + (data.buyAgainFlag == 1 ? "是" : "否") + "</td>" +
  922. ((data.productCategory == 2) ? "" : "<td>" + cmPromotion + "</td>") +
  923. ((data.productCategory == 2) ? "" : "<td>" + cmCouponBtn + "</td>") +
  924. "<td>" + (orderStatus != 0 ? "" : (data.productCategory == 2) ?
  925. "<a href='javascript:void(0);' onclick='orderSecondHandEditShop($(this))'>设置</a>&nbsp;&nbsp;<a href='javascript:void(0);' onclick='deleteShopProduct($(this))'>删除商品</a>" :
  926. "<a href='javascript:void(0);' onclick='editShopProduct($(this))'>设置</a>&nbsp;&nbsp;<a href='javascript:void(0);' onclick='deleteShopProduct($(this))'>删除商品</a>"
  927. ) +
  928. "</td>" +
  929. "</tr>";
  930. appendProductList(str, data, cmPromotion);
  931. }
  932. function appendProductList(str, data, cmPromotion) {
  933. //把表中存在的删除
  934. var removeBeforeSoon = false; //是这一次移除
  935. var removeEle;
  936. var skuId;
  937. if (data.skuStr) {
  938. var strings = data.skuStr.split("/");
  939. skuId = strings[0];
  940. } else {
  941. skuId = data.skuList[0].skuId;
  942. }
  943. console.log("skuId---------------->" + skuId);
  944. $('.productTable tbody tr:not(.gift)').each(function (index, element) {
  945. console.log("我看看-------------" + $(this).find("td:nth-child(2)").html());
  946. if ($(this).find("td:nth-child(2)").html() == skuId) {
  947. removeEle = $(this).parent();
  948. $(this).remove();
  949. removeBeforeSoon = true;
  950. }
  951. });
  952. if (removeBeforeSoon) {
  953. //走到这里 说明是修改
  954. console.log("修改------------");
  955. removeEle.append(str);
  956. } else {
  957. //这里就是新加了 //先看有没有这个 当前这个商品的供应商的table
  958. if ($('#pTable_' + data.shopId).length != 0) {
  959. $('#pTable_' + data.shopId + ' tbody').append(str);
  960. } else {
  961. appendShopOrderHead(data, str, cmPromotion);
  962. }
  963. }
  964. setShopOrderFee(data.shopId);
  965. // setOrderFee(); //设置底部订单金额
  966. product_index++;
  967. // 设置赠品
  968. setGiftHtmlList(data, cmPromotion);
  969. // 展示可选优惠券列表
  970. getShownCouponList();
  971. }
  972. function appendShopOrderHead(data, str, cmPromotion) {
  973. var html = '<div class="order-rows">' +
  974. '<br><p>' +
  975. '<span class="fix-right-margin"><label>下单时间:</label></span>' +
  976. '<span class="fix-right-margin"><label>子订单号(ID):</label></span>' +
  977. '<span class="fix-right-margin"><label>子订单金额:</label><span class="bmd"></span></span>' +
  978. '</p>' +
  979. '<p> <label>供应商:</label>' + data.shopName + (data.cmPromotion && data.cmPromotion.type == 3 ? cmPromotion :
  980. '') + '</p>' +
  981. '<p><span><label>留言:</label>' +
  982. "<input id='shopID_" + data.shopId + "' type='text' class='shopNote' data-shopid='" + data.shopId + "'>" +
  983. '<input type="hidden" name="shopNote">' +
  984. '</span></p>' +
  985. '</div>' + '<table id="pTable_' + data.shopId +
  986. '" class="productTable table table-striped table-bordered table-condensed">' +
  987. '<thead>' +
  988. '<tr>' +
  989. '<th>商品ID</th>' +
  990. '<th>skuId</th>' +
  991. '<th hidden></th>' +
  992. '<th hidden></th>' +
  993. '<th class="fix-width">商品名称</th><th hidden></th>' +
  994. ((data.productCategory == 2) ? '' : '<th>供应商名称</th>') +
  995. '<th>规格</th>' +
  996. '<th>数量(赠品数)</th>' +
  997. '<th>单价</th>' +
  998. '<th>折扣</th>' +
  999. '<th>折后单价</th>' +
  1000. '<th>税率</th>' +
  1001. '<th>单个税费</th>' +
  1002. '<th>税费</th>' +
  1003. '<th>总价</th>' +
  1004. /*'<th>应付供应商</th>' +*/
  1005. '<th>能否复购</th>' +
  1006. ((data.productCategory == 2) ? '' : '<th>促销活动</th>') +
  1007. ((data.productCategory == 2) ? "" : "<td>优惠券</td>") +
  1008. '<th>操作</th>' +
  1009. '</tr>' +
  1010. '</thead>' +
  1011. '<tbody>' + str + '</tbody></table>';
  1012. $('#product_index').before(html);
  1013. }
  1014. function setGiftHtmlList(data, cmPromotion) {
  1015. console.log("设置赠品" + JSON.stringify(data));
  1016. if (data.presentNum > 0) {
  1017. // 已经添加的,重新添加
  1018. $('.productTable tbody tr.gift_' + data.productId).each(function (index, element) {
  1019. $(this).remove();
  1020. });
  1021. var present = JSON.parse(JSON.stringify(data));
  1022. present.productType = 1;
  1023. present.num = data.presentNum;
  1024. present.price = 0;
  1025. present.discountPrice = 0;
  1026. present.orderProductId = '';
  1027. present.orderProductID = '';
  1028. var giftStr = "<tr id='product_gift_" + present.productId + "' class='gift gift_" + present.productId +
  1029. "' data-value='" + JSON.stringify(present) + "' data-index='" + product_index + "'>" +
  1030. "<td>" + present.productId + "</td>" +
  1031. "<td hidden><input type='hidden' name='orderProduct[" + product_index +
  1032. "].enabledStatus' id='orderProduct" + product_index + ".enabledStatus' value='" + JSON.stringify(present) +
  1033. "'/>" + present.shopId + "</td>" +
  1034. "<td hidden>" + present.shopName + "</td>" +
  1035. "<td class='fix-width'><i class='red'>协商赠品:</i>" + present.name + "</td><td hidden></td>" +
  1036. "<td>" + present.num + "</td>" +
  1037. "<td>0</td>" +
  1038. "<td>100</td>" +
  1039. "<td>0</td>" +
  1040. "<td>0</td>" +
  1041. "<td>0</td>" +
  1042. "<td>0</td>" +
  1043. "<td>0</td>" +
  1044. /*"<td>"+ Math.round(present.shopFee*100)/100 +"</td>"+*/
  1045. "<td>否</td>" +
  1046. "<td></td>" +
  1047. "<td></td>" +
  1048. "</tr>";
  1049. product_index++;
  1050. appendGiftsList(present, giftStr, cmPromotion);
  1051. }
  1052. if (data.cmPromotion && data.cmPromotion.mode == 3) {
  1053. var thisTouchPrice = 0;
  1054. totalPromotions.forEach(function (item) {
  1055. if (data.cmPromotion.id == item.id) {
  1056. item.promotionProducts.forEach(function (p) {
  1057. thisTouchPrice += (p.number * p.price + p.totalTax * 1);
  1058. });
  1059. }
  1060. });
  1061. //本单总价>=满赠条件金额
  1062. if (thisTouchPrice >= data.cmPromotion.touchPrice) {
  1063. if (giftPromotionsIds.indexOf(data.cmPromotion.id) < 0) {
  1064. // 已经添加的,重新添加
  1065. $('.productTable tbody tr.promotion_' + cmPromotion.id).each(function (index, element) {
  1066. $(this).remove();
  1067. });
  1068. // 记录赠品促销
  1069. giftPromotionsIds.push(data.cmPromotion.id);
  1070. // 获取赠品
  1071. var getGiftPath = $('#ctx').val() + '/product/cmPromotions/getGifts';
  1072. $.getJSON(getGiftPath, {
  1073. id: data.cmPromotion.id
  1074. }, function (res) {
  1075. if (res && res.length > 0) {
  1076. res.forEach(function (gift) {
  1077. gift.productType = 2;
  1078. gift.price = 0;
  1079. gift.discountPrice = 0;
  1080. gift.promotionsId = data.cmPromotion.id;
  1081. gift.orderProductId = '';
  1082. gift.orderProductID = '';
  1083. if ($("#product_promotion_" + gift.productId).length > 0) {
  1084. var pageGift = JSON.parse($("#product_promotion_" + gift.productId)
  1085. .attr("data-value"));
  1086. if (gift.discounts * 1 === 1) {
  1087. var b = Math.floor(thisTouchPrice / data.cmPromotion.touchPrice);
  1088. gift.num = gift.num * 1 * b + pageGift.num * 1;
  1089. } else {
  1090. gift.num = gift.num * 1 + pageGift.num * 1;
  1091. }
  1092. $("#product_promotion_" + gift.productId).remove();
  1093. }
  1094. if (gift.discounts * 1 === 1) {
  1095. var b = Math.floor(thisTouchPrice / data.cmPromotion.touchPrice);
  1096. gift.num = gift.num * 1 * b;
  1097. } else {
  1098. gift.num = gift.num * 1;
  1099. }
  1100. var giftStr = "<tr id='product_promotion_" + gift.productId +
  1101. "' class='gift promotions promotion_" + data.cmPromotion.id +
  1102. "' data-value='" + JSON.stringify(gift) + "' gift-index='" +
  1103. product_index + "'>" +
  1104. "<td>" + gift.productId + "</td>" +
  1105. "<td hidden><input type='hidden' name='orderProduct[" + product_index +
  1106. "].enabledStatus' id='orderProduct" + product_index +
  1107. ".enabledStatus' value='" + JSON.stringify(gift) + "'/>" + gift.shopId +
  1108. "</td>" +
  1109. "<td class='fix-width'><i class='red'>促销赠品:</i>" + gift.name +
  1110. "<td>" + gift.shopName + "</td>" +
  1111. "</td><td hidden></td>" +
  1112. "<td>" + gift.num + "</td>" +
  1113. "<td>0</td>" +
  1114. "<td>100</td>" +
  1115. "<td>0</td>" +
  1116. "<td>0</td>" +
  1117. "<td>0</td>" +
  1118. "<td>0</td>" +
  1119. "<td>0</td>" +
  1120. /*"<td>"+ Math.round(gift.shopFee*100)/100 +"</td>"+*/
  1121. "<td>否</td>" +
  1122. "<td></td>" +
  1123. "<td></td>" +
  1124. "</tr>";
  1125. product_index++;
  1126. appendGiftsList(gift, giftStr, cmPromotion);
  1127. });
  1128. }
  1129. });
  1130. }
  1131. }
  1132. }
  1133. // 重新设置底部订单金额
  1134. // setOrderFee();
  1135. // 重新设置返佣订单选项
  1136. showRebateCheck();
  1137. }
  1138. function appendGiftsList(gift, giftStr, cmPromotion) {
  1139. if ($('#pTable_' + gift.shopId).length != 0) {
  1140. $('#pTable_' + gift.shopId + ' tbody').append(giftStr);
  1141. } else {
  1142. appendShopOrderHead(gift, giftStr, cmPromotion);
  1143. }
  1144. // 重新设置底部订单金额
  1145. setOrderFee();
  1146. }
  1147. /**
  1148. * 设置商品列表(二手商品)
  1149. * @param items
  1150. */
  1151. function setSeondHandProductList(data) {
  1152. console.log(data);
  1153. data.productType = 0;
  1154. var productID = (data.productId == undefined) ? data.productID : data.productId;
  1155. //把表中存在的删除
  1156. var removeBeforeSoon = false; //是这一次移除
  1157. var removeEle;
  1158. $('.productTable tbody tr').each(function (index, element) {
  1159. if ($(this).find("td:nth-child(1)").html() == productID) {
  1160. removeEle = $(this).parent();
  1161. $(this).remove();
  1162. removeBeforeSoon = true;
  1163. }
  1164. });
  1165. var buyAgain = "<td>否</td>";
  1166. var str = '';
  1167. var shopFee = data.shopFee;
  1168. str +=
  1169. "<tr id='product_" + productID + "' data-value='" + JSON.stringify(data) + "' data-index='" + product_index +
  1170. "'>" +
  1171. "<td>" + productID + "</td>" +
  1172. "<td hidden>" + data.shopId + "</td>" +
  1173. "<td hidden>" + data.shopName + "</td>" +
  1174. "<td class='fix-width'>" + data.name + "</td>" +
  1175. "<td class='fix-width' hidden>" + "<input type='hidden' name='orderProduct[" + product_index +
  1176. "].enabledStatus' id='orderProduct" + product_index + ".enabledStatus'/>" + data.shopName + "</td>" +
  1177. "<td>" + data.num + "(" + data.presentNum + ")" + "</td>" +
  1178. "<td>" + data.price + "</td>" +
  1179. "<td>" + data.discount + "</td>" +
  1180. "<td>" + data.discountPrice + "</td>" +
  1181. "<td>" + data.taxRate + "</td>" +
  1182. "<td>" + data.addedValueTax + "</td>" +
  1183. "<td>" + data.totalAddedValueTax + "</td>" +
  1184. "<td class='totalFee'>" + data.totalFee + "</td>" +
  1185. /*"<td>"+ Math.round(shopFee*100)/100 +"</td>"+*/
  1186. // 以下三个应付不显示,但是内容值参与计算并保存---关闭控制入口移动到财务管理中控制20181201
  1187. // "<td>"+ data.shopFee+"</td>"+
  1188. // "<td>"+ data.otherFee +"</td>"+
  1189. // "<td>"+ data.cmFee +"</td>"+
  1190. buyAgain +
  1191. "<td>" +
  1192. "<a href='javascript:void(0);' onclick='orderSecondHandEditShop($(this))'>设置</a>&nbsp;&nbsp;" +
  1193. "<a href='javascript:void(0);' onclick='deleteShop($(this))'>删除商品</a>" +
  1194. "</td>" +
  1195. "</tr>";
  1196. if (removeBeforeSoon) {
  1197. removeEle.append(str);
  1198. //走到这里 说明是修改
  1199. } else {
  1200. //这里就是新加了
  1201. //先看有没有这个 当前这个商品的供应商的table
  1202. if ($('#pTable_' + data.shopId).length != 0) {
  1203. $('#pTable_' + data.shopId + ' tbody').append(str);
  1204. } else {
  1205. var html = '<div class="order-rows">' +
  1206. '<span class="fix-right-margin"><label>下单时间:</label></span>' +
  1207. '<span class="fix-right-margin"><label>子订单号(ID):</label></span>' +
  1208. '<span class="fix-right-margin"><label>子订单金额:</label><span class="bmd"></span></span>' +
  1209. '<br>' +
  1210. '<span><label>留言:</label>' +
  1211. "<input id='shopID_" + data.shopId + "' type='text' class='shopNote' data-shopid='" + data.shopId +
  1212. "'>" +
  1213. '<input type="hidden" name="shopNote">' +
  1214. '</span>' +
  1215. '</div>' + '<table id="pTable_' + data.shopId +
  1216. '" class="productTable table table-striped table-bordered table-condensed">' +
  1217. '<thead>' +
  1218. '<tr>' +
  1219. '<th>商品ID</th>' +
  1220. '<th hidden></th>' +
  1221. '<th hidden></th>' +
  1222. '<th class="fix-width">商品名称</th>' +
  1223. '<th class="fix-width" hidden>供应商名称</th>' +
  1224. '<th>数量(赠品数)</th>' +
  1225. '<th>单价</th>' +
  1226. '<th>折扣</th>' +
  1227. '<th>折后单价</th>' +
  1228. '<th>税率</th>' +
  1229. '<th>单个税费</th>' +
  1230. '<th>税费</th>' +
  1231. '<th>总价</th>' +
  1232. /*'<th>应付供应商</th>' +*/
  1233. '<th>能否复购</th>' +
  1234. '<th>操作</th>' +
  1235. '</tr>' +
  1236. '</thead>' +
  1237. '<tbody>' + str + '</tbody></table>';
  1238. $('#product_index').before(html);
  1239. }
  1240. }
  1241. setShopOrderFee(data.shopId);
  1242. setOrderFee(); //设置底部订单金额
  1243. product_index++;
  1244. }
  1245. //设置订单金额信息
  1246. function setOrderFee() { //不考虑经理折扣、运费,此时 商品总金额=订单总额=应付总额
  1247. var productTotalFee = 0, //商品总金额
  1248. productCount = 0, // 商品总数
  1249. presentCount = 0, //协商赠送商品数
  1250. giftCount = 0, //促销赠品数
  1251. orderTotalFee = 0, //订单总额
  1252. reducedPrice = 0, //促销满减
  1253. payTotalFee = 0, //应付总额
  1254. svipFullReduction = 0; //超级会员优惠
  1255. var couponPrice = $("#couponAmount").val() ? $("#couponAmount").val() * 1 : 0;
  1256. $('.productTable tbody tr:not(.gift)').each(function (index, element) {
  1257. var obj = JSON.parse($(this).attr("data-value"));
  1258. productTotalFee = ((Number(productTotalFee) * 100 + Number(obj.num * obj.price) * 100 + Number(obj
  1259. .totalAddedValueTax) * 100) / 100 + Number(obj.svipTaxReduction)).toFixed(2);
  1260. productCount = Number(productCount) + Number(obj.num);
  1261. presentCount = Number(presentCount) + Number(obj.presentNum);
  1262. orderTotalFee = ((Number(orderTotalFee) * 100 + Number(obj.totalFee) * 100) / 100).toFixed(2);
  1263. payTotalFee = ((Number(payTotalFee) * 100 + Number(obj.totalFee) * 100) / 100).toFixed(2);
  1264. svipFullReduction = ((Number(svipFullReduction) * 100 + Number(obj.svipReduction) * obj.num * 100) / 100).toFixed(2);
  1265. });
  1266. $('.productTable tbody tr.promotions').each(function (index, element) {
  1267. var obj = JSON.parse($(this).attr("data-value"));
  1268. giftCount = Number(giftCount) + Number(obj.num);
  1269. });
  1270. // 计算促销折扣
  1271. totalPromotions.forEach(function (item) {
  1272. console.log(totalPromotions);
  1273. if (item.mode == 2) {
  1274. var touchPrice = 0;
  1275. item.promotionProducts.forEach(function (product) {
  1276. touchPrice += (product.number * product.price + product.totalTax * 1);
  1277. });
  1278. if (touchPrice >= item.touchPrice) {
  1279. if (item.discount * 1 === 1) {
  1280. var b = Math.floor(touchPrice / item.touchPrice);
  1281. reducedPrice += (b * item.reducedPrice);
  1282. payTotalFee -= reducedPrice;
  1283. } else {
  1284. reducedPrice += item.reducedPrice;
  1285. payTotalFee -= item.reducedPrice;
  1286. }
  1287. }
  1288. }
  1289. });
  1290. // 优惠券折扣
  1291. if (couponPrice > 0) {
  1292. orderTotalFee -= couponPrice;
  1293. payTotalFee -= couponPrice;
  1294. }
  1295. $(".productTotalFee").text((productTotalFee * 1).toFixed(2));
  1296. $(".promotionFullReduction").text((reducedPrice * 1).toFixed(2));
  1297. $(".couponPrice").text((couponPrice * 1).toFixed(2));
  1298. $(".productCount").text(productCount);
  1299. $(".presentCount").text(presentCount + giftCount);
  1300. $(".presentCount1").text(presentCount + giftCount);
  1301. $("#presentCount").val(presentCount);
  1302. $("#promotionalGiftsCount").val(giftCount);
  1303. $(".orderTotalFee").text(orderTotalFee);
  1304. $(".payTotalFee").text(payTotalFee);
  1305. $(".svipFullReduction").text(svipFullReduction);
  1306. $("#svipFullReduction").val(svipFullReduction);
  1307. $("#discount").val('0.00');
  1308. setProductTotalFee(); //重新设置经理折扣
  1309. }
  1310. // 修改数量
  1311. function changenum(index) {
  1312. var $num = $("#num" + index);
  1313. var numVal = $num.val();
  1314. var $checkItem = $("#check-item" + index);
  1315. var orderProductStr = $($checkItem).val();
  1316. var obj = JSON.parse(orderProductStr);
  1317. if (numVal != null && numVal != "" && typeof (numVal) != "undefined") {
  1318. if (parseInt(numVal) + "" != numVal || parseInt(numVal) < 1) {
  1319. alertx("数量必须大于0,并且是一个整数");
  1320. $num.val(obj["num"]);
  1321. return;
  1322. }
  1323. obj["num"] = numVal;
  1324. setLadderPrice(obj, numVal, index);
  1325. var result = JSON.stringify(obj);
  1326. $($checkItem).val(result);
  1327. //重新计算税费
  1328. taxRateVal(index);
  1329. } else {
  1330. $num.val(obj["num"]);
  1331. alertx("您输入的数量有误,请重新输入");
  1332. }
  1333. }
  1334. //加减数量
  1335. function presentNum(index, type) {
  1336. var $num = $("#num" + index);
  1337. var numVal = $num.val();
  1338. if (numVal != null && numVal != "" && typeof (numVal) != "undefined") {
  1339. if (type == 'del') {
  1340. numVal = parseInt(numVal) - 1;
  1341. } else if (type == 'add') {
  1342. numVal = parseInt(numVal) + 1;
  1343. }
  1344. if (numVal < 1) {
  1345. alertx("商品数量不能小于0")
  1346. } else {
  1347. $num.val(numVal);
  1348. //重新设置选中json对象值
  1349. var $checkItem = $("#check-item" + index);
  1350. var orderProductStr = $($checkItem).val();
  1351. var obj = JSON.parse(orderProductStr);
  1352. obj["num"] = numVal;
  1353. setLadderPrice(obj, numVal, index);
  1354. var result = JSON.stringify(obj);
  1355. $($checkItem).val(result);
  1356. //重新计算税费
  1357. taxRateVal(index);
  1358. }
  1359. }
  1360. }
  1361. function setLadderPrice(obj, numVal, index) {
  1362. if (obj["ladderPriceFlag"] * 1 === 1) {
  1363. var ladderList = obj["ladderPriceList"];
  1364. var resultLadder = 0;
  1365. for (var i = 0; i < ladderList.length; i++) {
  1366. if (numVal >= ladderList[i]["buyNum"]) {
  1367. resultLadder = i;
  1368. }
  1369. }
  1370. obj["price"] = ladderList[resultLadder]["buyPrice"];
  1371. obj["discountPrice"] = ladderList[resultLadder]["buyPrice"];
  1372. $("#check-item" + index).parents("tr").find("#price" + index).val(ladderList[resultLadder]["buyPrice"]);
  1373. $("#check-item" + index).parents("tr").find("#priceLabel" + index).text(ladderList[resultLadder]["buyPrice"]);
  1374. $("#check-item" + index).parents("tr").find("#discountPrice" + index).val(ladderList[resultLadder]["buyPrice"]);
  1375. }
  1376. }
  1377. function showView(index) {
  1378. var $num = $("#num" + index);
  1379. //重置数量
  1380. $num.val(1);
  1381. alertx("二手仪器购买数量只能为1");
  1382. }
  1383. // 商品折扣比例
  1384. function discountPriceVal(index) {
  1385. var discount = $("#discount" + index).val(); //折扣
  1386. discount = Number(discount);
  1387. var $checkItem = $("#check-item" + index);
  1388. var orderProductStr = $($checkItem).val();
  1389. var obj = JSON.parse(orderProductStr);
  1390. if (!isNaN(discount)) {
  1391. if (discount.length > 8 || discount.length < 0) {
  1392. $("#discount" + index).val(obj["discount"]);
  1393. alertx("折扣最大为5位小数");
  1394. } else if (discount > 100 || discount < 0) {
  1395. $("#discount" + index).val(obj["discount"]);
  1396. alertx("输入的折扣有误")
  1397. } else {
  1398. var svipPriceFlag = $("#svipPriceFlag" + index).val();
  1399. var price;
  1400. if (1 == svipPriceFlag) {
  1401. price = Number($("#svipDiscountPrice" + index).text());// 拿到超级会员价
  1402. } else {
  1403. price = Number($("#price" + index).val()); //拿到单价
  1404. }
  1405. //折后单价=折扣*当前价格/100
  1406. var discountPrice = ((discount * 100000 * price) / (100 * 100000)).toFixed(2);
  1407. $("#discountPrice" + index).val(discountPrice);
  1408. $("#discount" + index).val(discount);
  1409. var $checkItem = eval('(' + $("#check-item" + index).val() + ')');
  1410. $checkItem["discount"] = discount + ""; //重新设置折扣
  1411. $checkItem["discountPrice"] = discountPrice + ""; //重新设置折扣单价
  1412. $("#check-item" + index).val(JSON.stringify($checkItem));
  1413. //重新计算税费
  1414. taxRateVal(index)
  1415. }
  1416. } else {
  1417. alertx("商品折扣只能输入数字");
  1418. $("#discount" + index).val(obj.discount);
  1419. }
  1420. }
  1421. //输入折扣单价重新计算折扣
  1422. function countDiscount(index) {
  1423. var svipPriceFlag = $("#svipPriceFlag" + index).val(); //是否使用超级会员价
  1424. var price;
  1425. if (1 == svipPriceFlag) {
  1426. price = Number($("#svipDiscountPrice" + index).text());// 拿到超级会员价
  1427. } else {
  1428. price = Number($("#price" + index).val()); //拿到单价
  1429. }
  1430. var discountPrice = Number($("#discountPrice" + index).val()); //拿到折后单价
  1431. //判断必须小于等于商品单价
  1432. if (discountPrice > price) {
  1433. alertx("折后单价不能大于当前单价");
  1434. $("#discountPrice" + index).val(price); //清楚输入值设置为原始单价
  1435. $("#discount" + index).val(100);
  1436. return;
  1437. }
  1438. var discount = ((discountPrice / price).toFixed(7) * 100);
  1439. //设置折扣
  1440. $("#discount" + index).val(discount);
  1441. //重新计算税费和总价
  1442. var $checkItem = $("#check-item" + index);
  1443. var orderProductStr = $($checkItem).val();
  1444. var obj = JSON.parse(orderProductStr);
  1445. if (!isNaN(discount)) {
  1446. if (discount > 100 || discount < 0) {
  1447. $("#discount" + index).val(obj["discount"]);
  1448. alertx("输入的折扣有误")
  1449. } else {
  1450. var $checkItem = eval('(' + $("#check-item" + index).val() + ')');
  1451. $checkItem["discount"] = discount + ""; //重新设置折扣
  1452. $checkItem["discountPrice"] = discountPrice + ""; //重新设置折扣单价
  1453. $("#check-item" + index).val(JSON.stringify($checkItem));
  1454. //重新计算税费
  1455. taxRateVal(index)
  1456. }
  1457. }
  1458. }
  1459. //计算税费
  1460. function taxRateVal(index) {
  1461. var $checkItem = eval('(' + $("#check-item" + index).val() + ')');
  1462. var taxRateLabel = Number($("#taxRateLabel").val());
  1463. var taxRate = isNaN(taxRateLabel) ? Number($("#taxRate" + index).val()) : taxRateLabel; //税率
  1464. var supplierTaxRate = Number($checkItem["supplierTaxRate"]); //供应商税率
  1465. var numVal = $("#num" + index).val(); //商品数量
  1466. var presentNum = $("#presentNum" + index).val(); //商品赠品数量-计算税费需要包含赠品
  1467. if (presentNum == "" || presentNum == "undefined") {
  1468. presentNum = 0;
  1469. $("#presentNum" + index).val(0);
  1470. }
  1471. var totalNumVal = numVal * 1 + presentNum * 1; //统计赠品和购买商品数量
  1472. var discountPrice = $("#discountPrice" + index).val(); //折后单价
  1473. var $checkItem = eval('(' + $("#check-item" + index).val() + ')');
  1474. if ($checkItem["name"] == '' || $checkItem["name"] == null || $checkItem["name"] == 'null' || typeof ($checkItem[
  1475. "name"]) == "undefined") {
  1476. $checkItem["name"] = $checkItem.purchaseProductName + "";
  1477. }
  1478. var mode = $("#mode" + index).val(); //是否参与优惠活动
  1479. var touchPrice = $("#touchPrice" + index).val(); //优惠价/满减满赠设定价
  1480. var reducedPrice = $("#reducedPrice" + index).val(); //减免价格
  1481. var name = $("#promotionName" + index).val(); //促销活动名称
  1482. var promotionsId = $("#promotionsId" + index).val(); //促销活动id
  1483. var discount = $("#discount" + index).val(); //百分比折扣
  1484. var productId = $checkItem["productId"]; //商品id 11
  1485. var includedTax = $checkItem["includedTax"] == undefined ? 2 : $checkItem["includedTax"]; //是否含税 11
  1486. var invoiceType = $checkItem["invoiceType"] == undefined ? 3 : $checkItem["invoiceType"]; //发票类型 11
  1487. var ctx = $("#ctx" + index).val(); //ctx
  1488. var costCheckFlag = $checkItem["costCheckFlag"] == undefined ? 1 : $checkItem[
  1489. "costCheckFlag"]; //成本价选中标志:1固定成本 2比例成 11
  1490. var costPrice = $checkItem["costPrice"] == undefined ? 0.0 : $checkItem["costPrice"]; //成本价 11
  1491. var costProportional = $checkItem["costProportional"] == undefined ? 90 : $checkItem[
  1492. "costProportional"]; //比例成本百分比90% 11
  1493. var oldProductFlag = $checkItem["oldProductFlag"] == undefined ? 0 : $checkItem["oldProductFlag"]; //旧商品标志,0否1是
  1494. var obj1 = document.getElementById("priceLabel" + index); //选择商品页面商品单价
  1495. var obj2 = document.getElementById("price"); //设置商品页面商品单价
  1496. var price = obj1 != null ? obj1 : obj2 != null ? obj2 : null;
  1497. var svipDiscountPriceObj = document.getElementById("svipDiscountPrice" + index);
  1498. var svipReduction = $("#svipReduction" + index).val() == undefined ? 0 : $("#svipReduction" + index).val();
  1499. var svipPriceFlag = $("#svipPriceFlag" + index).val() == undefined ? 0 : $("#svipPriceFlag" + index).val();
  1500. var svipTaxReduction = $("#svipTaxReduction" + index).val() == undefined ? 0 : $("#svipTaxReduction" + index).val();
  1501. if (includedTax != '' && includedTax == 0 && invoiceType == 3) {
  1502. //不含税不能开票商品,税率置为0
  1503. taxRate = 0;
  1504. }
  1505. //税率校验
  1506. if (isNaN(taxRate) || taxRate < 0 || taxRate > 100) {
  1507. alertx("机构税率只能为[0,100]之间的数");
  1508. return;
  1509. }
  1510. if (isNaN(supplierTaxRate) || supplierTaxRate < 0 || supplierTaxRate > 100) {
  1511. alertx("供应商税率只能为[0,100]之间的数");
  1512. return;
  1513. }
  1514. // 含税商品以及不含税不能发票商品,不需要计算税费
  1515. if (includedTax == '1' || (includedTax == '0' && invoiceType == '3')) {
  1516. //计算总价(税费为0)=折后单价*数量
  1517. if (discount == 100 && mode == 1) {
  1518. var totalFee = parseFloat(((touchPrice * 100000 * numVal) / 100000).toFixed(2));
  1519. if (price != null) {
  1520. price.style.cssText = "text-decoration: line-through";
  1521. }
  1522. document.getElementById("discountPrice" + index).style.cssText =
  1523. "width: 80px;text-decoration: line-through";
  1524. } else {
  1525. var totalFee = parseFloat(((discountPrice * 100000 * numVal) / 100000).toFixed(2));
  1526. if (price != null) {
  1527. price.style.cssText = "";
  1528. }
  1529. document.getElementById("discountPrice" + index).style.cssText = "width: 80px;";
  1530. }
  1531. if (discount != 100) {
  1532. if (promotionsId != 0) {
  1533. $("#promotion" + index).html("<label style=\"color:red;float: left\">有折扣,不享受促销优惠</label>");
  1534. } else {
  1535. $("#promotion" + index).html("");
  1536. }
  1537. $("#presentNum" + index).attr("readonly", null);
  1538. } else {
  1539. if (mode == 1) {
  1540. $("#promotion" + index).html(
  1541. "<label style=\"float: left;cursor: default\"><a href=\"javascript:void(0);\" onclick=\"showPromotionDetail('iframe:" +
  1542. ctx + "/bulkpurchase/purchaseProduct/promotionDetail?promotionId=" + promotionsId + "','" +
  1543. name + "')\"><label style=\"background: green;color: white;\">" + name + "</label>\n" +
  1544. "<label>优惠价:" + touchPrice + "</label></a></label>")
  1545. } else if (mode == 2) {
  1546. $("#promotion" + index).html(
  1547. "<label style=\"float: left\"><a href=\"javascript:void(0);\" onclick=\"showPromotionDetail('iframe:" +
  1548. ctx + "/bulkpurchase/purchaseProduct/promotionDetail?promotionId=" + promotionsId + "','" +
  1549. name + "')\"><label style=\"background: #F60;color: white;\" >" + name + "</label>\n" +
  1550. "<label>满" + touchPrice + ",减" + reducedPrice + "</label></a></label>");
  1551. } else if (mode == 3) {
  1552. $("#promotion" + index).html(
  1553. "<label style=\"float: left\"><a href=\"javascript:void(0);\" onclick=\"showPromotionDetail('iframe:" +
  1554. ctx + "/bulkpurchase/purchaseProduct/promotionDetail?promotionId=" + promotionsId + "','" +
  1555. name + "')\"><label style=\"background: purple;color: white;\" >" + name + "</label>\n" +
  1556. "<label>满" + touchPrice + ",赠送商品</label></a></label>");
  1557. }
  1558. if (promotionsId != null && promotionsId != '' && promotionsId != 0) {
  1559. $("#presentNum" + index).val(0);
  1560. $("#presentNum" + index).attr("readonly", "readonly");
  1561. } else {
  1562. if (productId >= 6060 && productId <= 6069) {
  1563. $("#presentNum" + index).attr("readonly", "readonly");
  1564. } else {
  1565. $("#presentNum" + index).attr("readonly", null);
  1566. }
  1567. }
  1568. }
  1569. $("#totalFee" + index).val(totalFee);
  1570. $("#supplierTaxRate" + index).val(supplierTaxRate);
  1571. $checkItem["taxRate"] = taxRate + ""; //重新设置税率
  1572. $checkItem["supplierTaxRate"] = supplierTaxRate + ""; //重新设置供应商税率
  1573. $checkItem["num"] = numVal + ""; //重新设置数量
  1574. $checkItem["addedValueTax"] = 0; //重新设置单个机构税费
  1575. $checkItem["totalAddedValueTax"] = 0; //重新设置机构总税费
  1576. $checkItem["singleShouldPayTotalTax"] = 0; //重新设置单个供应商税费
  1577. $checkItem["shouldPayTotalTax"] = 0; //重新设置供应商总税费
  1578. $checkItem["totalFee"] = totalFee + ""; //重新设置总价
  1579. $checkItem["payTotalFee"] = totalFee + ""; //重新设置应付
  1580. $checkItem["costPrice"] = costPrice + ""; //重新设置成本
  1581. $checkItem["svipReduction"] = svipReduction + ""; //重新设置超级会员优惠
  1582. $("#svipReduction0").val(svipReduction);
  1583. $checkItem["svipTaxReduction"] = svipTaxReduction + ""; //重新设置超级会员税费优惠
  1584. $("#svipTaxReduction").val(svipTaxReduction);
  1585. // console.log("data" + index + ":" + JSON.stringify($checkItem));
  1586. $("#check-item" + index).val(JSON.stringify($checkItem));
  1587. } else {
  1588. //不含税可开发票商品,需要计算税费
  1589. if (taxRate == 0) {
  1590. //机构税率为0,机构税费则为0
  1591. $("#taxRate" + index).val(0);
  1592. $("#addedValueTax" + index).val(0); //设置单个税费
  1593. $("#totalAddedValueTax" + index).val(0); //设置总税费
  1594. //计算总价(税费为0)=折后单价*数量
  1595. if (discount == 100 && mode == 1) {
  1596. //参与单品优惠价
  1597. //计算总价
  1598. var totalFee = parseFloat(((touchPrice * 100000 * numVal) / 100000).toFixed(2));
  1599. //计算成本价
  1600. if (costCheckFlag == 2 && costProportional != null) {
  1601. costPrice = parseFloat((((touchPrice * costProportional) / 100).toFixed(2)));
  1602. }
  1603. if (price != null) {
  1604. price.style.cssText = "text-decoration: line-through";
  1605. }
  1606. document.getElementById("discountPrice" + index).style.cssText =
  1607. "width: 80px;text-decoration: line-through";
  1608. } else {
  1609. var totalFee = parseFloat(((discountPrice * 100000 * numVal) / 100000).toFixed(2));
  1610. //计算成本价
  1611. if (costCheckFlag == 2 && costProportional != null) {
  1612. costPrice = parseFloat((((discountPrice * costProportional) / 100).toFixed(2)));
  1613. }
  1614. if (price != null) {
  1615. price.style.cssText = "";
  1616. }
  1617. document.getElementById("discountPrice" + index).style.cssText = "width: 80px;";
  1618. }
  1619. if (discount != 100) {
  1620. if (promotionsId != 0) {
  1621. $("#promotion" + index).html("<label style=\"color:red;float: left\">有折扣,不享受促销优惠</label>");
  1622. } else {
  1623. $("#promotion" + index).html("");
  1624. }
  1625. $("#presentNum" + index).attr("readonly", null);
  1626. } else {
  1627. if (mode == 1) {
  1628. $("#promotion" + index).html(
  1629. "<label style=\"float: left;cursor: default\"><a href=\"javascript:void(0);\" onclick=\"showPromotionDetail('iframe:" +
  1630. ctx + "/bulkpurchase/purchaseProduct/promotionDetail?promotionId=" + promotionsId + "','" +
  1631. name + "')\"><label style=\"background: green;color: white;\">" + name + "</label>\n" +
  1632. "<label>优惠价:" + touchPrice + "</label></a></label>")
  1633. } else if (mode == 2) {
  1634. $("#promotion" + index).html(
  1635. "<label style=\"float: left\"><a href=\"javascript:void(0);\" onclick=\"showPromotionDetail('iframe:" +
  1636. ctx + "/bulkpurchase/purchaseProduct/promotionDetail?promotionId=" + promotionsId + "','" +
  1637. name + "')\"><label style=\"background: #F60;color: white;\" >" + name + "</label>\n" +
  1638. "<label>满" + touchPrice + ",减" + reducedPrice + "</label></a></label>");
  1639. } else if (mode == 3) {
  1640. $("#promotion" + index).html(
  1641. "<label style=\"float: left\"><a href=\"javascript:void(0);\" onclick=\"showPromotionDetail('iframe:" +
  1642. ctx + "/bulkpurchase/purchaseProduct/promotionDetail?promotionId=" + promotionsId + "','" +
  1643. name + "')\"><label style=\"background: purple;color: white;\" >" + name + "</label>\n" +
  1644. "<label>满" + touchPrice + ",赠送商品</label></a></label>");
  1645. }
  1646. if (promotionsId != null && promotionsId != '' && promotionsId != 0) {
  1647. $("#presentNum" + index).val(0);
  1648. $("#presentNum" + index).attr("readonly", "readonly");
  1649. } else {
  1650. if (productId >= 6060 && productId <= 6069) {
  1651. $("#presentNum" + index).attr("readonly", "readonly");
  1652. } else {
  1653. $("#presentNum" + index).attr("readonly", null);
  1654. }
  1655. }
  1656. }
  1657. var singleShouldPayTotalTax = 0;
  1658. var shouldPayTotalTax = 0;
  1659. if (supplierTaxRate > 0) {
  1660. //供应商税费(单) = 成本价 * 供应商税率 * 0.01
  1661. singleShouldPayTotalTax = (costPrice * supplierTaxRate * 0.01).toFixed(2);
  1662. //供应商税费(总) = 供应商税费(单)*数量
  1663. shouldPayTotalTax = (singleShouldPayTotalTax * numVal).toFixed(2);
  1664. }
  1665. $("#totalFee" + index).val(totalFee);
  1666. $("#supplierTaxRate" + index).val(supplierTaxRate);
  1667. $checkItem["taxRate"] = 0; //重新设置税率
  1668. $checkItem["supplierTaxRate"] = supplierTaxRate + ""; //重新设置供应商税率
  1669. $checkItem["num"] = numVal + ""; //重新设置数量
  1670. $checkItem["addedValueTax"] = 0; //重新设置单个税费
  1671. $checkItem["totalAddedValueTax"] = 0; //重新设置机构总税费
  1672. $checkItem["singleShouldPayTotalTax"] = singleShouldPayTotalTax + "" //重新设置供应商单个税费
  1673. $checkItem["shouldPayTotalTax"] = shouldPayTotalTax + ""; //重新设置供应商总税费
  1674. $checkItem["totalFee"] = totalFee + ""; //重新设置总价
  1675. $checkItem["payTotalFee"] = totalFee + ""; //重新设置应付
  1676. $checkItem["costPrice"] = costPrice + ""; //重新设置成本
  1677. $("#taxRateLabel").val(taxRate);
  1678. $("#addedValueTaxLabel").val(0)
  1679. $("#totalAddedValueTaxLabel").val(0)
  1680. if (svipPriceFlag == 1) {
  1681. // 折扣价重新计算超级会员优惠
  1682. var svipDiscountPrice = $("#svipDiscountPrice" + index).text();
  1683. var originalPrice = $("#price" + index).val();
  1684. svipReduction = originalPrice - svipDiscountPrice;
  1685. }
  1686. $checkItem["svipReduction"] = svipReduction + ""; //重新设置超级会员优惠
  1687. $("#svipReduction0").val(svipReduction);
  1688. $checkItem["svipTaxReduction"] = svipTaxReduction + ""; //重新设置超级会员税费优惠
  1689. $("#svipTaxReduction").val(svipTaxReduction);
  1690. // console.log("data" + index + ":" + JSON.stringify($checkItem));
  1691. $("#check-item" + index).val(JSON.stringify($checkItem));
  1692. } else if (taxRate > 100) {
  1693. alertx("税率不能大于100%");
  1694. $("#taxRate" + index).val($checkItem['taxRate']);
  1695. return;
  1696. } else {
  1697. // var r = /^\+?[1-9][0-9]*$/;
  1698. if ((typeof taxRate === 'number') && (taxRate <= 100)) {
  1699. //折扣为100且参与单品优惠活动时,根据优惠价计算数据
  1700. if (discount == 100 && mode == 1) {
  1701. $("#taxRate" + index).val(taxRate);
  1702. // if (r.test(taxRate) && taxRate <= 100) {
  1703. //单个税费=优惠价*税率【税率 (4舍5入保留2位小数)】
  1704. var addedValueTax = (touchPrice * taxRate * 0.01).toFixed(2);
  1705. //商品总额=折后单价*数量【[折后单价(真实值) x 数量](4舍5入保留2位小数)】
  1706. var totalTax = (touchPrice * numVal).toFixed(2);
  1707. //税费=商品总额*税率【税率:(4舍5入保留2位小数)】
  1708. var totalAddedValueTax = (totalTax * taxRate * 0.01).toFixed(2);
  1709. //计算成本价
  1710. if (costCheckFlag == 2 && costProportional != null) {
  1711. costPrice = (((parseFloat(touchPrice) + parseFloat(addedValueTax)) * costProportional) / 100)
  1712. .toFixed(2);
  1713. }
  1714. //计算总价(存在折扣)【总价=[折后单价 x 数量](4舍5入保留2位小数) + 税费 】
  1715. var totalFee = ((parseFloat((touchPrice * numVal).toFixed(2)) * 100 + parseFloat(
  1716. totalAddedValueTax) * 100) / 100).toFixed(2);
  1717. if (price != null) {
  1718. price.style.cssText = "text-decoration: line-through";
  1719. }
  1720. document.getElementById("discountPrice" + index).style.cssText =
  1721. "width: 80px;text-decoration: line-through";
  1722. } else {
  1723. $("#taxRate" + index).val(taxRate);
  1724. // if (r.test(taxRate) && taxRate <= 100) {
  1725. //单个税费=折后单价*税率【税率 (4舍5入保留2位小数)】
  1726. var addedValueTax = (discountPrice * taxRate * 0.01).toFixed(2);
  1727. //商品总额=折后单价*数量【[折后单价(真实值) x 数量](4舍5入保留2位小数)】
  1728. var totalTax = (discountPrice * numVal).toFixed(2);
  1729. //机构税费=商品总额*税率【税率:(4舍5入保留2位小数)】
  1730. var totalAddedValueTax = (totalTax * taxRate * 0.01).toFixed(2);
  1731. //计算成本价
  1732. if (costCheckFlag == 2 && costProportional != null) {
  1733. costPrice = ((((parseFloat(discountPrice) + parseFloat(addedValueTax))) * costProportional) /
  1734. 100).toFixed(2);
  1735. }
  1736. //计算总价(存在折扣)【总价=[折后单价 x 数量](4舍5入保留2位小数) + 税费 】
  1737. var totalFee = ((parseFloat((discountPrice * numVal).toFixed(2)) * 100 + parseFloat(
  1738. totalAddedValueTax) * 100) / 100).toFixed(2);
  1739. $("#totalFee" + index).val(totalFee);
  1740. if (price != null) {
  1741. price.style.cssText = "";
  1742. }
  1743. document.getElementById("discountPrice" + index).style.cssText = "width: 80px;";
  1744. }
  1745. if (discount != 100) {
  1746. $("#promotion" + index).html("<label style=\"color:red;float: left\">有折扣,不享受促销优惠</label>")
  1747. $("#presentNum" + index).attr("readonly", null);
  1748. } else {
  1749. if (mode == 1) {
  1750. $("#promotion" + index).html(
  1751. "<label style=\"float: left;cursor: default\"><a href=\"javascript:void(0);\" onclick=\"showPromotionDetail('iframe:" +
  1752. ctx + "/bulkpurchase/purchaseProduct/promotionDetail?promotionId=" + promotionsId +
  1753. "','" + name + "')\"><label style=\"background: green;color: white;\">" + name +
  1754. "</label>\n" +
  1755. "<label>优惠价:" + touchPrice + "</label></a></label>")
  1756. } else if (mode == 2) {
  1757. $("#promotion" + index).html(
  1758. "<label style=\"float: left\"><a href=\"javascript:void(0);\" onclick=\"showPromotionDetail('iframe:" +
  1759. ctx + "/bulkpurchase/purchaseProduct/promotionDetail?promotionId=" + promotionsId +
  1760. "','" + name + "')\"><label style=\"background: #F60;color: white;\" >" + name +
  1761. "</label>\n" +
  1762. "<label>满" + touchPrice + ",减" + reducedPrice + "</label></a></label>");
  1763. } else if (mode == 3) {
  1764. $("#promotion" + index).html(
  1765. "<label style=\"float: left\"><a href=\"javascript:void(0);\" onclick=\"showPromotionDetail('iframe:" +
  1766. ctx + "/bulkpurchase/purchaseProduct/promotionDetail?promotionId=" + promotionsId +
  1767. "','" + name + "')\"><label style=\"background: purple;color: white;\" >" + name +
  1768. "</label>\n" +
  1769. "<label>满" + touchPrice + ",赠送商品</label></a></label>");
  1770. }
  1771. if (promotionsId != null && promotionsId != '' && promotionsId != 0) {
  1772. $("#presentNum" + index).val(0);
  1773. $("#presentNum" + index).attr("readonly", "readonly");
  1774. } else {
  1775. $("#presentNum" + index).attr("readonly", null);
  1776. }
  1777. }
  1778. var singleShouldPayTotalTax = 0;
  1779. var shouldPayTotalTax = 0;
  1780. //(未知商品/不含税可开发票的旧商品)将机构税率赋值给供应商税率
  1781. if (includedTax == '2' || includedTax == '' || (includedTax == '0' && (invoiceType == '1' ||
  1782. invoiceType == '2') && oldProductFlag == '1')) {
  1783. supplierTaxRate = taxRate;
  1784. }
  1785. if (supplierTaxRate > 0) {
  1786. //供应商税费(单) = 成本价 * 供应商税率 * 0.01
  1787. singleShouldPayTotalTax = (costPrice * supplierTaxRate * 0.01).toFixed(3);
  1788. //供应商税费(总) = 供应商税费(单)*数量
  1789. shouldPayTotalTax = (singleShouldPayTotalTax * numVal).toFixed(2);
  1790. }
  1791. if (svipPriceFlag == 1) {
  1792. // 折扣价重新计算超级会员优惠
  1793. var svipDiscountPrice = $("#svipDiscountPrice" + index).text();
  1794. var originalPrice = $("#price" + index).val();
  1795. svipReduction = ((originalPrice - svipDiscountPrice) + (originalPrice - svipDiscountPrice) * taxRate / 100).toFixed(2);
  1796. svipTaxReduction = ((originalPrice - svipDiscountPrice) * taxRate / 100).toFixed(2);
  1797. }
  1798. $checkItem["svipReduction"] = svipReduction + ""; //重新设置超级会员优惠
  1799. $("#svipReduction0").val(svipReduction);
  1800. $checkItem["svipTaxReduction"] = svipTaxReduction + ""; //重新设置超级会员税费优惠
  1801. $("#svipTaxReduction").val(svipTaxReduction);
  1802. $("#addedValueTax" + index).val(addedValueTax);
  1803. $("#totalAddedValueTax" + index).val(totalAddedValueTax);
  1804. $("#totalFee" + index).val(totalFee);
  1805. $("#supplierTaxRate" + index).val(supplierTaxRate);
  1806. $checkItem["num"] = numVal + ""; //重新设置数量
  1807. $checkItem["taxRate"] = taxRate + ""; //重新设置税率
  1808. $checkItem["supplierTaxRate"] = supplierTaxRate + ""; //重新设置供应商税率
  1809. $checkItem["addedValueTax"] = addedValueTax + ""; //重新设置单个税费
  1810. $checkItem["totalAddedValueTax"] = totalAddedValueTax + ""; //重新设置总税费
  1811. $checkItem["singleShouldPayTotalTax"] = singleShouldPayTotalTax + "" //重新设置供应商单个税费
  1812. $checkItem["shouldPayTotalTax"] = shouldPayTotalTax + ""; //重新设置供应商总税费
  1813. $checkItem["totalFee"] = totalFee + ""; //重新设置总价
  1814. $checkItem["payTotalFee"] = totalFee + ""; //重新设置应付
  1815. $checkItem["costPrice"] = costPrice + ""; //重新设置成本
  1816. $("#taxRateLabel").val(taxRate);
  1817. $("#addedValueTaxLabel").val(addedValueTax)
  1818. $("#totalAddedValueTaxLabel").val(totalAddedValueTax)
  1819. // console.log("data" + index + ":" + JSON.stringify($checkItem));
  1820. $("#check-item" + index).val(JSON.stringify($checkItem));
  1821. } else {
  1822. alertx("税率只能为[0,100]之间的数");
  1823. $("#taxRate" + index).val($checkItem['taxRate']);
  1824. return;
  1825. }
  1826. }
  1827. }
  1828. if (svipPriceFlag == 1) {
  1829. if (price != null) {
  1830. price.style.cssText = "text-decoration: line-through";
  1831. svipDiscountPriceObj.style.cssText = "display:''";
  1832. }
  1833. }
  1834. singeGiveNum(index);
  1835. shopFee(index); //优化功能开启刷新应付供应商
  1836. otherFee(index);
  1837. }
  1838. // 添加赠品数
  1839. function giveNum(i) {
  1840. var $giveNum = $("#presentNum" + i).val();
  1841. if ($giveNum == "" || $giveNum == "undefined") {
  1842. $giveNum = 0;
  1843. $("#presentNum" + i).val(0);
  1844. }
  1845. var giveNum = Number($giveNum);
  1846. var $checkItem = eval('(' + $("#check-item" + i).val() + ')');
  1847. if (!isNaN(giveNum)) {
  1848. if ((typeof giveNum === 'number') && (giveNum % 1 === 0)) {
  1849. $checkItem["presentNum"] = giveNum + ""; //重新设置赠品数
  1850. $("#presentNum" + i).val(giveNum);
  1851. $("#check-item" + i).val(JSON.stringify($checkItem));
  1852. if (0 != giveNum) {
  1853. cmFee(i);
  1854. }
  1855. //重新税费(因为赠品也需要计算税费)
  1856. taxRateVal(i);
  1857. } else {
  1858. alertx("赠品数只能输入整数");
  1859. $("#presentNum" + i).val($checkItem.presentNum);
  1860. }
  1861. } else {
  1862. alertx("赠品数只能输入数字");
  1863. $("#presentNum" + i).val($checkItem.presentNum);
  1864. }
  1865. }
  1866. // 单纯获取赠品数(不计算税费)
  1867. function singeGiveNum(i) {
  1868. var $giveNum = $("#presentNum" + i).val();
  1869. if ($giveNum == null || $giveNum == "" || $giveNum == "undefined") {
  1870. $giveNum = 0;
  1871. $("#presentNum" + i).val(0);
  1872. }
  1873. var giveNum = Number($giveNum);
  1874. var $checkItem = eval('(' + $("#check-item" + i).val() + ')');
  1875. if (giveNum != 'undefined' && !isNaN(giveNum)) {
  1876. if ((typeof giveNum === 'number') && (giveNum % 1 === 0)) {
  1877. $checkItem["presentNum"] = giveNum + ""; //重新设置赠品数
  1878. $("#presentNum" + i).val(giveNum);
  1879. $("#check-item" + i).val(JSON.stringify($checkItem));
  1880. if (0 != giveNum) {
  1881. cmFee(i);
  1882. }
  1883. } else {
  1884. alertx("赠品数只能输入整数");
  1885. $("#presentNum" + i).val($checkItem.presentNum);
  1886. }
  1887. } else {
  1888. alertx("赠品数只能输入数字");
  1889. $("#presentNum" + i).val($checkItem.presentNum);
  1890. }
  1891. }
  1892. /**
  1893. * @param obj
  1894. * jquery控制input只能输入数字和两位小数
  1895. */
  1896. function num(obj) {
  1897. obj.value = obj.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
  1898. obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字
  1899. obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个, 清除多余的
  1900. obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  1901. obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
  1902. }
  1903. // 添加供应应付商金额
  1904. function shopFee(i) {
  1905. var $shopFee = $("#shopFee1" + i).val();
  1906. var shopFee = Number($shopFee);
  1907. var $checkItem = eval('(' + $("#check-item" + i).val() + ')');
  1908. if (!isNaN(shopFee)) {
  1909. $checkItem["shopFee1"] = shopFee + "";
  1910. $("#shopFee1" + i).val(shopFee);
  1911. $("#check-item" + i).val(JSON.stringify($checkItem));
  1912. cmFee(i);
  1913. } else {
  1914. alertx("应付供应商只能输入数字");
  1915. $("#shopFee1" + i).val($checkItem.shopFee1);
  1916. }
  1917. }
  1918. // 添加复购属性
  1919. function buyAgain(i) {
  1920. var options = $("#buyAgainFlag" + i + " option:selected");
  1921. var buyAgainFlag = options.val();
  1922. if (null != buyAgainFlag && undefined != buyAgainFlag) {
  1923. var $checkItem = eval('(' + $("#check-item" + i).val() + ')');
  1924. $checkItem["buyAgainFlag"] = buyAgainFlag + "";
  1925. $("#buyAgainFlag" + i).val(buyAgainFlag);
  1926. $("#check-item" + i).val(JSON.stringify($checkItem));
  1927. } else {
  1928. var $checkItem = eval('(' + $("#check-item" + i).val() + ')');
  1929. $checkItem["buyAgainFlag"] = "1";
  1930. $("#buyAgainFlag" + i).val(buyAgainFlag);
  1931. $("#check-item" + i).val(JSON.stringify($checkItem));
  1932. }
  1933. }
  1934. // 添加第三方应付商金额
  1935. function otherFee(i) {
  1936. var $otherFee = $("#otherFee1" + i).val();
  1937. var otherFee = Number($otherFee);
  1938. var $checkItem = eval('(' + $("#check-item" + i).val() + ')');
  1939. if (!isNaN(otherFee)) {
  1940. $checkItem["otherFee1"] = otherFee + "";
  1941. $("#otherFee1" + i).val(otherFee);
  1942. $("#check-item" + i).val(JSON.stringify($checkItem));
  1943. cmFee(i);
  1944. } else {
  1945. alertx("应付第三方只能输入数字");
  1946. $("#otherFee1" + i).val($checkItem.otherFee1);
  1947. }
  1948. }
  1949. // 添加采美应付金额
  1950. function cmFee(i) {
  1951. var discountPrice = $("#discountPrice" + i).val(); //折后单价
  1952. var shopFee1 = $("#shopFee1" + i).val(); //应付供应商
  1953. var otherFee1 = $("#otherFee1" + i).val() //应付第三方
  1954. if ((shopFee1 != "" && shopFee1 != null) && (otherFee1 != "" && otherFee1 != null)) {
  1955. var shopFee = Number(shopFee1);
  1956. var otherFee = Number(otherFee1);
  1957. var $checkItem = eval('(' + $("#check-item" + i).val() + ')');
  1958. var num = parseInt($checkItem.num);
  1959. var presentNum = parseInt($checkItem.presentNum);
  1960. var cmFee = ((discountPrice * 100000 - shopFee * 100000 - otherFee * 100000) / 100000).toFixed(6);
  1961. $("#cmFee1" + i).val(cmFee);
  1962. $checkItem["cmFee1"] = cmFee + "";
  1963. //设置总的应付
  1964. var _shopFee = (shopFee * (num + presentNum)).toFixed(6); //供应商
  1965. var _otherFee = (otherFee * num).toFixed(6); //供应商
  1966. var _cmFee = ((discountPrice * num * 100000 - _shopFee * 100000 - _otherFee * 100000) / 100000).toFixed(6);
  1967. $checkItem["shopFee"] = _shopFee + "";
  1968. $checkItem["otherFee"] = _otherFee + "";
  1969. $checkItem["cmFee"] = _cmFee + "";
  1970. $("#check-item" + i).val(JSON.stringify($checkItem));
  1971. }
  1972. }
  1973. //经理折扣后计算
  1974. function setProductTotalFee() {
  1975. var discount = Number($("#discount").val()); //经理折扣金额
  1976. if (isNaN(discount)) {
  1977. discount = Number($("#discountFee").val());
  1978. }
  1979. if ($('.productTable').length == 0) {
  1980. // 非添加订单页面
  1981. $("#discount").val('0.00');
  1982. $(".payableAmount").text(0);
  1983. return;
  1984. }
  1985. var trs = $('.productTable tbody').find('tr:not(.gift)');
  1986. if (trs.length == 0) { //没有添加商品的情况
  1987. $("#discount").val('0.00');
  1988. $(".payableAmount").text(0);
  1989. alertx("请先添加商品");
  1990. return;
  1991. }
  1992. //经理折扣 -> 改变订单总额 -> 改变分期免息金额
  1993. var productTotalFee = Number($(".productTotalFee").html()), //商品总金额
  1994. productCount = Number($(".productCount").html()), // 订单商品总数
  1995. presentCount = Number($("#presentCount").val()), //赠送商品数
  1996. giftCount = Number($("#promotionalGiftsCount").val()), //促销赠品
  1997. orderTotalFee = Number($(".orderTotalFee").html()), //订单总额
  1998. reducedPrice = 0, //促销满减
  1999. payTotalFee = ((orderTotalFee * 100 - discount * 100) / 100).toFixed(2); //应付总额=订单总额-折扣金额-减抵扣余额(待开发)
  2000. if (payTotalFee < 0) {
  2001. $("#discount").attr('value', '0');
  2002. $("#discountFee").attr('value', '0');
  2003. alertx("订单金额不能小于0");
  2004. setProductTotalFee();
  2005. return;
  2006. }
  2007. //计算运费
  2008. var freePostFlag = $("#freePostFlag").val();
  2009. var freight = 0;
  2010. if (freePostFlag == "1") {
  2011. freight = Number($("#freight").val());
  2012. }
  2013. payTotalFee = (Number(payTotalFee) + freight).toFixed(2);
  2014. // 计算促销折扣
  2015. totalPromotions.forEach(function (item) {
  2016. if (item.mode == 2) {
  2017. var touchPrice = 0;
  2018. item.promotionProducts.forEach(function (product) {
  2019. touchPrice += (product.number * product.price + product.totalTax * 1);
  2020. });
  2021. if (touchPrice >= item.touchPrice) {
  2022. if (item.discount * 1 === 1) {
  2023. var b = Math.floor(touchPrice / item.touchPrice);
  2024. reducedPrice += (b * item.reducedPrice);
  2025. payTotalFee -= reducedPrice;
  2026. } else {
  2027. reducedPrice += item.reducedPrice;
  2028. payTotalFee -= item.reducedPrice;
  2029. }
  2030. }
  2031. }
  2032. });
  2033. //计算余额抵扣
  2034. //计算应付金额
  2035. var payableAmount = payTotalFee; //应付订单金额
  2036. var balancePayFee = Number($("#balancePayFee").val()); //当前使用金额
  2037. var surplusBalance = 0.00; //剩余金额
  2038. var availableBalanceStatus = $("#useBalancePayFee").is(':checked'); //账户余额
  2039. var availableBalance = Number($("#availableBalance").html());
  2040. if (availableBalanceStatus == true) {
  2041. if ((availableBalance + balancePayFee - payTotalFee).toFixed(2) > 0) { //余额大于订单总额 全额抵扣
  2042. surplusBalance = (Number(availableBalance) + balancePayFee - Number(payTotalFee)).toFixed(2);
  2043. balancePayFee = payTotalFee;
  2044. payableAmount = 0.00;
  2045. availableBalance = surplusBalance;
  2046. } else {
  2047. payableAmount = (Number(payTotalFee) - Number(availableBalance) - balancePayFee).toFixed(2);
  2048. balancePayFee = (Number(availableBalance) + balancePayFee).toFixed(2);
  2049. surplusBalance = 0.00;
  2050. availableBalance = surplusBalance;
  2051. }
  2052. } else {
  2053. availableBalance = availableBalance + balancePayFee;
  2054. surplusBalance = availableBalance;
  2055. balancePayFee = 0.00;
  2056. }
  2057. trs.each(function (index, element) {
  2058. var obj = JSON.parse($(this).attr("data-value"));
  2059. var _taxRate = Number(obj.taxRate); //税率
  2060. var _totalFee = Number(obj.totalFee); //总价
  2061. var _shopFee1 = isNaN(Number(obj.shopFee1)) ? Number(obj.singleShopFee) : Number(obj.shopFee1);
  2062. var _shopFee = (_shopFee1 * (Number(obj.num) + Number(obj.presentNum))).toFixed(6); //供应商
  2063. var _otherFee1 = isNaN(Number(obj.otherFee1)) ? Number(obj.singleOtherFee) : Number(obj.otherFee1);
  2064. var _otherFee = (_otherFee1 * Number(obj.num)).toFixed(6); //第三方
  2065. //采美
  2066. var _cmFee = ((Number(obj.discountPrice) * Number(obj.num) * 100000 - _shopFee * 100000 - _otherFee *
  2067. 100000) / 100000).toFixed(6);
  2068. //订单的单个商品 应付金额= 单个总价 。(四舍五入后,保留两位小数,--此处不平摊经理折扣)
  2069. var _payTotalFee = (Number(obj.totalFee)).toFixed(2);
  2070. //【旧】订单的单个商品 税费=订单的单个商品应付金额-[订单的单个商品应付金额/(1+税率)](最后保留2位小数+四舍五入)
  2071. //var _totalAddedValueTax=((_payTotalFee*100000-((_payTotalFee/((1+_taxRate/100).toFixed(6))).toFixed(6))*100000)/100000).toFixed(2);
  2072. var _totalAddedValueTax = obj.totalAddedValueTax;
  2073. //差额(单个商品的经理折扣)=总价-应付金额 如果没有特别要求默认保留6位小数(此处结果为0)
  2074. var _difAmount = ((_totalFee * 100000 - _payTotalFee * 100000) / 100000).toFixed(6);
  2075. //总盈利(经理折扣后)=第三方+采美-差额
  2076. var _totalProfit = ((_otherFee * 100000 + _cmFee * 100000 - _difAmount * 100000) / 100000).toFixed(6);
  2077. //盈利比=总盈利÷(第三方+采美)
  2078. var _profitability = 0;
  2079. if (_otherFee != 0 && _cmFee != 0) {
  2080. _profitability = (_totalProfit / ((_otherFee * 100000 + _cmFee * 100000) / 100000).toFixed(6))
  2081. .toFixed(6);
  2082. }
  2083. //订单的每种商品 应付第三方(经理折扣后)=盈利比x第三方(经理折扣前)
  2084. _otherFee = (_profitability * _otherFee).toFixed(6);
  2085. //订单的单个商品 应付采美=应付金额-应付供应商-应付第三方-税费
  2086. _cmFee = ((_payTotalFee * 100000 - _shopFee * 100000 - _otherFee * 100000 - _totalAddedValueTax *
  2087. 100000) / 100000).toFixed(6);
  2088. obj["shopFee"] = _shopFee + "";
  2089. obj["otherFee"] = _otherFee + "";
  2090. obj["cmFee"] = _cmFee + "";
  2091. obj["shouldPayFee"] = _payTotalFee + "";
  2092. obj["presentNum"] = obj.presentNum + "";
  2093. if (obj["name"] == '' || obj["name"] == null || obj["name"] == 'null' || typeof (obj["name"]) ==
  2094. "undefined") {
  2095. obj["name"] = obj.purchaseProductName + "";
  2096. }
  2097. $(this).attr("data-value", JSON.stringify(obj));
  2098. var index = $(this).attr("data-index");
  2099. $('#orderProduct' + index + '\\.enabledStatus').val(JSON.stringify(obj));
  2100. });
  2101. if (initFlag) {
  2102. $(".productTotalFee").html(productTotalFee);
  2103. $(".productCount").html(productCount);
  2104. $(".presentCount").text(presentCount + giftCount);
  2105. $(".orderTotalFee").html(orderTotalFee);
  2106. $(".payTotalFee").html((payTotalFee * 1).toFixed(2));
  2107. $(".promotionFullReduction").text(reducedPrice);
  2108. $(".payableAmount").html((payableAmount * 1).toFixed(2));
  2109. $("#balancePayFee").val(balancePayFee);
  2110. $(".balancePayFee").html(balancePayFee);
  2111. $("#surplusBalance").html(surplusBalance);
  2112. $("#availableBalance").html(availableBalance);
  2113. $("#productTotalFee").val(productTotalFee);
  2114. $("#promotionFullReduction").val(reducedPrice);
  2115. $("#productCount").val(productCount);
  2116. $("#presentCount").val(presentCount);
  2117. $("#promotionalGiftsCount").val(giftCount);
  2118. $("#orderTotalFee").val(orderTotalFee);
  2119. $("#payTotalFee").val(payTotalFee);
  2120. $("#inputForm").find("[name*='bpOrderUserinfo.ableUserMoney']").val(availableBalance);
  2121. $("#payableAmount").val(payableAmount);
  2122. }
  2123. initStagesFee(); //初始化分期相关金额
  2124. }
  2125. // 展示商品促销活动详情
  2126. function showPromotionDetail(iframe, title) {
  2127. top.$.jBox(iframe, {
  2128. iframeScrolling: 'yes',
  2129. width: $(top.document).width() - 800,
  2130. height: $(top.document).height() - 200,
  2131. persistent: true,
  2132. title: title,
  2133. buttons: {
  2134. "关闭": '-1'
  2135. },
  2136. submit: function (v, h, f) {
  2137. //确定
  2138. var $jboxFrame = top.$('#jbox-iframe');
  2139. var $mainFrame = top.$('#mainFrame');
  2140. if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
  2141. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  2142. if (!items) {
  2143. return false;
  2144. } else if (items.length > 0) {
  2145. console.log($('.productTable'));
  2146. $(('.producttable')).remove();
  2147. setProductList(items[0], false); //设置商品列表
  2148. // initStages();//初始化分期信息
  2149. return true;
  2150. } else {
  2151. top.$.jBox.tip("请选择...");
  2152. return false;
  2153. }
  2154. }
  2155. },
  2156. });
  2157. }
  2158. /**
  2159. * 改变返佣标识
  2160. */
  2161. function updateRebateFlag() {
  2162. var rebateFlag = $("#rebateFlag").val() * 1;
  2163. console.log(rebateFlag);
  2164. if (1 === rebateFlag) {
  2165. // $("#rebateFlag").val(1);
  2166. //选中返佣订单后不可用优惠券
  2167. // $("#couponBox").find("input[name=clubCouponId]").prop('checked', 'checked');
  2168. checkRebateFee(rebateFlag);
  2169. $("#couponBox").find("input[name=clubCouponId]").prop('checked', '');
  2170. $("#couponBox").find("input[name=clubCouponId]").attr("disabled", true);
  2171. $("#couponBox").find("#bsy").prop('checked', 'checked');
  2172. $("#freePostFlag").attr("value", "-1");
  2173. $("#freeDesc").find(".select2-chosen").text("到付");
  2174. $("#useBalancePayFee").prop('checked', '');
  2175. setFreight();
  2176. $("#freePostFlag").attr("disabled", true);
  2177. $("#useBalancePayFee").attr("disabled", true);
  2178. $("#couponAmount").val(0);
  2179. $("#seen").find("#orderSeen2").prop('checked', 'checked');
  2180. setOrderFee();
  2181. } else {
  2182. // $("#rebateFlag").val(0);
  2183. // $("#couponBox").find("input[name=clubCouponId]").prop('checked', '');
  2184. checkRebateFee(rebateFlag);
  2185. $("#couponBox").find("input[name=clubCouponId]").prop('checked', '');
  2186. $("#couponBox").find("input[name=clubCouponId]").attr("disabled", false);
  2187. $("#freePostFlag").attr("value", "0");
  2188. $("#freeDesc").find(".select2-chosen").text("包邮");
  2189. $("#useBalancePayFee").prop('checked', '');
  2190. setFreight();
  2191. $("#freePostFlag").attr("disabled", false);
  2192. $("#useBalancePayFee").attr("disabled", false);
  2193. $("#couponAmount").val(0);
  2194. $("#seen").find("#orderSeen1").prop('checked', 'checked');
  2195. // 重新计算总价
  2196. setOrderFee();
  2197. }
  2198. }
  2199. function updateRebateFlags() {
  2200. var rebateFlag = $("#rebateCheckBox").is(':checked');
  2201. if (rebateFlag) {
  2202. $("#rebateFlag").val(1);
  2203. //选中返佣订单后不可用优惠券
  2204. // $("#couponBox").find("input[name=clubCouponId]").prop('checked', 'checked');
  2205. $("#couponBox").find("input[name=clubCouponId]").prop('checked', '');
  2206. $("#couponBox").find("input[name=clubCouponId]").attr("disabled", true);
  2207. $("#couponBox").find("#bsy").prop('checked', 'checked');
  2208. $("#freePostFlag").attr("value", "-1");
  2209. $("#freeDesc").find(".select2-chosen").text("到付");
  2210. $("#useBalancePayFee").prop('checked', '');
  2211. setFreight();
  2212. $("#freePostFlag").attr("disabled", true);
  2213. $("#useBalancePayFee").attr("disabled", true);
  2214. $("#couponAmount").val(0);
  2215. $("#seen").find("#orderSeen2").prop('checked', 'checked');
  2216. setOrderFee();
  2217. } else {
  2218. $("#rebateFlag").val(0);
  2219. // $("#couponBox").find("input[name=clubCouponId]").prop('checked', '');
  2220. $("#couponBox").find("input[name=clubCouponId]").prop('checked', '');
  2221. $("#couponBox").find("input[name=clubCouponId]").attr("disabled", false);
  2222. $("#freePostFlag").attr("value", "0");
  2223. $("#freeDesc").find(".select2-chosen").text("包邮");
  2224. $("#useBalancePayFee").prop('checked', '');
  2225. setFreight();
  2226. $("#freePostFlag").attr("disabled", false);
  2227. $("#useBalancePayFee").attr("disabled", false);
  2228. $("#couponAmount").val(0);
  2229. $("#seen").find("#orderSeen1").prop('checked', 'checked');
  2230. // 重新计算总价
  2231. setOrderFee();
  2232. }
  2233. }
  2234. function checkRebateFee(rebateFlag) {
  2235. if (2 === rebateFlag) {
  2236. $("#rebateFee").show();
  2237. } else {
  2238. $("#rebateFee").hide();
  2239. }
  2240. }
  2241. /**
  2242. * 修改返佣选项是否可见
  2243. */
  2244. function showRebateCheck() {
  2245. var length = $(".productTable").length;
  2246. var rebateDiv = document.getElementById("rebateDiv");
  2247. if (rebateDiv != null) {
  2248. if (length != 0 && length != 1) {
  2249. $("#rebateCheckBox").attr("checked", false);
  2250. $("#rebateFlag").val(0);
  2251. rebateDiv.style.cssText = "display:none";
  2252. } else {
  2253. rebateDiv.style.cssText = "";
  2254. }
  2255. }
  2256. }
  2257. /************************商品相关 end**********************************************************/