StoreYcOperationRecord.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use yii\base\ErrorException;
  9. use yii\db\ActiveRecord;
  10. use yii\behaviors\TimestampBehavior;
  11. use Yii;
  12. /**
  13. * This is the model class for table "{{%partner_pool_award-record}}".
  14. *
  15. * @property integer $id
  16. * @property float $money
  17. * @property integer $store_id
  18. * @property integer $store_settle_id
  19. * @property integer $yc_settle_id
  20. * @property integer $created_at
  21. * @property string $order_no
  22. */
  23. class StoreYcOperationRecord extends \yii\db\ActiveRecord
  24. {
  25. /**
  26. * @inheritdoc
  27. */
  28. public static function tableName()
  29. {
  30. return '{{%store_yc_operation_record}}';
  31. }
  32. public function behaviors()
  33. {
  34. return [
  35. [
  36. 'class' => TimestampBehavior::class,
  37. 'attributes' => [
  38. ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
  39. ]
  40. ]
  41. ];
  42. }
  43. /**
  44. * @inheritdoc
  45. */
  46. public function rules()
  47. {
  48. return [
  49. [[ 'store_id', 'store_settle_id','yc_settle_id'], 'integer'],
  50. [['order_no'], 'string'],
  51. [['money'], 'number'],
  52. [['created_at'], 'safe']
  53. ];
  54. }
  55. public static function createRecord($money,$store_id,$store_settle_id,$yc_settle_id){
  56. try {
  57. $record = new self();
  58. $record->money=$money;
  59. $record->store_id=$store_id;
  60. $record->store_settle_id=$store_settle_id;
  61. $record->yc_settle_id=$yc_settle_id;
  62. $record->order_no=\app\utils\OrderNo::getOrderNo(\app\utils\OrderNo::SOTRE_YC_OPERATION);
  63. if (!$record->save())throw new ErrorException('保存失败'.json_encode($record->getErrors()));
  64. return true;
  65. }catch (ErrorException $e){
  66. //debug_log([__METHOD__, __LINE__, "发放是失败 {$e->getMessage() }"], "app_debug_partner.log");
  67. return false;
  68. }
  69. }
  70. }