GzcLogRepository.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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): GzcLogEntity
  43. {
  44. $orderSn = '';
  45. $payTime = '';
  46. if ($orderType == CommonEnum::ORDER_TYPE['Platform']['code']) {
  47. /** @var StoreOrderRepository $storeOrderRepository */
  48. $storeOrderRepository = app()->make(StoreOrderRepository::class);
  49. $storeOrderEntity = $storeOrderRepository->getStoreOrderEntityByOrderId((int)$orderId);
  50. if (empty($storeOrderEntity->getOrderId())) {
  51. throw new ValidateException('未查询到订单信息');
  52. }
  53. $orderSn = $storeOrderEntity->getOrderSn();
  54. $payTime = $storeOrderEntity->getPayTime();
  55. $payType = 3;// 默认是微信
  56. if ($storeOrderEntity->getFzonePayNote() != "现金") {
  57. $payType = 4;
  58. }
  59. }
  60. $createTime = date('Y-m-d H:i:s');
  61. /** @var GzcLogEntity $gzcLogEntity */
  62. $gzcLogEntity = GzcLogEntity::newInstance();
  63. $gzcLogEntity->setUid($uid)
  64. ->setUserName($userName)
  65. ->setMobile($mobile)
  66. ->setUserCard($userCard)
  67. ->setPension($pension)
  68. ->setOutTradeNo($orderSn)
  69. ->setAccountType($payType)
  70. ->setOrderType($orderType)
  71. ->setPayTime($payTime)
  72. ->setCreateTime($createTime)
  73. ->setUpdateTime($createTime);
  74. return $this->createByEntity($gzcLogEntity);
  75. }
  76. }