SupplierTransactionsServices.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\services\supplier\finance;
  12. use app\dao\supplier\finance\SupplierTransactionsDao;
  13. use app\dao\store\StoreUserDao;
  14. use app\services\BaseServices;
  15. use app\services\order\StoreOrderCreateServices;
  16. use app\services\order\StoreOrderServices;
  17. use app\services\pay\PayServices;
  18. /**
  19. * 门店流水
  20. * Class StoreExtractServices
  21. * @package app\services\store\finance
  22. * @mixin SupplierTransactionsDao
  23. */
  24. class SupplierTransactionsServices extends BaseServices
  25. {
  26. /**
  27. * 支付类型
  28. * @var string[]
  29. */
  30. public $pay_type = ['weixin' => '微信支付', 'yue' => '余额支付', 'offline' => '线下支付', 'alipay' => '支付宝支付', 'cash' => '现金支付', 'automatic' => '自动转账', 'store' => '微信支付'];
  31. /**
  32. * 交易类型
  33. * @var string[]
  34. */
  35. public $type = [
  36. 1 => '支付订单',
  37. 2 => '支付订单',
  38. 3 => '订单手续费',
  39. 4 => '退款订单',
  40. 5 => '充值返点',
  41. 6 => '付费会员返点',
  42. 7 => '充值订单',
  43. 8 => '付费订单',
  44. 9 => '收银订单',
  45. 10 => '核销订单',
  46. 11 => '分配订单',
  47. 12 => '配送订单',
  48. 13 => '同城配送订单',
  49. ];
  50. /**
  51. * 构造方法
  52. * StoreUser constructor.
  53. * @param StoreUserDao $dao
  54. */
  55. public function __construct(SupplierTransactionsDao $dao)
  56. {
  57. $this->dao = $dao;
  58. }
  59. /**
  60. * 写入数据
  61. * @param $order
  62. * @param $number
  63. * @param $pm
  64. * @param $type
  65. * @param $trade_type
  66. * @param array $append
  67. * @throws \Exception
  68. */
  69. public function savaData($order, $pm, $type, array $append = [])
  70. {
  71. /** @var StoreOrderCreateServices $storeOrderCreateServices */
  72. $storeOrderCreateServices = app()->make(StoreOrderCreateServices::class);
  73. $order_id = $storeOrderCreateServices->getNewOrderId('ls');
  74. $data = [
  75. 'supplier_id' => $order['supplier_id'] ?? 0,
  76. 'uid' => $order['uid'] ?? 0,
  77. 'order_id' => $order_id,
  78. 'link_id' => $order['order_id'] ?? '',
  79. 'pay_type' => $order['pay_type'] ?? '',
  80. 'trade_time' => $order['pay_time'] ?? $order['add_time'] ?? '',
  81. 'pm' => $pm,
  82. 'type' => $type,
  83. 'add_time' => time()
  84. ];
  85. $data = array_merge($data, $append);
  86. $this->dao->save($data);
  87. }
  88. }