| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- namespace app\common\repositories\gzc;
- use app\common\dao\gzc\GzcLogDao;
- use app\common\enum\CommonEnum;
- use app\common\repositories\BaseRepository;
- use app\common\repositories\store\order\StoreOrderRepository;
- use app\entity\data\gzc\GzcLogEntity;
- use think\exception\ValidateException;
- class GzcLogRepository extends BaseRepository
- {
- public function __construct(GzcLogDao $dao)
- {
- $this->dao = $dao;
- }
- public function create($data)
- {
- return $this->dao->create($data);
- }
- /**
- * @param GzcLogEntity $gzcLogEntity
- * @return GzcLogEntity
- */
- public function createByEntity(GzcLogEntity $gzcLogEntity): GzcLogEntity
- {
- $result = $this->create($gzcLogEntity->toUnderlineArray())->toArray();
- /** @var GzcLogEntity $entity */
- $entity = GzcLogEntity::newInstance($result);
- return $entity;
- }
- /**
- * 添加 公证处记录
- * @param int $uid
- * @param string $userName
- * @param string $mobile
- * @param string $userCard
- * @param int $orderType
- * @param string $orderId
- * @param float $pension
- * @param int $payType
- * @return GzcLogEntity
- */
- public function addGzcLog(int $uid, string $userName, string $mobile, string $userCard, int $orderType, string $orderId, float $pension, int $payType = 0): GzcLogEntity
- {
- $linkId = 0;
- $orderSn = '';
- $payTime = '';
- if ($orderType == CommonEnum::ORDER_TYPE['Platform']['code']) {
- /** @var StoreOrderRepository $storeOrderRepository */
- $storeOrderRepository = app()->make(StoreOrderRepository::class);
- $storeOrderEntity = $storeOrderRepository->getStoreOrderEntityByOrderId((int)$orderId);
- if (empty($storeOrderEntity->getOrderId())) {
- throw new ValidateException('未查询到订单信息');
- }
- $orderSn = $storeOrderEntity->getOrderSn();
- $payTime = $storeOrderEntity->getPayTime();
- $payType = 3;// 默认是微信
- if ($storeOrderEntity->getFzonePayNote() != "现金") {
- $payType = 4;
- }
- }
- $createTime = date('Y-m-d H:i:s');
- /** @var GzcLogEntity $gzcLogEntity */
- $gzcLogEntity = GzcLogEntity::newInstance();
- $gzcLogEntity->setUid($uid)
- ->setPlatformNo('IN10' . (int)(microtime(true) * 1000) . mt_rand(10000, 99999))
- ->setUserName($userName)
- ->setMobile($mobile)
- ->setUserCard($userCard)
- ->setPension($pension)
- ->setOutTradeNo($orderSn)
- ->setAccountType($payType)
- ->setOrderType($orderType)
- ->setPayTime($payTime)
- ->setCreateTime($createTime)
- ->setUpdateTime($createTime)
- ->setLinkId($orderId);
- return $this->createByEntity($gzcLogEntity);
- }
- }
|