| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\models;
- use yii\db\ActiveRecord;
- use yii\behaviors\TimestampBehavior;
- /**
- * This is the model class for table "{{%integral_appreciation_transfer_integral_log}}".
- *
- * @property integer $id
- * @property integer $user_id
- * @property integer $store_id
- * @property float $amount
- * @property float $transfer_amount
- * @property integer $type
- * @property float $integral_price
- * @property float $fee
- * @property string $created_at
- * @property string $updated_at
- */
- class IntegralAppreciationTransferIntegralLog extends \yii\db\ActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%integral_appreciation_transfer_integral_log}}';
- }
- public function behaviors()
- {
- return [
- [
- 'class' => TimestampBehavior::class
- ]
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['id', 'user_id', 'type','store_id'], 'integer'],
- [['amount','transfer_amount','integral_price','fee', 'created_at', 'updated_at'], 'number'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => '',
- 'user_id' => '用户ID',
- 'store_id' => '商户ID',
- 'amount' => '数量',
- 'transfer_amount' => '转换数量',
- 'type' => '类型 1积分转余额 2余额转积分',
- 'integral_price' => '积分价格',
- 'fee' => '手续费',
- 'created_at' => '',
- 'updated_at' => ''
- ];
- }
- public static function saveIntegralLog($user_id,$store_id, $num,$transfer_amount ,$integral_price, $fee,$type) {
- $user = IntegralAppreciationUser::findOne(['user_id'=>$user_id]);
- if (!$user) {
- return [
- 'code' => 1,
- 'msg' => '用户不存在'
- ];
- }
- try {
- $integral_log = new IntegralAppreciationTransferIntegralLog();
- $integral_log->user_id = $user_id;
- $integral_log->store_id = $store_id;
- $integral_log->amount = $num;
- $integral_log->transfer_amount = $transfer_amount;
- $integral_log->type = $type;
- $integral_log->integral_price = $integral_price;
- $integral_log->fee = $fee;
- $integral_log->save();
- return [
- 'code' => 0,
- 'msg' => '操作成功'
- ];
- }catch (\Exception $e){
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- }
|