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() ]; } } }