pay_calc.test.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. const { app, assert } = require('egg-mock/bootstrap');
  10. const Calc = require('../../../app/lib/pay_calc');
  11. const PayConst = require('../../../app/const/deal_pay.js');
  12. describe('test/app/lib/pay_calc.test.js', () => {
  13. it('test calculate Stage DealPay TotalPrice', function* () {
  14. const ctx = app.mockContext();
  15. // 模拟登录
  16. const postData = {
  17. account: '734406061@qq.com',
  18. project: 'T201711273363',
  19. project_password: 'mai654321',
  20. };
  21. ctx.session = {};
  22. const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
  23. assert(loginResult);
  24. // 模拟打开标段
  25. ctx.tender = {id: 244};
  26. ctx.tender.data = yield ctx.service.tender.getTender(ctx.tender.id);
  27. ctx.tender.info = yield ctx.service.tenderInfo.getTenderInfo(ctx.tender.id);
  28. // 模拟打开期
  29. ctx.stage = yield ctx.service.stage.getDataByCondition({
  30. id: 43
  31. });
  32. ctx.stage.curTimes = ctx.stage.times;
  33. ctx.stage.curOrder = 0;
  34. const calc = new Calc(ctx, ctx.tender.info.decimal);
  35. const dealPay = yield ctx.service.stagePay.getStageLastestPays(ctx.stage);
  36. yield calc.calculateAll(dealPay);
  37. const bqwc = app._.find(dealPay, {ptype: PayConst.payType.wc});
  38. assert(bqwc.tp === 26220);
  39. const bqyf = app._.find(dealPay, {ptype: PayConst.payType.yf});
  40. assert(bqyf.tp === 26220);
  41. });
  42. });