GzcLogRepository.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace app\common\repositories\gzc;
  3. use app\common\dao\gzc\GzcLogDao;
  4. use app\common\enum\CommonEnum;
  5. use app\common\repositories\BaseRepository;
  6. use app\common\repositories\store\order\StoreOrderRepository;
  7. use app\entity\data\gzc\GzcLogEntity;
  8. use think\exception\ValidateException;
  9. class GzcLogRepository extends BaseRepository
  10. {
  11. public function __construct(GzcLogDao $dao)
  12. {
  13. $this->dao = $dao;
  14. }
  15. public function create($data)
  16. {
  17. return $this->dao->create($data);
  18. }
  19. /**
  20. * @param GzcLogEntity $gzcLogEntity
  21. * @return GzcLogEntity
  22. */
  23. public function createByEntity(GzcLogEntity $gzcLogEntity): GzcLogEntity
  24. {
  25. $result = $this->create($gzcLogEntity->toUnderlineArray())->toArray();
  26. /** @var GzcLogEntity $entity */
  27. $entity = GzcLogEntity::newInstance($result);
  28. return $entity;
  29. }
  30. /**
  31. * 添加 公证处记录
  32. * @param int $uid
  33. * @param string $userName
  34. * @param string $mobile
  35. * @param string $userCard
  36. * @param int $orderType
  37. * @param string $orderId
  38. * @param float $pension
  39. * @param int $payType
  40. * @return GzcLogEntity
  41. */
  42. public function addGzcLog(int $uid, string $userName, string $mobile, string $userCard, int $orderType, string $orderId, float $pension, int $payType = 0): GzcLogEntity
  43. {
  44. $linkId = 0;
  45. $orderSn = '';
  46. $payTime = '';
  47. if ($orderType == CommonEnum::ORDER_TYPE['Platform']['code']) {
  48. /** @var StoreOrderRepository $storeOrderRepository */
  49. $storeOrderRepository = app()->make(StoreOrderRepository::class);
  50. $storeOrderEntity = $storeOrderRepository->getStoreOrderEntityByOrderId((int)$orderId);
  51. if (empty($storeOrderEntity->getOrderId())) {
  52. throw new ValidateException('未查询到订单信息');
  53. }
  54. $orderSn = $storeOrderEntity->getOrderSn();
  55. $payTime = $storeOrderEntity->getPayTime();
  56. $payType = 3;// 默认是微信
  57. if ($storeOrderEntity->getFzonePayNote() != "现金") {
  58. $payType = 4;
  59. }
  60. }
  61. $createTime = date('Y-m-d H:i:s');
  62. /** @var GzcLogEntity $gzcLogEntity */
  63. $gzcLogEntity = GzcLogEntity::newInstance();
  64. $gzcLogEntity->setUid($uid)
  65. ->setPlatformNo('IN10' . (int)(microtime(true) * 1000) . mt_rand(10000, 99999))
  66. ->setUserName($userName)
  67. ->setMobile($mobile)
  68. ->setUserCard($userCard)
  69. ->setPension($pension)
  70. ->setOutTradeNo($orderSn)
  71. ->setAccountType($payType)
  72. ->setOrderType($orderType)
  73. ->setPayTime($payTime)
  74. ->setCreateTime($createTime)
  75. ->setUpdateTime($createTime)
  76. ->setLinkId($orderId);
  77. return $this->createByEntity($gzcLogEntity);
  78. }
  79. }